public class Strings extends Object
CharSequence
s.Constructor and Description |
---|
Strings(ComparisonStrategy comparisonStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
assertContains(AssertionInfo info,
CharSequence actual,
CharSequence... values)
Verifies that the given
CharSequence contains the given strings. |
void |
assertContainsIgnoringCase(AssertionInfo info,
CharSequence actual,
CharSequence sequence)
Verifies that the given
CharSequence contains the given sequence, ignoring case considerations. |
void |
assertContainsOnlyOnce(AssertionInfo info,
CharSequence actual,
CharSequence sequence)
Verifies that actual
CharSequence s contains only once the given sequence. |
void |
assertContainsSequence(AssertionInfo info,
CharSequence actual,
CharSequence[] values) |
void |
assertDoesNotContain(AssertionInfo info,
CharSequence actual,
CharSequence sequence)
Verifies that the given
CharSequence does not contain the given sequence. |
void |
assertDoesNotMatch(AssertionInfo info,
CharSequence actual,
CharSequence regex)
Verifies that the given
CharSequence does not match the given regular expression. |
void |
assertDoesNotMatch(AssertionInfo info,
CharSequence actual,
Pattern pattern)
Verifies that the given
CharSequence does not match the given regular expression. |
void |
assertEmpty(AssertionInfo info,
CharSequence actual)
Asserts that the given
CharSequence is empty. |
void |
assertEndsWith(AssertionInfo info,
CharSequence actual,
CharSequence suffix)
Verifies that the given
CharSequence ends with the given suffix. |
void |
assertEqualsIgnoringCase(AssertionInfo info,
CharSequence actual,
CharSequence expected)
Verifies that two
CharSequence s are equal, ignoring case considerations. |
void |
assertHasSameSizeAs(AssertionInfo info,
CharSequence actual,
Iterable<?> other)
Asserts that the number of entries in the given
CharSequence has the same size as the other
Iterable . |
void |
assertHasSameSizeAs(AssertionInfo info,
CharSequence actual,
Object[] other)
Asserts that the number of entries in the given
CharSequence has the same size as the other array. |
void |
assertHasSize(AssertionInfo info,
CharSequence actual,
int expectedSize)
Asserts that the size of the given
CharSequence is equal to the expected one. |
void |
assertMatches(AssertionInfo info,
CharSequence actual,
CharSequence regex)
Verifies that the given
CharSequence matches the given regular expression. |
void |
assertMatches(AssertionInfo info,
CharSequence actual,
Pattern pattern)
Verifies that the given
CharSequence matches the given regular expression. |
void |
assertNotEmpty(AssertionInfo info,
CharSequence actual)
Asserts that the given
CharSequence is not empty. |
void |
assertNullOrEmpty(AssertionInfo info,
CharSequence actual)
Asserts that the given
CharSequence is null or empty. |
void |
assertStartsWith(AssertionInfo info,
CharSequence actual,
CharSequence prefix)
Verifies that the given
CharSequence starts with the given prefix. |
Comparator<?> |
getComparator() |
static Strings |
instance()
Returns the singleton instance of this class based on
StandardComparisonStrategy . |
public Strings(ComparisonStrategy comparisonStrategy)
public static Strings instance()
StandardComparisonStrategy
.StandardComparisonStrategy
.public Comparator<?> getComparator()
public void assertNullOrEmpty(AssertionInfo info, CharSequence actual)
CharSequence
is null
or empty.info
- contains information about the assertion.actual
- the given CharSequence
.AssertionError
- if the given CharSequence
is not null
*and* it is not empty.public void assertEmpty(AssertionInfo info, CharSequence actual)
CharSequence
is empty.info
- contains information about the assertion.actual
- the given CharSequence
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the given CharSequence
is not empty.public void assertNotEmpty(AssertionInfo info, CharSequence actual)
CharSequence
is not empty.info
- contains information about the assertion.actual
- the given CharSequence
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the given CharSequence
is empty.public void assertHasSize(AssertionInfo info, CharSequence actual, int expectedSize)
CharSequence
is equal to the expected one.info
- contains information about the assertion.actual
- the given CharSequence
.expectedSize
- the expected size of actual
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the size of the given CharSequence
is different than the expected one.public void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Iterable<?> other)
CharSequence
has the same size as the other
Iterable
.info
- contains information about the assertion.actual
- the given CharSequence
.other
- the group to compareAssertionError
- if the given CharSequence
is null
.AssertionError
- if the given Iterable
is null
.AssertionError
- if the number of entries in the given CharSequence
does not have the same size.public void assertHasSameSizeAs(AssertionInfo info, CharSequence actual, Object[] other)
CharSequence
has the same size as the other array.info
- contains information about the assertion.actual
- the given CharSequence
.other
- the group to compareAssertionError
- if the given CharSequence
is null
.AssertionError
- if the given array is null
.AssertionError
- if the number of entries in the given CharSequence
does not have the same size.public void assertContains(AssertionInfo info, CharSequence actual, CharSequence... values)
CharSequence
contains the given strings.info
- contains information about the assertion.actual
- the actual CharSequence
.values
- the values to look for.NullPointerException
- if the given sequence is null
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contain the given sequence.public void assertContainsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence sequence)
CharSequence
contains the given sequence, ignoring case considerations.info
- contains information about the assertion.actual
- the actual CharSequence
.sequence
- the sequence to search for.NullPointerException
- if the given sequence is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contain the given sequence.public void assertDoesNotContain(AssertionInfo info, CharSequence actual, CharSequence sequence)
CharSequence
does not contain the given sequence.info
- contains information about the assertion.actual
- the actual CharSequence
.sequence
- the sequence to search for.NullPointerException
- if the given sequence is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
contains the given sequence.public void assertEqualsIgnoringCase(AssertionInfo info, CharSequence actual, CharSequence expected)
CharSequence
s are equal, ignoring case considerations.info
- contains information about the assertion.actual
- the actual CharSequence
.expected
- the expected CharSequence
.AssertionError
- if the given CharSequence
s are not equal.public void assertContainsOnlyOnce(AssertionInfo info, CharSequence actual, CharSequence sequence)
CharSequence
s contains only once the given sequence.info
- contains information about the assertion.actual
- the actual CharSequence
.sequence
- the given CharSequence
.NullPointerException
- if the given sequence is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contains only once the given
CharSequence
.public void assertStartsWith(AssertionInfo info, CharSequence actual, CharSequence prefix)
CharSequence
starts with the given prefix.info
- contains information about the assertion.actual
- the actual CharSequence
.prefix
- the given prefix.NullPointerException
- if the given sequence is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not start with the given prefix.public void assertEndsWith(AssertionInfo info, CharSequence actual, CharSequence suffix)
CharSequence
ends with the given suffix.info
- contains information about the assertion.actual
- the actual CharSequence
.suffix
- the given suffix.NullPointerException
- if the given sequence is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not end with the given suffix.public void assertMatches(AssertionInfo info, CharSequence actual, CharSequence regex)
CharSequence
matches the given regular expression.info
- contains information about the assertion.actual
- the given CharSequence
.regex
- the regular expression to which the actual CharSequence
is to be matched.NullPointerException
- if the given pattern is null
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
does not match the given regular expression.public void assertDoesNotMatch(AssertionInfo info, CharSequence actual, CharSequence regex)
CharSequence
does not match the given regular expression.info
- contains information about the assertion.actual
- the given CharSequence
.regex
- the regular expression to which the actual CharSequence
is to be matched.NullPointerException
- if the given pattern is null
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the actual CharSequence
matches the given regular expression.public void assertMatches(AssertionInfo info, CharSequence actual, Pattern pattern)
CharSequence
matches the given regular expression.info
- contains information about the assertion.actual
- the given CharSequence
.pattern
- the regular expression to which the actual CharSequence
is to be matched.NullPointerException
- if the given pattern is null
.AssertionError
- if the given CharSequence
is null
.AssertionError
- if the given CharSequence
does not match the given regular expression.public void assertDoesNotMatch(AssertionInfo info, CharSequence actual, Pattern pattern)
CharSequence
does not match the given regular expression.info
- contains information about the assertion.actual
- the given CharSequence
.pattern
- the regular expression to which the actual CharSequence
is to be matched.NullPointerException
- if the given pattern is null
.AssertionError
- if the given CharSequence
matches the given regular expression.public void assertContainsSequence(AssertionInfo info, CharSequence actual, CharSequence[] values)
Copyright © 2013 AssertJ. All Rights Reserved.