private int indexOf(String string, CharSequence toFind) { for (int i = 0; i < string.length(); i++) { if (comparisonStrategy.stringStartsWith(string.substring(i), toFind.toString())) return i; } return -1; }
private int indexOf(String string, CharSequence toFind) { for (int i = 0; i < string.length(); i++) { if (comparisonStrategy.stringStartsWith(string.substring(i), toFind.toString())) return i; } return -1; }
/** * Verifies that the given {@code CharSequence} does not start with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} starts with the given prefix. */ public void assertDoesNotStartWith(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); if (comparisonStrategy.stringStartsWith(actual.toString(), prefix.toString())) throw failures.failure(info, shouldNotStartWith(actual, prefix, comparisonStrategy)); }
/** * Verifies that the given {@code CharSequence} starts with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} does not start with the given prefix. */ public void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); if (!comparisonStrategy.stringStartsWith(actual.toString(), prefix.toString())) throw failures.failure(info, shouldStartWith(actual, prefix, comparisonStrategy)); }
/** * Verifies that the given {@code CharSequence} does not start with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} starts with the given prefix. */ public void assertDoesNotStartWith(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); if (comparisonStrategy.stringStartsWith(actual.toString(), prefix.toString())) throw failures.failure(info, shouldNotStartWith(actual, prefix, comparisonStrategy)); }
/** * Verifies that the given {@code CharSequence} starts with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} does not start with the given prefix. */ public void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequence prefix) { failIfPrefixIsNull(prefix); assertNotNull(info, actual); if (!comparisonStrategy.stringStartsWith(actual.toString(), prefix.toString())) throw failures.failure(info, shouldStartWith(actual, prefix, comparisonStrategy)); }
/** * Verifies that the given {@code CharSequence} starts with the given prefix. * * @param info contains information about the assertion. * @param actual the actual {@code CharSequence}. * @param prefix the given prefix. * @throws NullPointerException if the given sequence is {@code null}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the actual {@code CharSequence} does not start with the given prefix. */ public void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequence prefix) { if (prefix == null) { throw new NullPointerException("The given prefix should not be null"); } assertNotNull(info, actual); if (comparisonStrategy.stringStartsWith(actual.toString(), prefix.toString())) { return; } throw failures.failure(info, shouldStartWith(actual, prefix, comparisonStrategy)); }