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

Method testAlignment

test/com/sun/jna/MemoryTest.java:89–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87 }
88
89 public void testAlignment() {
90 final int SIZE = 1<<16;
91 Memory base = new Memory(SIZE);
92 for (int align=1;align < SIZE;align *= 2) {
93 Memory unaligned = base;
94 long mask = ~((long)align - 1);
95 if ((base.peer & mask) == base.peer)
96 unaligned = (Memory)base.share(1, SIZE-1);
97 Pointer aligned = unaligned.align(align);
98 assertEquals("Memory not aligned (" + align + ")",
99 aligned.peer & mask, aligned.peer);
100
101 assertSame("Alignment request on aligned memory should no-op",
102 aligned, ((Memory)aligned).align(align));
103 }
104 }
105
106 public void testNegativeAlignment() {
107 final int SIZE = 128;

Callers

nothing calls this directly

Calls 2

shareMethod · 0.95
alignMethod · 0.95

Tested by

no test coverage detected