Search in sources :

Example 6 with DynamicArrayLong

use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.

the class DynamicArrayLongTest method testAddArray.

/**
     * Tests the add(long[]) method.
     */
public void testAddArray() {
    final DynamicArrayLong array = new DynamicArrayLong(10);
    final long[] subArray = new long[5];
    assertEquals(0, array.size());
    // adds arrays containing increasing number to the DynamicArrayLong 
    for (int i = 0; i <= 4; i++) {
        for (int j = 0; j < subArray.length; j++) {
            subArray[j] = i * subArray.length + (j + 1);
        }
        final int index = array.add(subArray);
        assertEquals((i + 1) * subArray.length - 1, index);
        assertEquals((i + 1) * subArray.length, array.size());
    }
    // it shall contain the values [1, 2, 3...19, 20] in the same order
    for (int i = 0; i < array.size(); i++) {
        assertEquals(i + 1, array.get(i));
    }
}
Also used : DynamicArrayLong(com.vodafone360.people.utils.DynamicArrayLong)

Example 7 with DynamicArrayLong

use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.

the class DynamicArrayLongTest method testToArray.

/**
     * Tests the toArray() method.
     */
public void testToArray() {
    final int ADDS_COUNT = 20;
    final DynamicArrayLong array = new DynamicArrayLong(ADDS_COUNT / 4);
    // check that the array is empty after creation
    assertEquals(0, array.size());
    // add the values [0..ADDS_COUNT] to the array
    for (int i = 0; i < ADDS_COUNT; i++) {
        array.add(i);
    }
    // get all the values in the DynamicArrayLong as a primitive long array
    final long[] toArray = array.toArray();
    assertEquals(ADDS_COUNT, toArray.length);
    // check that the values in the array are [0..ADDS_COUNT] 
    for (int i = 0; i < toArray.length; i++) {
        assertEquals(i, toArray[i]);
    }
}
Also used : DynamicArrayLong(com.vodafone360.people.utils.DynamicArrayLong)

Example 8 with DynamicArrayLong

use of com.vodafone360.people.utils.DynamicArrayLong in project 360-Engine-for-Android by 360.

the class DynamicArrayLongTest method testAddGetSize.

/**
     * Tests the add(), get() and size() methods.
     */
public void testAddGetSize() {
    final int ADDS_COUNT = 20;
    final DynamicArrayLong array = new DynamicArrayLong();
    // check that the array is empty after creation
    assertEquals(0, array.size());
    // perform checks for add/get/size methods
    for (int i = 0; i < ADDS_COUNT; i++) {
        final int ret = array.add(i + 10);
        assertEquals(i, ret);
        assertEquals(i + 10, array.get(i));
        assertEquals(i + 1, array.size());
    }
}
Also used : DynamicArrayLong(com.vodafone360.people.utils.DynamicArrayLong)

Aggregations

DynamicArrayLong (com.vodafone360.people.utils.DynamicArrayLong)8