use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testTruncate.
/**
*/
@Test
public void testTruncate() {
GridLongList list = asList(1, 2, 3, 4, 5, 6, 7, 8);
list.truncate(4, true);
assertEquals(asList(1, 2, 3, 4), list);
list.truncate(2, false);
assertEquals(asList(3, 4), list);
list = new GridLongList();
list.truncate(0, false);
list.truncate(0, true);
assertEquals(new GridLongList(), list);
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testArray.
/**
*/
@Test
public void testArray() {
GridLongList list = new GridLongList();
long[] array = list.array();
assertNotNull(array);
assertEquals(0, array.length);
list.add(1L);
array = list.array();
assertNotNull(array);
assertEquals(1, array.length);
assertEquals(1L, array[0]);
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testCopyWithout.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("ZeroLengthArrayAllocation")
@Test
public void testCopyWithout() throws Exception {
assertCopy(new GridLongList(new long[] {}), new GridLongList(new long[] {}));
assertCopy(new GridLongList(new long[] {}), new GridLongList(new long[] { 1 }));
assertCopy(new GridLongList(new long[] { 1 }), new GridLongList(new long[] {}));
assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 4, 5, 6 }));
assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 1, 2, 3 }));
assertCopy(new GridLongList(new long[] { 1, 2, 3, 4, 5, 1 }), new GridLongList(new long[] { 1, 1 }));
assertCopy(new GridLongList(new long[] { 1, 1, 1, 2, 3, 4, 5, 1, 1, 1 }), new GridLongList(new long[] { 1, 1 }));
assertCopy(new GridLongList(new long[] { 1, 2, 3 }), new GridLongList(new long[] { 1, 1, 2, 2, 3, 3 }));
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridLongListSelfTest method testSerializationInsufficientBuffer.
/**
*/
@Test
public void testSerializationInsufficientBuffer() {
MessageWriter writer = new DirectMessageWriter(GridIoManager.DIRECT_PROTO_VER);
ByteBuffer buf = ByteBuffer.allocate(10);
GridLongList ll = new GridLongList(new long[] { 1L, 2L, 3L });
Assert.assertFalse(ll.writeTo(buf, writer));
Assert.assertEquals(10, buf.position());
}
Aggregations