public void testIsEqual() { long[] intsE = new long[] {}; long[] ints1 = new long[] {1}; long[] ints12 = new long[] {1, 2}; long[] ints11 = new long[] {1, 1}; // Equal matches assertTrue(Int64Array.make(intsE).isEqual(Int64Array.make(intsE))); assertTrue(Int64Array.make(ints1).isEqual(Int64Array.make(ints1))); assertTrue(Int64Array.make(ints12).isEqual(Int64Array.make(ints12))); assertTrue(Int64Array.make(ints1).isEqual(AssertArrays.makeInt64Array1())); // Unequal compatible matches assertFalse(Int64Array.make(ints11).isEqual(Int64Array.make(ints12))); assertFalse(Int64Array.make(intsE).isEqual(Int64Array.make(ints12))); assertFalse(Int64Array.make(ints12).isEqual(Int64Array.make(intsE))); // single value assertFalse(Int64Array.make(ints1).isEqual(IntegerValue.make(1))); // incompatible array try { assertFalse(Int64Array.make(ints1).isEqual(AssertArrays.makeIEEE32Array1())); fail("ieee32"); } catch (UnsupportedOperationException e) { // expected } }
public void printOn(PrintWriter oo) { oo.print(getClass().getName()); oo.print(" on "); oo.print(array().subTableBetween(index(), IntegerValue.make(lastValueInternal))); /* udanax-top.st:55493:AscendingArrayStepper methodsFor: 'printing'! {void} printOn: oo {ostream reference} oo << self getCategory name << ' on ' << (self array subTableBetween: self index with: lastValueInternal)! */ }
public Stepper copy() { return AscendingArrayStepper.make(array(), index(), IntegerValue.make(lastValueInternal)); /* udanax-top.st:55458:AscendingArrayStepper methodsFor: 'create'! {Stepper} copy ^AscendingArrayStepper make: self array with: self index with: lastValueInternal! */ }
public void testIntegerAt() { Int64Array a = Int64Array.make(new long[] {0, 1, -2, 3}); AssertArrays.assertEquals(IntegerValue.make(0), a.integerAt(0)); AssertArrays.assertEquals(IntegerValue.make(1), a.integerAt(1)); AssertArrays.assertEquals(IntegerValue.make(-2), a.integerAt(2)); AssertArrays.assertEquals(IntegerValue.make(3), a.integerAt(3)); try { a.integerAt(-1); fail("-1"); } catch (IndexOutOfBoundsException e) { // expected } try { a.integerAt(4); fail("4"); } 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 testIndexOf() { int index = AssertArrays.makeIEEE64ArrayEmpty().indexOf(IEEE64Value.make(1.1), 0, 1); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array1().indexOf(IEEE64Value.make(1.1), 0, 1); assertEquals(0, index); index = AssertArrays.makeIEEE64Array1().indexOf(IEEE64Value.make(1.1), 0, 0); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array12345().indexOf(IEEE64Value.make(1.1), 0, 1); assertEquals(0, index); index = AssertArrays.makeIEEE64Array12345().indexOf(IEEE64Value.make(1.1), 0, 2); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array12345().indexOf(IEEE64Value.make(1.1), 1, 1); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array12345().indexOf(IEEE64Value.make(5.5), 0, 1); assertEquals(4, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), 0, 1); assertEquals(1, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), 0, 2); assertEquals(3, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(1.1), -1, -1); assertEquals(4, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -1, -1); assertEquals(3, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -1, 1); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -1, -2); assertEquals(1, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -1, -3); assertEquals(-1, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -3, -1); assertEquals(1, index); index = AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -1, 1); assertEquals(-1, index); try { AssertArrays.makeIEEE64Array12321().indexOf(IEEE64Value.make(2.2), -6, 1); fail(); } catch (IndexOutOfBoundsException e) { // expected } try { AssertArrays.makeIEEE64Array12321().indexOf(IntegerValue.make(2), -3, 1); fail(); } catch (ClassCastException e) { // expected } }
public void testStoreAll() { IEEE64Array array = IEEE64Array.make(0); array.storeAll(IEEE64Value.make(1.1)); AssertArrays.assertEquals(IEEE64Array.make(0), array, DIFF); array = IEEE64Array.make(1); array.storeAll(IEEE64Value.make(1.1)); AssertArrays.assertEquals(IEEE64Array.make(new double[] {1.1}), array, DIFF); array = IEEE64Array.make(3); array.storeAll(IEEE64Value.make(2.2)); AssertArrays.assertEquals(IEEE64Array.make(new double[] {2.2, 2.2, 2.2}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(IEEE64Value.make(9.9), 2, 1); AssertArrays.assertEquals( IEEE64Array.make(new double[] {1.1, 9.9, 9.9, 4.4, 5.5}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(null, 2, 1); AssertArrays.assertEquals( IEEE64Array.make(new double[] {1.1, 0.0, 0.0, 4.4, 5.5}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(IEEE64Value.make(9.9), -1, 1); AssertArrays.assertEquals( IEEE64Array.make(new double[] {1.1, 9.9, 9.9, 9.9, 9.9}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(IEEE64Value.make(9.9), 2); AssertArrays.assertEquals( IEEE64Array.make(new double[] {9.9, 9.9, 3.3, 4.4, 5.5}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(IEEE64Value.make(9.9), 0, 1); AssertArrays.assertEquals( IEEE64Array.make(new double[] {1.1, 2.2, 3.3, 4.4, 5.5}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); array.storeAll(IEEE64Value.make(9.9), 2, 1); AssertArrays.assertEquals( IEEE64Array.make(new double[] {1.1, 9.9, 9.9, 4.4, 5.5}), array, DIFF); array = AssertArrays.makeIEEE64Array12345(); try { array.storeAll(IEEE64Value.make(9.9), 6); fail(); } catch (IndexOutOfBoundsException e) { // expected } array = AssertArrays.makeIEEE64Array12345(); try { array.storeAll(IEEE64Value.make(9.9), 4, 2); fail(); } catch (IndexOutOfBoundsException e) { // expected } // Store incompatible type array = AssertArrays.makeIEEE64Array12345(); try { array.storeAll(IntegerValue.make(9), 1); fail(); } catch (ClassCastException e) { // expected } }
public void testStoreMany() { // empty Int64Array array = AssertArrays.makeInt64ArrayEmpty(); array.storeMany(0, AssertArrays.makeInt64ArrayEmpty()); AssertArrays.assertEquals(AssertArrays.makeInt64ArrayEmpty(), array); // simple array = AssertArrays.makeInt64Array12345(); array.storeMany(0, AssertArrays.makeInt64Array12321()); AssertArrays.assertEquals(AssertArrays.makeInt64Array12321(), array); array = AssertArrays.makeInt64Array12345(); array.storeMany(0, AssertArrays.makeInt64Array12321()); AssertArrays.assertEquals(AssertArrays.makeInt64Array12321(), array); array = AssertArrays.makeInt64Array12321(); array.storeMany(1, Int64Array.make(new long[] {8, 7, 6, 5, 4, 3, 3}), 2, 3); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 5, 4, 2, 1}), array); array = AssertArrays.makeInt64Array12321(); array.storeMany(1, Int64Array.make(new long[] {8, 7})); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 8, 7, 2, 1}), array); // Store incompatible type array = AssertArrays.makeInt64Array12321(); try { array.storeMany(1, IEEE64Array.make(new double[] {8.8, 7.7})); fail(); } catch (ClassCastException e) { // expected } // attempt to copy beyond this extent array = AssertArrays.makeInt64Array12345(); try { array.storeMany(1, AssertArrays.makeInt64Array12321()); fail(); } catch (IndexOutOfBoundsException e) { // expected } // insufficient source elements array = AssertArrays.makeInt64Array12345(); try { array.storeMany(0, AssertArrays.makeInt64Array12321(), 2, 4); fail(); } catch (IndexOutOfBoundsException e) { // expected } // Store integer values outside of spec array = AssertArrays.makeInt64Array12321(); try { array.storeMany( 1, IntegerVarArray.make( new IntegerValue[] {IntegerValue.make(Long.MAX_VALUE).plus(IntegerValue.one())})); fail("MAX_VALUE + 1"); } catch (IllegalArgumentException e) { // expected } }
public void testStoreAll() { Int64Array array = Int64Array.make(0); array.storeAll(IntegerValue.make(1)); AssertArrays.assertEquals(Int64Array.make(0), array); array = Int64Array.make(1); array.storeAll(IntegerValue.make(1)); AssertArrays.assertEquals(Int64Array.make(new long[] {1}), array); array = Int64Array.make(3); array.storeAll(IntegerValue.make(2)); AssertArrays.assertEquals(Int64Array.make(new long[] {2, 2, 2}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(IntegerValue.make(9), 2, 1); assertEquals(Int64Array.make(new long[] {1, 9, 9, 4, 5}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(null, 2, 1); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 0, 0, 4, 5}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(IntegerValue.make(9), -1, 1); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 9, 9, 9, 9}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(IntegerValue.make(9), 2); AssertArrays.assertEquals(Int64Array.make(new long[] {9, 9, 3, 4, 5}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(IntegerValue.make(9), 0, 1); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 2, 3, 4, 5}), array); array = AssertArrays.makeInt64Array12345(); array.storeAll(IntegerValue.make(9), 2, 1); AssertArrays.assertEquals(Int64Array.make(new long[] {1, 9, 9, 4, 5}), array); // Store outside of array bounds array = AssertArrays.makeInt64Array12345(); try { array.storeAll(IntegerValue.make(9), 6); fail(); } catch (IndexOutOfBoundsException e) { // expected } array = AssertArrays.makeInt64Array12345(); try { array.storeAll(IntegerValue.make(9), 4, 2); fail(); } catch (IndexOutOfBoundsException e) { // expected } // Store incompatible type array = AssertArrays.makeInt64Array12345(); try { array.storeAll(IEEE32Value.make(9.9f), 1); fail(); } catch (ClassCastException e) { // expected } // Store integer values outside of spec array = AssertArrays.makeInt64Array12345(); try { array.storeAll(IntegerValue.make(Long.MAX_VALUE).plus(IntegerValue.one()), 1); fail(); } catch (IllegalArgumentException 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 } }