-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ca879b
commit e22d482
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
java/cuvs-java/src/test/java/com/nvidia/cuvs/internal/common/UtilIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.nvidia.cuvs.internal.common; | ||
|
||
import com.nvidia.cuvs.CuVSTestCase; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.MethodType; | ||
|
||
import static com.carrotsearch.randomizedtesting.RandomizedTest.assumeTrue; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
public class UtilIT extends CuVSTestCase { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(UtilIT.class); | ||
|
||
@Before | ||
public void setup() { | ||
assumeTrue("not supported on " + System.getProperty("os.name"), isLinuxAmd64()); | ||
} | ||
|
||
@Test | ||
public void testGetLastErrorText() throws Throwable { | ||
var cls = Class.forName("com.nvidia.cuvs.internal.common.Util"); | ||
var lookup = MethodHandles.lookup(); | ||
var mt = MethodType.methodType(String.class); | ||
var mh = lookup.findStatic(cls, "getLastErrorText", mt); | ||
|
||
// first, ensures that accessing the error text when there is none does not crash! | ||
String errorText = (String) mh.invoke(); | ||
// second, ensures that the default test is returned | ||
assertThat(errorText, equalTo("no last error text")); | ||
} | ||
} |