Package org.fest.assertions.internal
Class Strings
java.lang.Object
org.fest.assertions.internal.Strings
Reusable assertions for
Strings.- Author:
- Alex Ruiz, Joel Costigliola, Nicolas François
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertContains(AssertionInfo info, String actual, String sequence) Verifies that the givenStringcontains the given sequence.voidassertContainsIgnoringCase(AssertionInfo info, String actual, String sequence) Verifies that the givenStringcontains the given sequence, ignoring case considerations.voidassertContainsOnlyOnce(AssertionInfo info, String actual, String sequence) Verifies that actualStrings contains only once the given sequence.voidassertDoesNotContain(AssertionInfo info, String actual, String sequence) Verifies that the givenStringdoes not contain the given sequence.voidassertDoesNotMatch(AssertionInfo info, String actual, String regex) Verifies that the givenStringdoes not match the given regular expression.voidassertDoesNotMatch(AssertionInfo info, String actual, Pattern pattern) Verifies that the givenStringdoes not match the given regular expression.voidassertEmpty(AssertionInfo info, String actual) Asserts that the givenStringis empty.voidassertEndsWith(AssertionInfo info, String actual, String suffix) Verifies that the givenStringends with the given suffix.voidassertEqualsIgnoringCase(AssertionInfo info, String actual, String expected) Verifies that twoStrings are equal, ignoring case considerations.voidassertHasSameSizeAs(AssertionInfo info, String actual, Iterable<?> other) Asserts that the number of entries in the givenStringhas the same size as the otherIterable.voidassertHasSameSizeAs(AssertionInfo info, String actual, Object[] other) Asserts that the number of entries in the givenStringhas the same size as the other array.voidassertHasSize(AssertionInfo info, String actual, int expectedSize) Asserts that the size of the givenStringis equal to the expected one.voidassertMatches(AssertionInfo info, String actual, String regex) Verifies that the givenStringmatches the given regular expression.voidassertMatches(AssertionInfo info, String actual, Pattern pattern) Verifies that the givenStringmatches the given regular expression.voidassertNotEmpty(AssertionInfo info, String actual) Asserts that the givenStringis not empty.voidassertNullOrEmpty(AssertionInfo info, String actual) Asserts that the givenStringisnullor empty.voidassertStartsWith(AssertionInfo info, String actual, String prefix) Verifies that the givenStringstarts with the given prefix.Comparator<?>static Stringsinstance()Returns the singleton instance of this class based onStandardComparisonStrategy.
-
Constructor Details
-
Strings
-
-
Method Details
-
instance
Returns the singleton instance of this class based onStandardComparisonStrategy.- Returns:
- the singleton instance of this class based on
StandardComparisonStrategy.
-
getComparator
-
assertNullOrEmpty
Asserts that the givenStringisnullor empty.- Parameters:
info- contains information about the assertion.actual- the givenString.- Throws:
AssertionError- if the givenStringis notnull*and* it is not empty.
-
assertEmpty
Asserts that the givenStringis empty.- Parameters:
info- contains information about the assertion.actual- the givenString.- Throws:
AssertionError- if the givenStringisnull.AssertionError- if the givenStringis not empty.
-
assertNotEmpty
Asserts that the givenStringis not empty.- Parameters:
info- contains information about the assertion.actual- the givenString.- Throws:
AssertionError- if the givenStringisnull.AssertionError- if the givenStringis empty.
-
assertHasSize
Asserts that the size of the givenStringis equal to the expected one.- Parameters:
info- contains information about the assertion.actual- the givenString.expectedSize- the expected size ofactual.- Throws:
AssertionError- if the givenStringisnull.AssertionError- if the size of the givenStringis different than the expected one.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenStringhas the same size as the otherIterable.- Parameters:
info- contains information about the assertion.actual- the givenString.other- the group to compare- Throws:
AssertionError- if the givenString. isnull.AssertionError- if the givenIterableisnull.AssertionError- if the number of entries in the givenStringdoes not have the same size.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenStringhas the same size as the other array.- Parameters:
info- contains information about the assertion.actual- the givenString.other- the group to compare- Throws:
AssertionError- if the givenStringisnull.AssertionError- if the given array isnull.AssertionError- if the number of entries in the givenStringdoes not have the same size.
-
assertContains
Verifies that the givenStringcontains the given sequence.- Parameters:
info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not contain the given sequence.
-
assertContainsIgnoringCase
Verifies that the givenStringcontains the given sequence, ignoring case considerations.- Parameters:
info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not contain the given sequence.
-
assertDoesNotContain
Verifies that the givenStringdoes not contain the given sequence.- Parameters:
info- contains information about the assertion.actual- the actualString.sequence- the sequence to search for.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringcontains the given sequence.
-
assertEqualsIgnoringCase
Verifies that twoStrings are equal, ignoring case considerations.- Parameters:
info- contains information about the assertion.actual- the actualString.expected- the expectedString.- Throws:
AssertionError- if the givenStrings are not equal.
-
assertContainsOnlyOnce
Verifies that actualStrings contains only once the given sequence.- Parameters:
info- contains information about the assertion.actual- the actualString.sequence- the givenString.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not contains only once the givenString.
-
assertStartsWith
Verifies that the givenStringstarts with the given prefix.- Parameters:
info- contains information about the assertion.actual- the actualString.prefix- the given prefix.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not start with the given prefix.
-
assertEndsWith
Verifies that the givenStringends with the given suffix.- Parameters:
info- contains information about the assertion.actual- the actualString.suffix- the given suffix.- Throws:
NullPointerException- if the given sequence isnull.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not end with the given suffix.
-
assertMatches
Verifies that the givenStringmatches the given regular expression.- Parameters:
info- contains information about the assertion.actual- the givenString.regex- the regular expression to which the actualStringis to be matched.- Throws:
NullPointerException- if the given pattern isnull.PatternSyntaxException- if the regular expression's syntax is invalid.AssertionError- if the givenStringisnull.AssertionError- if the actualStringdoes not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenStringdoes not match the given regular expression.- Parameters:
info- contains information about the assertion.actual- the givenString.regex- the regular expression to which the actualStringis to be matched.- Throws:
NullPointerException- if the given pattern isnull.PatternSyntaxException- if the regular expression's syntax is invalid.AssertionError- if the actualStringmatches the given regular expression.
-
assertMatches
Verifies that the givenStringmatches the given regular expression.- Parameters:
info- contains information about the assertion.actual- the givenString.pattern- the regular expression to which the actualStringis to be matched.- Throws:
NullPointerException- if the given pattern isnull.AssertionError- if the givenStringisnull.AssertionError- if the givenStringdoes not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenStringdoes not match the given regular expression.- Parameters:
info- contains information about the assertion.actual- the givenString.pattern- the regular expression to which the actualStringis to be matched.- Throws:
NullPointerException- if the given pattern isnull.AssertionError- if the givenStringmatches the given regular expression.
-