private static void testSortDescending(byte[] input, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); SignedBytes.sortDescending(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testSortDescending( byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); SignedBytes.sortDescending(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void assertCastFails(long value) { try { SignedBytes.checkedCast(value); fail("Cast to byte should have failed: " + value); } catch (IllegalArgumentException ex) { assertTrue( value + " not found in exception text: " + ex.getMessage(), ex.getMessage().contains(String.valueOf(value))); } }
public void testCompare() { for (byte x : VALUES) { for (byte y : VALUES) { // Only compare the sign of the result of compareTo(). int expected = Byte.valueOf(x).compareTo(y); int actual = SignedBytes.compare(x, y); if (expected == 0) { assertEquals(x + ", " + y, expected, actual); } else if (expected < 0) { assertTrue( x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual < 0); } else { assertTrue( x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual > 0); } } } }
private static void testSortDescending(byte[] input, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); SignedBytes.sortDescending(input); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void testSortDescending( byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) { input = Arrays.copyOf(input, input.length); SignedBytes.sortDescending(input, fromIndex, toIndex); assertTrue(Arrays.equals(expectedOutput, input)); }
private static void assertCastFails(long value) { try { SignedBytes.checkedCast(value); fail("Cast to byte should have failed: " + value); } catch (IllegalArgumentException ex) { assertTrue(value + " not found in exception text: " + ex.getMessage(), ex.getMessage().contains(String.valueOf(value))); } }
public void testCompare() { for (byte x : VALUES) { for (byte y : VALUES) { // Only compare the sign of the result of compareTo(). int expected = Byte.valueOf(x).compareTo(y); int actual = SignedBytes.compare(x, y); if (expected == 0) { assertEquals(x + ", " + y, expected, actual); } else if (expected < 0) { assertTrue(x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual < 0); } else { assertTrue(x + ", " + y + " (expected: " + expected + ", actual" + actual + ")", actual > 0); } } } }