@Test public void testGetAndSetUnsignedInt() throws Exception { DynamicByteBuffer buf = new DynamicByteBuffer(); long MAX_UNSIGNED_INT = 4294967295L; buf.putUnsignedInt(MAX_UNSIGNED_INT); buf.putUnsignedInt(1); buf.putUnsignedInt(0); buf.putUnsignedInt(-1); buf.putUnsignedInt(MAX_UNSIGNED_INT + 1); assertEquals(buf.position(), 20); buf.flip(); assertEquals(buf.position(), 0); assertEquals(buf.limit(), 20); assertEquals("test 1", MAX_UNSIGNED_INT, buf.getUnsignedInt()); assertEquals("test 2", 1L, buf.getUnsignedInt()); assertEquals("test 3", 0L, buf.getUnsignedInt()); assertEquals("test 4", MAX_UNSIGNED_INT, buf.getUnsignedInt()); assertEquals("test 5", 0L, buf.getUnsignedInt()); assertEquals(buf.position(), 20); buf.putUnsignedIntAt(0, 121); buf.putUnsignedIntAt(4, 4000000000L); assertEquals(121L, buf.getUnsignedIntAt(0)); assertEquals(4000000000L, buf.getUnsignedIntAt(4)); assertEquals(buf.position(), 20); }
@Test(expected = BufferOverflowException.class) public void testGetAndSetPutUnsignedIntException() throws Exception { DynamicByteBuffer buf = DynamicByteBuffer.allocate(0); buf.setAutoExpand(false); buf.putUnsignedInt(121); }