@Test public void should_pass_if_actual_is_empty_whatever_given_comparator_is() { arrays.assertIsSortedAccordingToComparator( someInfo(), emptyArray(), byteDescendingOrderComparator); arrays.assertIsSortedAccordingToComparator( someInfo(), emptyArray(), byteAscendingOrderComparator); }
@Test public void should_fail_if_actual_is_not_sorted_according_to_given_comparator() { AssertionInfo info = someInfo(); actual = new byte[] {3, 2, 1, 9}; try { arrays.assertIsSortedAccordingToComparator(info, actual, byteDescendingOrderComparator); } catch (AssertionError e) { verify(failures).failure(info, shouldBeSortedAccordingToGivenComparator(2, actual)); return; } failBecauseExpectedAssertionErrorWasNotThrown(); }
@Test public void should_fail_if_comparator_is_null() { thrown.expect(NullPointerException.class); arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null); }
@Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertIsSortedAccordingToComparator(someInfo(), null, byteDescendingOrderComparator); }
@Test public void should_pass_if_actual_is_sorted_according_to_given_comparator() { arrays.assertIsSortedAccordingToComparator(someInfo(), actual, byteDescendingOrderComparator); }