MCPcopy Create free account
hub / github.com/java-native-access/jna / testToString

Method testToString

test/com/sun/jna/StructureTest.java:1419–1453  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1417 }
1418
1419 public void testToString() {
1420 // wce missing String.matches() and regex support
1421 if (Platform.isWindowsCE()) return;
1422
1423 class TestStructure extends Structure {
1424 public int intField;
1425 public PublicTestStructure inner;
1426 @Override
1427 protected List<String> getFieldOrder() {
1428 return Arrays.asList("intField", "inner");
1429 }
1430 }
1431 TestStructure s = new TestStructure();
1432 final String LS = System.lineSeparator();
1433 System.setProperty("jna.dump_memory", "true");
1434 final String EXPECTED = "(?m).*" + s.size() + " bytes.*\\{" + LS
1435 + " int intField@0x0=0x0000" + LS
1436 + " .* inner@0x4=.*\\{" + LS
1437 + " int x@0x0=.*" + LS
1438 + " int y@0x4=.*" + LS
1439 + " \\}" + LS
1440 + "\\}" + LS
1441 + "memory dump" + LS
1442 + "\\[[0-9a-f]+\\]" + LS
1443 + "\\[[0-9a-f]+\\]" + LS
1444 + "\\[[0-9a-f]+\\]";
1445 String actual = s.toString();
1446 assertTrue("Improperly formatted toString(): expected "
1447 + EXPECTED + "\n" + actual,
1448 actual.matches(EXPECTED));
1449
1450 System.setProperty("jna.dump_memory", "false");
1451 assertFalse("Doesn't dump memory when jna.dump_memory is false",
1452 s.toString().contains("memory dump"));
1453 }
1454
1455 public void testNativeMappedWrite() {
1456 class TestStructure extends Structure {

Callers

nothing calls this directly

Calls 5

isWindowsCEMethod · 0.95
containsMethod · 0.80
setPropertyMethod · 0.65
sizeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected