Package org.fest.assertions.internal
Class Strings
java.lang.Object
org.fest.assertions.internal.Strings
Reusable assertions for
String
s.- Author:
- Alex Ruiz, Joel Costigliola, Nicolas François
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
assertContains
(AssertionInfo info, String actual, String sequence) Verifies that the givenString
contains the given sequence.void
assertContainsIgnoringCase
(AssertionInfo info, String actual, String sequence) Verifies that the givenString
contains the given sequence, ignoring case considerations.void
assertContainsOnlyOnce
(AssertionInfo info, String actual, String sequence) Verifies that actualString
s contains only once the given sequence.void
assertDoesNotContain
(AssertionInfo info, String actual, String sequence) Verifies that the givenString
does not contain the given sequence.void
assertDoesNotMatch
(AssertionInfo info, String actual, String regex) Verifies that the givenString
does not match the given regular expression.void
assertDoesNotMatch
(AssertionInfo info, String actual, Pattern pattern) Verifies that the givenString
does not match the given regular expression.void
assertEmpty
(AssertionInfo info, String actual) Asserts that the givenString
is empty.void
assertEndsWith
(AssertionInfo info, String actual, String suffix) Verifies that the givenString
ends with the given suffix.void
assertEqualsIgnoringCase
(AssertionInfo info, String actual, String expected) Verifies that twoString
s are equal, ignoring case considerations.void
assertHasSameSizeAs
(AssertionInfo info, String actual, Iterable<?> other) Asserts that the number of entries in the givenString
has the same size as the otherIterable
.void
assertHasSameSizeAs
(AssertionInfo info, String actual, Object[] other) Asserts that the number of entries in the givenString
has the same size as the other array.void
assertHasSize
(AssertionInfo info, String actual, int expectedSize) Asserts that the size of the givenString
is equal to the expected one.void
assertMatches
(AssertionInfo info, String actual, String regex) Verifies that the givenString
matches the given regular expression.void
assertMatches
(AssertionInfo info, String actual, Pattern pattern) Verifies that the givenString
matches the given regular expression.void
assertNotEmpty
(AssertionInfo info, String actual) Asserts that the givenString
is not empty.void
assertNullOrEmpty
(AssertionInfo info, String actual) Asserts that the givenString
isnull
or empty.void
assertStartsWith
(AssertionInfo info, String actual, String prefix) Verifies that the givenString
starts with the given prefix.Comparator<?>
static Strings
instance()
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 givenString
isnull
or empty.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.- Throws:
AssertionError
- if the givenString
is notnull
*and* it is not empty.
-
assertEmpty
Asserts that the givenString
is empty.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.- Throws:
AssertionError
- if the givenString
isnull
.AssertionError
- if the givenString
is not empty.
-
assertNotEmpty
Asserts that the givenString
is not empty.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.- Throws:
AssertionError
- if the givenString
isnull
.AssertionError
- if the givenString
is empty.
-
assertHasSize
Asserts that the size of the givenString
is equal to the expected one.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.expectedSize
- the expected size ofactual
.- Throws:
AssertionError
- if the givenString
isnull
.AssertionError
- if the size of the givenString
is different than the expected one.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenString
has 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 givenIterable
isnull
.AssertionError
- if the number of entries in the givenString
does not have the same size.
-
assertHasSameSizeAs
Asserts that the number of entries in the givenString
has 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 givenString
isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the number of entries in the givenString
does not have the same size.
-
assertContains
Verifies that the givenString
contains 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 givenString
isnull
.AssertionError
- if the actualString
does not contain the given sequence.
-
assertContainsIgnoringCase
Verifies that the givenString
contains 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 givenString
isnull
.AssertionError
- if the actualString
does not contain the given sequence.
-
assertDoesNotContain
Verifies that the givenString
does 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 givenString
isnull
.AssertionError
- if the actualString
contains the given sequence.
-
assertEqualsIgnoringCase
Verifies that twoString
s are equal, ignoring case considerations.- Parameters:
info
- contains information about the assertion.actual
- the actualString
.expected
- the expectedString
.- Throws:
AssertionError
- if the givenString
s are not equal.
-
assertContainsOnlyOnce
Verifies that actualString
s 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 givenString
isnull
.AssertionError
- if the actualString
does not contains only once the givenString
.
-
assertStartsWith
Verifies that the givenString
starts 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 givenString
isnull
.AssertionError
- if the actualString
does not start with the given prefix.
-
assertEndsWith
Verifies that the givenString
ends 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 givenString
isnull
.AssertionError
- if the actualString
does not end with the given suffix.
-
assertMatches
Verifies that the givenString
matches the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.regex
- the regular expression to which the actualString
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the givenString
isnull
.AssertionError
- if the actualString
does not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenString
does not match the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.regex
- the regular expression to which the actualString
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the actualString
matches the given regular expression.
-
assertMatches
Verifies that the givenString
matches the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.pattern
- the regular expression to which the actualString
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenString
isnull
.AssertionError
- if the givenString
does not match the given regular expression.
-
assertDoesNotMatch
Verifies that the givenString
does not match the given regular expression.- Parameters:
info
- contains information about the assertion.actual
- the givenString
.pattern
- the regular expression to which the actualString
is to be matched.- Throws:
NullPointerException
- if the given pattern isnull
.AssertionError
- if the givenString
matches the given regular expression.
-