@Test public void testIsZeroOrNull() { Assert.assertTrue(IntArrayComparator.isZeroOrNull(null)); Assert.assertTrue(IntArrayComparator.isZeroOrNull(ArrayConstants.ZERO_LENGTH_INT_ARRAY)); Assert.assertTrue(IntArrayComparator.isZeroOrNull(this.zero)); Assert.assertFalse(IntArrayComparator.isZeroOrNull(this.base)); }
@Test public void testIsEqual() { Assert.assertFalse(IntArrayComparator.isEqual(null, this.base)); Assert.assertFalse(IntArrayComparator.isEqual(this.lessThanBase, this.base)); Assert.assertFalse(IntArrayComparator.isEqual(ArrayConstants.ZERO_LENGTH_INT_ARRAY, this.base)); Assert.assertFalse(IntArrayComparator.isEqual(this.base, null)); Assert.assertFalse(IntArrayComparator.isEqual(this.base, this.lessThanBase)); Assert.assertFalse(IntArrayComparator.isEqual(this.base, ArrayConstants.ZERO_LENGTH_INT_ARRAY)); Assert.assertTrue(IntArrayComparator.isEqual(this.base, this.equalToBaseButNotSame)); Assert.assertTrue(IntArrayComparator.isEqual(null, null)); Assert.assertTrue(IntArrayComparator.isEqual(this.base, this.equalToBaseButNotSame)); }
@Test public void testComplementProblem() { final int[] twoComplementProblemLesser = new int[this.base.length]; final int[] twoComplementProblemGreater = new int[this.base.length]; System.arraycopy(this.base, 0, twoComplementProblemLesser, 0, this.base.length); System.arraycopy(this.base, 0, twoComplementProblemGreater, 0, this.base.length); twoComplementProblemLesser[1] = 100; twoComplementProblemGreater[1] = -100; Assert.assertTrue( IntArrayComparator.isLessThan(twoComplementProblemLesser, twoComplementProblemGreater)); }
@Test public void testCompareArrays() { Assert.assertEquals(0, IntArrayComparator.compareArrays(this.base, this.equalToBaseButNotSame)); Assert.assertEquals(0, IntArrayComparator.compareArrays(null, null)); Assert.assertEquals(0, IntArrayComparator.compareArrays(this.base, this.equalToBaseButNotSame)); Assert.assertEquals(1, IntArrayComparator.compareArrays(this.base, null)); Assert.assertEquals(1, IntArrayComparator.compareArrays(this.base, this.lessThanBase)); Assert.assertEquals( 1, IntArrayComparator.compareArrays(this.base, ArrayConstants.ZERO_LENGTH_INT_ARRAY)); Assert.assertEquals(-1, IntArrayComparator.compareArrays(null, this.base)); Assert.assertEquals(-1, IntArrayComparator.compareArrays(this.lessThanBase, this.base)); Assert.assertEquals( -1, IntArrayComparator.compareArrays(ArrayConstants.ZERO_LENGTH_INT_ARRAY, this.base)); // single element compare Assert.assertEquals(0, IntArrayComparator.compareArrays(new int[] {10}, new int[] {10})); Assert.assertEquals(1, IntArrayComparator.compareArrays(new int[] {10}, new int[] {8})); Assert.assertEquals(-1, IntArrayComparator.compareArrays(new int[] {8}, new int[] {10})); }