public void testStoreInt32() { Int64Array empty = Int64Array.make(0); Int64Array tri = Int64Array.make(3); tri.storeInt64(0, Long.MIN_VALUE); assertEquals(tri.int64At(0), Long.MIN_VALUE); tri.storeInt64(1, (int) 1); assertEquals(tri.int64At(1), 1); tri.storeInt64(2, Long.MAX_VALUE); assertEquals(tri.int64At(2), Long.MAX_VALUE); try { tri.storeInt64(-1, (int) 1); fail("-1"); } catch (IndexOutOfBoundsException e) { // expected } try { tri.storeInt64(3, (int) 1); fail("3"); } catch (IndexOutOfBoundsException e) { // expected } try { empty.storeInt64(0, (int) 1); fail("0"); } catch (IndexOutOfBoundsException e) { // expected } }
public void testStoreInteger() { Int64Array empty = Int64Array.make(0); Int64Array tri = Int64Array.make(3); // Store integer values within spec tri.storeInteger(0, IntegerValue.make(Long.MIN_VALUE)); assertTrue(tri.int64At(0) == Long.MIN_VALUE); tri.storeInteger(1, IntegerValue.make(1)); assertEquals(tri.int64At(1), 1); tri.storeInteger(2, IntegerValue.make(Long.MAX_VALUE)); assertTrue(tri.int64At(2) == Long.MAX_VALUE); // Store integer values outside of spec try { tri.storeInteger(0, IntegerValue.make(Long.MIN_VALUE).minus(IntegerValue.one())); fail("MIN_VALUE - 1"); } catch (IllegalArgumentException e) { // expected } try { tri.storeInteger(2, IntegerValue.make(Long.MAX_VALUE).plus(IntegerValue.one())); fail("MAX_VALUE + 1"); } catch (IllegalArgumentException e) { // expected } // Store outside array boundary try { tri.storeInteger(-1, IntegerValue.make(1)); fail("-1"); } catch (IndexOutOfBoundsException e) { // expected } try { tri.storeInteger(3, IntegerValue.make(1)); fail("3"); } catch (IndexOutOfBoundsException e) { // expected } try { empty.storeInteger(0, IntegerValue.make(1)); fail("0"); } catch (IndexOutOfBoundsException e) { // expected } }
public void testMakeBuffer() { Int64Array array = Int64Array.make(new long[] {}); assertEquals(0, array.count()); array = Int64Array.make(new long[] {1, 2}); assertEquals(2, array.count()); assertEquals(1, array.int64At(0)); assertEquals(2, array.int64At(1)); }
public void testInt32AtEmpty() { Int64Array a = Int64Array.make(0); try { a.int64At(0); fail("0"); } catch (IndexOutOfBoundsException e) { // OutOfBounds } }
public void testInt32At() { Int64Array a = Int64Array.make(new long[] {0, 1, -2, 3}); AssertArrays.assertEquals(0, a.int64At(0)); AssertArrays.assertEquals(1, a.int64At(1)); AssertArrays.assertEquals(-2, a.int64At(2)); AssertArrays.assertEquals(3, a.int64At(3)); try { a.int64At(-1); fail("-1"); } catch (IndexOutOfBoundsException e) { // expected } try { a.int64At(4); fail("4"); } catch (IndexOutOfBoundsException e) { // expected } }
public void testMakeCount() { Int64Array array = Int64Array.make(0); assertEquals(0, array.count()); array = Int64Array.make(1); AssertArrays.assertEquals(1, array.count()); AssertArrays.assertEquals(0, array.int64At(0)); try { Int64Array.make(-1); fail("-1"); } catch (NegativeArraySizeException e) { // expected } }
public void testStoreValue() { Int64Array empty = Int64Array.make(0); Int64Array tri = Int64Array.make(3); // Store integer values within spec tri.storeValue(0, IntegerValue.make(Long.MIN_VALUE)); assertTrue(tri.int64At(0) == Long.MIN_VALUE); tri.storeValue(1, IntegerValue.make(1)); assertEquals(tri.int64At(1), 1); tri.storeValue(2, IntegerValue.make(Long.MAX_VALUE)); assertTrue(tri.int64At(2) == Long.MAX_VALUE); // Store integer values outside of spec try { tri.storeValue(0, IntegerValue.make(Long.MIN_VALUE).minus(IntegerValue.one())); fail("MIN_VALUE - 1"); } catch (IllegalArgumentException e) { // expected } try { tri.storeValue(2, IntegerValue.make(Long.MAX_VALUE).plus(IntegerValue.one())); fail("MAX_VALUE + 1"); } catch (IllegalArgumentException e) { // expected } // Store outside array boundary try { tri.storeValue(-1, IntegerValue.make(1)); fail("-1"); } catch (IndexOutOfBoundsException e) { // expected } try { tri.storeValue(3, IntegerValue.make(1)); fail("3"); } catch (IndexOutOfBoundsException e) { // expected } try { empty.storeValue(0, IntegerValue.make(1)); fail("0"); } catch (IndexOutOfBoundsException e) { // expected } // non-compatible store try { tri.storeValue(0, IEEE64Value.make(1.1)); fail("classCast"); } catch (ClassCastException e) { // expected } // Null value try { tri.storeValue(0, null); fail("null"); } catch (NullPointerException e) { // expected } }