< prev index next >

test/jdk/java/foreign/CompositeLookupTest.java

Print this page

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 import org.testng.annotations.Test;
 25 
 26 import java.lang.foreign.*;
 27 import java.util.List;
 28 import java.util.Optional;
 29 import java.util.Set;
 30 
 31 import org.testng.annotations.*;
 32 
 33 import static org.testng.Assert.*;
 34 
 35 /*
 36  * @test
 37  * @enablePreview
 38  * @run testng CompositeLookupTest
 39  */
 40 public class CompositeLookupTest {
 41 
 42     @Test(dataProvider = "testCases")
 43     public void testLookups(SymbolLookup lookup, List<Result> results) {
 44         for (Result result : results) {
 45             switch (result) {
 46                 case Success(String name, long expectedLookupId) -> {
 47                     Optional<MemorySegment> symbol = lookup.find(name);
 48                     assertTrue(symbol.isPresent());
 49                     assertEquals(symbol.get().address(), expectedLookupId);
 50                 }
 51                 case Failure(String name) -> {
 52                     Optional<MemorySegment> symbol = lookup.find(name);
 53                     assertFalse(symbol.isPresent());
 54                 }
 55             }
 56         }
 57     }

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 import org.testng.annotations.Test;
 25 
 26 import java.lang.foreign.*;
 27 import java.util.List;
 28 import java.util.Optional;
 29 import java.util.Set;
 30 
 31 import org.testng.annotations.*;
 32 
 33 import static org.testng.Assert.*;
 34 
 35 /*
 36  * @test

 37  * @run testng CompositeLookupTest
 38  */
 39 public class CompositeLookupTest {
 40 
 41     @Test(dataProvider = "testCases")
 42     public void testLookups(SymbolLookup lookup, List<Result> results) {
 43         for (Result result : results) {
 44             switch (result) {
 45                 case Success(String name, long expectedLookupId) -> {
 46                     Optional<MemorySegment> symbol = lookup.find(name);
 47                     assertTrue(symbol.isPresent());
 48                     assertEquals(symbol.get().address(), expectedLookupId);
 49                 }
 50                 case Failure(String name) -> {
 51                     Optional<MemorySegment> symbol = lookup.find(name);
 52                     assertFalse(symbol.isPresent());
 53                 }
 54             }
 55         }
 56     }
< prev index next >