@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_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(); }
@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(); }
@Test public void should_fail_if_actual_is_null() { thrown.expectAssertionError(actualIsNull()); arrays.assertStartsWith(someInfo(), null, array(8)); }
@Test public void should_throw_error_if_sequence_is_empty() { thrown.expectIllegalArgumentException(valuesToLookForIsEmpty()); arrays.assertStartsWith(someInfo(), actual, emptyArray()); }
@Test public void should_throw_error_if_sequence_is_null() { thrown.expectNullPointerException(valuesToLookForIsNull()); arrays.assertStartsWith(someInfo(), actual, null); }
@Test public void should_pass_if_actual_and_sequence_are_equal() { arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10, 12)); }
@Test public void should_pass_if_actual_starts_with_sequence() { arrays.assertStartsWith(someInfo(), actual, array(6, 8, 10)); }