27import java.nio.ByteBuffer;
28import java.nio.ByteOrder;
30import org.jau.io.Buffers;
31import org.jau.io.MemUtil;
32import org.junit.Assert;
33import org.junit.FixMethodOrder;
35import org.junit.runners.MethodSorters;
37import jau.pkg.PlatformRuntime;
38import jau.test.junit.util.JunitTracer;
40@FixMethodOrder(MethodSorters.NAME_ASCENDING)
42 static final boolean DEBUG =
false;
44 @Test(timeout = 10000)
45 public final
void test01_ByteBuffer() {
46 PlatformRuntime.checkInitialized();
49 final ByteBuffer b1 = Buffers.newDirectByteBuffer(len * 2);
50 Assert.assertEquals(len * 2, b1.capacity());
51 Assert.assertEquals(len * 2, b1.limit());
52 Assert.assertEquals(0, b1.position());
53 Assert.assertEquals(len * 2, b1.remaining());
54 Assert.assertEquals(ByteOrder.nativeOrder(), b1.order());
56 for(
int i=0; i<len; ++i) {
59 Assert.assertEquals(len, b1.position());
61 Assert.assertEquals(len, b1.limit());
62 Assert.assertEquals(0, b1.position());
63 Assert.assertEquals(len, b1.remaining());
65 Assert.assertEquals((
byte)0xaa, b1.get(0));
66 Assert.assertEquals((
byte)0xaa, b1.get(len-1));
67 MemUtil.zeroByteBuffer(b1);
68 Assert.assertEquals((
byte)0x00, b1.get(0));
69 Assert.assertEquals((
byte)0x00, b1.get(len-1));
139 public static void main(
final String args[]) {
static void main(final String args[])