/** Fails if the string contains the given sequence (while ignoring case). */ public void doesNotContain(CharSequence expectedSequence) { checkNotNull(expectedSequence); String expected = expectedSequence.toString(); if (actual() == null) { failWithoutActual( fact("expected a string that does not contain", expected), butWas(), simpleFact("(case is ignored)")); } else if (containsIgnoreCase(expected)) { failWithoutActual( fact("expected not to contain", expected), butWas(), simpleFact("(case is ignored)")); } }
/** Fails if the string does not contain the given sequence (while ignoring case). */ public void contains(CharSequence expectedSequence) { checkNotNull(expectedSequence); String expected = expectedSequence.toString(); if (actual() == null) { failWithoutActual( fact("expected a string that contains", expected), butWas(), simpleFact("(case is ignored)")); } else if (!containsIgnoreCase(expected)) { failWithoutActual( fact("expected to contain", expected), butWas(), simpleFact("(case is ignored)")); } }
/** * Fails if the subject is not equal to the given sequence (while ignoring case). For the * purposes of this comparison, two strings are equal if any of the following is true: * * <ul> * <li>they are equal according to {@link String#equalsIgnoreCase} * <li>they are both null * </ul> * * <p>Example: "abc" is equal to "ABC", but not to "abcd". */ public void isEqualTo(String expected) { if (actual() == null) { if (expected != null) { failWithoutActual( fact("expected a string that is equal to", expected), butWas(), simpleFact("(case is ignored)")); } } else { if (expected == null) { failWithoutActual( fact("expected", "null (null reference)"), butWas(), simpleFact("(case is ignored)")); } else if (!actual().equalsIgnoreCase(expected)) { failWithoutActual(fact("expected", expected), butWas(), simpleFact("(case is ignored)")); } } }
/** * Fails if the subject is equal to the given string (while ignoring case). The meaning of * equality is the same as for the {@link #isEqualTo} method. */ public void isNotEqualTo(String unexpected) { if (actual() == null) { if (unexpected == null) { failWithoutActual( fact("expected a string that is not equal to", "null (null reference)"), simpleFact("(case is ignored)")); } } else { if (unexpected != null && actual().equalsIgnoreCase(unexpected)) { failWithoutActual( fact("expected not to be", unexpected), butWas(), simpleFact("(case is ignored)")); } } }