public void testSlice() { assertTrue(buf.capacity() > 5); buf.position(1); buf.limit(buf.capacity() - 1); DoubleBuffer slice = buf.slice(); assertEquals(buf.isReadOnly(), slice.isReadOnly()); assertEquals(buf.isDirect(), slice.isDirect()); assertEquals(buf.order(), slice.order()); assertEquals(slice.position(), 0); assertEquals(slice.limit(), buf.remaining()); assertEquals(slice.capacity(), buf.remaining()); try { slice.reset(); fail("Should throw Exception"); // $NON-NLS-1$ } catch (InvalidMarkException e) { // expected } // slice share the same content with buf // FIXME: if (!slice.isReadOnly()) { loadTestData1(slice); assertContentLikeTestData1(buf, 1, 0, slice.capacity()); buf.put(2, 500); assertEquals(slice.get(1), 500, 0.0); } }
public void testDuplicate() { buf.clear(); buf.mark(); buf.position(buf.limit()); // duplicate's contents should be the same as buf DoubleBuffer duplicate = buf.duplicate(); assertNotSame(buf, duplicate); assertEquals(buf.position(), duplicate.position()); assertEquals(buf.limit(), duplicate.limit()); assertEquals(buf.isReadOnly(), duplicate.isReadOnly()); assertEquals(buf.isDirect(), duplicate.isDirect()); assertEquals(buf.order(), duplicate.order()); assertContentEquals(buf, duplicate); // duplicate's position, mark, and limit should be independent to buf duplicate.reset(); assertEquals(duplicate.position(), 0); duplicate.clear(); assertEquals(buf.position(), buf.limit()); buf.reset(); assertEquals(buf.position(), 0); // duplicate share the same content with buf // FIXME if (!duplicate.isReadOnly()) { loadTestData1(buf); assertContentEquals(buf, duplicate); loadTestData2(duplicate); assertContentEquals(buf, duplicate); } }
@TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Abstract method.", method = "isReadOnly", args = {}) public void testIsReadOnly() { assertFalse(buf.isReadOnly()); }
@TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "asReadOnlyBuffer", args = {}) public void testAsReadOnlyBuffer() { buf.clear(); buf.mark(); buf.position(buf.limit()); // readonly's contents should be the same as buf DoubleBuffer readonly = buf.asReadOnlyBuffer(); assertNotSame(buf, readonly); assertTrue(readonly.isReadOnly()); assertEquals(buf.position(), readonly.position()); assertEquals(buf.limit(), readonly.limit()); assertEquals(buf.isDirect(), readonly.isDirect()); assertEquals(buf.order(), readonly.order()); assertContentEquals(buf, readonly); // readonly's position, mark, and limit should be independent to buf readonly.reset(); assertEquals(readonly.position(), 0); readonly.clear(); assertEquals(buf.position(), buf.limit()); buf.reset(); assertEquals(buf.position(), 0); // BEGIN android-added // copied from a newer version of Harmony DoubleBuffer dbuffer1 = DoubleBuffer.wrap(new double[] {Double.NaN}); DoubleBuffer dbuffer2 = DoubleBuffer.wrap(new double[] {Double.NaN}); DoubleBuffer dbuffer3 = DoubleBuffer.wrap(new double[] {42d}); assertEquals("Failed equal comparison with NaN entry", 0, dbuffer1.compareTo(dbuffer2)); assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer3.compareTo(dbuffer1)); assertEquals("Failed greater than comparison with NaN entry", 1, dbuffer1.compareTo(dbuffer3)); // END android-added }
public void testAsReadOnlyBuffer() { buf.clear(); buf.mark(); buf.position(buf.limit()); // readonly's contents should be the same as buf DoubleBuffer readonly = buf.asReadOnlyBuffer(); assertNotSame(buf, readonly); assertTrue(readonly.isReadOnly()); assertEquals(buf.position(), readonly.position()); assertEquals(buf.limit(), readonly.limit()); assertEquals(buf.isDirect(), readonly.isDirect()); assertEquals(buf.order(), readonly.order()); assertContentEquals(buf, readonly); // readonly's position, mark, and limit should be independent to buf readonly.reset(); assertEquals(readonly.position(), 0); readonly.clear(); assertEquals(buf.position(), buf.limit()); buf.reset(); assertEquals(buf.position(), 0); }