MCPcopy Index your code
hub / github.com/java-native-access/jna / testToArray

Method testToArray

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

Source from the content-addressed store, hash-verified

958 }
959
960 public void testToArray() {
961 final int allocated[] = { 0 };
962 PublicTestStructure.allocations = 0;
963 PublicTestStructure s = new PublicTestStructure();
964 PublicTestStructure[] array = (PublicTestStructure[])s.toArray(1);
965 assertEquals("Array should consist of a single element",
966 1, array.length);
967 assertEquals("First element should be original", s, array[0]);
968
969 array = (PublicTestStructure[])s.toArray(2);
970 assertEquals("Structure memory should be expanded", 2, array.length);
971 assertEquals("No memory should be allocated for new element", 1, PublicTestStructure.allocations);
972 assertEquals("Structure.read called on New element", 0, array[1].x);
973 }
974
975 public void testByReferenceArraySync() {
976 PublicTestStructure.ByReference s = new PublicTestStructure.ByReference();

Callers

nothing calls this directly

Calls 1

toArrayMethod · 0.45

Tested by

no test coverage detected