public class StringSubject extends ComparableSubject<StringSubject,String>
Modifier and Type | Class and Description |
---|---|
class |
StringSubject.CaseInsensitiveStringComparison
Case insensitive propositions for string subjects.
|
Modifier | Constructor and Description |
---|---|
protected |
StringSubject(FailureMetadata metadata,
String string)
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
void |
contains(CharSequence string)
Fails if the string does not contain the given sequence.
|
void |
containsMatch(Pattern regex)
Fails if the string does not contain a match on the given regex.
|
void |
containsMatch(String regex)
Fails if the string does not contain a match on the given regex.
|
void |
doesNotContain(CharSequence string)
Fails if the string contains the given sequence.
|
void |
doesNotContainMatch(Pattern regex)
Fails if the string contains a match on the given regex.
|
void |
doesNotContainMatch(String regex)
Fails if the string contains a match on the given regex.
|
void |
doesNotMatch(Pattern regex)
Fails if the string matches the given regex.
|
void |
doesNotMatch(String regex)
Fails if the string matches the given regex.
|
void |
endsWith(String string)
Fails if the string does not end with the given string.
|
void |
hasLength(int expectedLength)
Fails if the string does not have the given length.
|
StringSubject.CaseInsensitiveStringComparison |
ignoringCase()
Returns a
StringSubject -like instance that will ignore the case of the characters. |
void |
isEmpty()
Fails if the string is not equal to the zero-length "empty string."
|
void |
isEquivalentAccordingToCompareTo(String other)
Deprecated.
Use
Subject.isEqualTo(java.lang.Object) instead. String comparison is consistent with equality. |
void |
isNotEmpty()
Fails if the string is equal to the zero-length "empty string."
|
void |
matches(Pattern regex)
Fails if the string does not match the given regex.
|
void |
matches(String regex)
Fails if the string does not match the given regex.
|
void |
startsWith(String string)
Fails if the string does not start with the given string.
|
comparesEqualTo, isAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
actual, actualAsString, actualCustomStringRepresentation, check, check, equals, fail, fail, fail, failComparing, failComparing, failWithActual, failWithActual, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutActual, failWithoutSubject, failWithRawMessage, failWithRawMessageAndCause, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named, toString
protected StringSubject(FailureMetadata metadata, @NullableDecl String string)
Subject.check()
.that(actual)
.@Deprecated public final void isEquivalentAccordingToCompareTo(String other)
Subject.isEqualTo(java.lang.Object)
instead. String comparison is consistent with equality.ComparableSubject
other
according to Comparable.compareTo(T)
, (i.e., checks that a.comparesTo(b) == 0
).
Note: Do not use this method for checking object equality. Instead, use Subject.isEqualTo(Object)
.
isEquivalentAccordingToCompareTo
in class ComparableSubject<StringSubject,String>
public void hasLength(int expectedLength)
public void isEmpty()
public void isNotEmpty()
public void contains(CharSequence string)
public void doesNotContain(CharSequence string)
public void startsWith(String string)
public void endsWith(String string)
public void matches(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void matches(Pattern regex)
public void doesNotMatch(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void doesNotMatch(Pattern regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void containsMatch(Pattern regex)
public void containsMatch(String regex)
@GwtIncompatible(value="java.util.regex.Pattern") public void doesNotContainMatch(Pattern regex)
public void doesNotContainMatch(String regex)
public StringSubject.CaseInsensitiveStringComparison ignoringCase()
StringSubject
-like instance that will ignore the case of the characters.
Character equality ignoring case is defined as follows: Characters must be equal either
after calling Character.toLowerCase(char)
or after calling Character.toUpperCase(char)
.
Note that this is independent of any locale.
Copyright © 2018. All rights reserved.