Package krati.core.array.basic

Examples of krati.core.array.basic.MemoryShortArray


*/
public class TestMemoryShortArray extends TestCase {
    final Random _rand = new Random();
   
    public void testApiBasics() {
        MemoryShortArray array = new MemoryShortArray();
        int length = array.length();
        int anyIndex = _rand.nextInt(length);
        onArray(array, anyIndex);
       
        anyIndex = length + _rand.nextInt(length);
        onArray(array, anyIndex);
        assertTrue(length < array.length());
       
        length = array.length();
        anyIndex = length + _rand.nextInt(length);
        onArray(array, anyIndex);
        assertTrue(length < array.length());
       
        length = array.length();
        anyIndex = length + _rand.nextInt(length << 5);
        onArray(array, anyIndex);
        assertTrue(length < array.length());
    }
View Full Code Here


            assertEquals(0, array.get(index));
        }
    }
   
    public void testMaxLength() {
        MemoryShortArray array = new MemoryShortArray();
        int index = Integer.MAX_VALUE - 1;
        short value = (short)10;
        array.set(index, value);
        assertEquals(value, array.get(index));
        assertEquals(Integer.MAX_VALUE, array.length());
       
        /**
         * The index can go to Integer.MAX_VALUE even array length is Integer.MAX_VALUE
         */
        index = Integer.MAX_VALUE;
        array.set(index, value);
        assertEquals(value, array.get(index));
        assertEquals(Integer.MAX_VALUE, array.length());
    }
View Full Code Here

TOP

Related Classes of krati.core.array.basic.MemoryShortArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.