@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_contains_given_values() {
   AssertionInfo info = someInfo();
   byte[] expected = {6, 8, 20};
   try {
     arrays.assertDoesNotContain(info, actual, expected);
   } catch (AssertionError e) {
     verify(failures).failure(info, shouldNotContain(actual, expected, set((byte) 6, (byte) 8)));
     return;
   }
   throw expectedAssertionErrorNotThrown();
 }
コード例 #3
0
 @Test
 public void should_fail_if_actual_starts_with_first_elements_of_sequence_only() {
   AssertionInfo info = someInfo();
   byte[] sequence = {6, 20};
   try {
     arrays.assertStartsWith(info, actual, sequence);
   } catch (AssertionError e) {
     verifyFailureThrownWhenSequenceNotFound(info, sequence);
     return;
   }
   throw expectedAssertionErrorNotThrown();
 }
 @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();
 }
コード例 #5
0
 @Test
 public void should_fail_if_sequence_is_bigger_than_actual() {
   AssertionInfo info = someInfo();
   byte[] sequence = {6, 8, 10, 12, 20, 22};
   try {
     arrays.assertStartsWith(info, actual, sequence);
   } catch (AssertionError e) {
     verifyFailureThrownWhenSequenceNotFound(info, sequence);
     return;
   }
   throw expectedAssertionErrorNotThrown();
 }
コード例 #6
0
 @Test
 public void should_fail_if_actual_does_not_start_with_sequence() {
   AssertionInfo info = someInfo();
   byte[] sequence = {8, 10};
   try {
     arrays.assertStartsWith(info, actual, sequence);
   } catch (AssertionError e) {
     verifyFailureThrownWhenSequenceNotFound(info, sequence);
     return;
   }
   throw expectedAssertionErrorNotThrown();
 }
 @Before
 public void setUp() {
   failures = spy(new Failures());
   actual = new byte[] {4, 3, 2, 2, 1};
   arrays = new ByteArrays();
   arrays.failures = failures;
   byteDescendingOrderComparator =
       new Comparator<Byte>() {
         public int compare(Byte byte1, Byte byte2) {
           return -byte1.compareTo(byte2);
         }
       };
   byteAscendingOrderComparator =
       new Comparator<Byte>() {
         public int compare(Byte byte1, Byte byte2) {
           return byte1.compareTo(byte2);
         }
       };
 }
コード例 #8
0
 @Test
 public void should_fail_if_actual_is_null() {
   thrown.expectAssertionError(actualIsNull());
   arrays.assertStartsWith(someInfo(), null, array(8));
 }
コード例 #9
0
 @Test
 public void should_throw_error_if_sequence_is_empty() {
   thrown.expectIllegalArgumentException(valuesToLookForIsEmpty());
   arrays.assertStartsWith(someInfo(), actual, emptyArray());
 }
コード例 #10
0
 @Test
 public void should_throw_error_if_sequence_is_null() {
   thrown.expectNullPointerException(valuesToLookForIsNull());
   arrays.assertStartsWith(someInfo(), actual, null);
 }
コード例 #11
0
 @Before
 public void setUp() {
   failures = spy(new Failures());
   arrays = new ByteArrays();
   arrays.failures = failures;
 }
コード例 #12
0
 @Test
 public void should_pass_if_actual_and_sequence_are_equal() {
   arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10, 12));
 }
 @Test
 public void should_fail_if_comparator_is_null() {
   thrown.expect(NullPointerException.class);
   arrays.assertIsSortedAccordingToComparator(someInfo(), emptyArray(), null);
 }
 @Test
 public void should_pass_if_actual_is_sorted_according_to_given_comparator() {
   arrays.assertIsSortedAccordingToComparator(someInfo(), actual, byteDescendingOrderComparator);
 }
 @Test
 public void should_fail_if_actual_is_null() {
   thrown.expectAssertionError(actualIsNull());
   arrays.assertDoesNotContain(someInfo(), null, array(8));
 }
 @Test
 public void should_throw_error_if_array_of_values_to_look_for_is_null() {
   thrown.expectNullPointerException(valuesToLookForIsNull());
   arrays.assertDoesNotContain(someInfo(), actual, null);
 }
 @Test
 public void should_throw_error_if_array_of_values_to_look_for_is_empty() {
   thrown.expectIllegalArgumentException(valuesToLookForIsEmpty());
   arrays.assertDoesNotContain(someInfo(), actual, emptyArray());
 }
 @Test
 public void should_pass_if_actual_does_not_contain_given_values_even_if_duplicated() {
   arrays.assertDoesNotContain(someInfo(), actual, array(12, 12, 20));
 }
コード例 #19
0
 @Test
 public void should_pass_if_actual_starts_with_sequence() {
   arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10));
 }
 @Test
 public void should_fail_if_actual_is_null() {
   thrown.expectAssertionError(actualIsNull());
   arrays.assertIsSortedAccordingToComparator(someInfo(), null, byteDescendingOrderComparator);
 }