public class Strings
extends java.lang.Object
String
s.Constructor and Description |
---|
Strings(ComparisonStrategy comparisonStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
assertContains(AssertionInfo info,
java.lang.String actual,
java.lang.String sequence)
Verifies that the given
String contains the given sequence. |
void |
assertContainsIgnoringCase(AssertionInfo info,
java.lang.String actual,
java.lang.String sequence)
Verifies that the given
String contains the given sequence, ignoring case considerations. |
void |
assertContainsOnlyOnce(AssertionInfo info,
java.lang.String actual,
java.lang.String sequence)
Verifies that actual
String s contains only once the given sequence. |
void |
assertDoesNotContain(AssertionInfo info,
java.lang.String actual,
java.lang.String sequence)
Verifies that the given
String does not contain the given sequence. |
void |
assertDoesNotMatch(AssertionInfo info,
java.lang.String actual,
java.util.regex.Pattern pattern)
Verifies that the given
String does not match the given regular expression. |
void |
assertDoesNotMatch(AssertionInfo info,
java.lang.String actual,
java.lang.String regex)
Verifies that the given
String does not match the given regular expression. |
void |
assertEmpty(AssertionInfo info,
java.lang.String actual)
Asserts that the given
String is empty. |
void |
assertEndsWith(AssertionInfo info,
java.lang.String actual,
java.lang.String suffix)
Verifies that the given
String ends with the given suffix. |
void |
assertEqualsIgnoringCase(AssertionInfo info,
java.lang.String actual,
java.lang.String expected)
Verifies that two
String s are equal, ignoring case considerations. |
void |
assertHasSameSizeAs(AssertionInfo info,
java.lang.String actual,
java.lang.Iterable<?> other)
Asserts that the number of entries in the given
String has the same size as the other Iterable . |
void |
assertHasSameSizeAs(AssertionInfo info,
java.lang.String actual,
java.lang.Object[] other)
Asserts that the number of entries in the given
String has the same size as the other array. |
void |
assertHasSize(AssertionInfo info,
java.lang.String actual,
int expectedSize)
Asserts that the size of the given
String is equal to the expected one. |
void |
assertMatches(AssertionInfo info,
java.lang.String actual,
java.util.regex.Pattern pattern)
Verifies that the given
String matches the given regular expression. |
void |
assertMatches(AssertionInfo info,
java.lang.String actual,
java.lang.String regex)
Verifies that the given
String matches the given regular expression. |
void |
assertNotEmpty(AssertionInfo info,
java.lang.String actual)
Asserts that the given
String is not empty. |
void |
assertNullOrEmpty(AssertionInfo info,
java.lang.String actual)
Asserts that the given
String is null or empty. |
void |
assertStartsWith(AssertionInfo info,
java.lang.String actual,
java.lang.String prefix)
Verifies that the given
String starts with the given prefix. |
java.util.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 java.util.Comparator<?> getComparator()
public void assertNullOrEmpty(AssertionInfo info, java.lang.String actual)
String
is null
or empty.info
- contains information about the assertion.actual
- the given String
.java.lang.AssertionError
- if the given String
is not null
*and* it is not empty.public void assertEmpty(AssertionInfo info, java.lang.String actual)
String
is empty.info
- contains information about the assertion.actual
- the given String
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the given String
is not empty.public void assertNotEmpty(AssertionInfo info, java.lang.String actual)
String
is not empty.info
- contains information about the assertion.actual
- the given String
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the given String
is empty.public void assertHasSize(AssertionInfo info, java.lang.String actual, int expectedSize)
String
is equal to the expected one.info
- contains information about the assertion.actual
- the given String
.expectedSize
- the expected size of actual
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the size of the given String
is different than the expected one.public void assertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Iterable<?> other)
String
has the same size as the other Iterable
.info
- contains information about the assertion.actual
- the given String
.other
- the group to comparejava.lang.AssertionError
- if the given String
. is null
.java.lang.AssertionError
- if the given Iterable
is null
.java.lang.AssertionError
- if the number of entries in the given String
does not have the same size.public void assertHasSameSizeAs(AssertionInfo info, java.lang.String actual, java.lang.Object[] other)
String
has the same size as the other array.info
- contains information about the assertion.actual
- the given String
.other
- the group to comparejava.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the given array is null
.java.lang.AssertionError
- if the number of entries in the given String
does not have the same size.public void assertContains(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
String
contains the given sequence.info
- contains information about the assertion.actual
- the actual String
.sequence
- the sequence to search for.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not contain the given sequence.public void assertContainsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
String
contains the given sequence, ignoring case considerations.info
- contains information about the assertion.actual
- the actual String
.sequence
- the sequence to search for.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not contain the given sequence.public void assertDoesNotContain(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
String
does not contain the given sequence.info
- contains information about the assertion.actual
- the actual String
.sequence
- the sequence to search for.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
contains the given sequence.public void assertEqualsIgnoringCase(AssertionInfo info, java.lang.String actual, java.lang.String expected)
String
s are equal, ignoring case considerations.info
- contains information about the assertion.actual
- the actual String
.expected
- the expected String
.java.lang.AssertionError
- if the given String
s are not equal.public void assertContainsOnlyOnce(AssertionInfo info, java.lang.String actual, java.lang.String sequence)
String
s contains only once the given sequence.info
- contains information about the assertion.actual
- the actual String
.sequence
- the given String
.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not contains only once the given String
.public void assertStartsWith(AssertionInfo info, java.lang.String actual, java.lang.String prefix)
String
starts with the given prefix.info
- contains information about the assertion.actual
- the actual String
.prefix
- the given prefix.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not start with the given prefix.public void assertEndsWith(AssertionInfo info, java.lang.String actual, java.lang.String suffix)
String
ends with the given suffix.info
- contains information about the assertion.actual
- the actual String
.suffix
- the given suffix.java.lang.NullPointerException
- if the given sequence is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not end with the given suffix.public void assertMatches(AssertionInfo info, java.lang.String actual, java.lang.String regex)
String
matches the given regular expression.info
- contains information about the assertion.actual
- the given String
.regex
- the regular expression to which the actual String
is to be matched.java.lang.NullPointerException
- if the given pattern is null
.java.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalid.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the actual String
does not match the given regular expression.public void assertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.lang.String regex)
String
does not match the given regular expression.info
- contains information about the assertion.actual
- the given String
.regex
- the regular expression to which the actual String
is to be matched.java.lang.NullPointerException
- if the given pattern is null
.java.util.regex.PatternSyntaxException
- if the regular expression's syntax is invalid.java.lang.AssertionError
- if the actual String
matches the given regular expression.public void assertMatches(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)
String
matches the given regular expression.info
- contains information about the assertion.actual
- the given String
.pattern
- the regular expression to which the actual String
is to be matched.java.lang.NullPointerException
- if the given pattern is null
.java.lang.AssertionError
- if the given String
is null
.java.lang.AssertionError
- if the given String
does not match the given regular expression.public void assertDoesNotMatch(AssertionInfo info, java.lang.String actual, java.util.regex.Pattern pattern)
String
does not match the given regular expression.info
- contains information about the assertion.actual
- the given String
.pattern
- the regular expression to which the actual String
is to be matched.java.lang.NullPointerException
- if the given pattern is null
.java.lang.AssertionError
- if the given String
matches the given regular expression.Copyright © 2007–2018. All rights reserved.