Package com.google.common.truth
Class StringSubject
- java.lang.Object
-
- com.google.common.truth.Subject<S,T>
-
- com.google.common.truth.ComparableSubject<StringSubject,java.lang.String>
-
- com.google.common.truth.StringSubject
-
public class StringSubject extends ComparableSubject<StringSubject,java.lang.String>
Propositions for string subjects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.HasField
-
-
Field Summary
Fields Modifier and Type Field Description static SubjectFactory<StringSubject,java.lang.String>
STRING
Deprecated.Use afor each
style loop over yourIterable<Integer>
instead.-
Fields inherited from class com.google.common.truth.Subject
failureStrategy
-
-
Constructor Summary
Constructors Constructor Description StringSubject(FailureStrategy failureStrategy, java.lang.String string)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contains(java.lang.CharSequence string)
Fails if the string does not contain the given sequence.void
containsMatch(java.lang.String regex)
Fails if the string does not contain a match on the given regex.void
containsMatch(java.util.regex.Pattern pattern)
Fails if the string does not contain a match on the given regex.void
doesNotContain(java.lang.CharSequence string)
Fails if the string contains the given sequence.void
doesNotContainMatch(java.lang.String regex)
Fails if the string contains a match on the given regex.void
doesNotContainMatch(java.util.regex.Pattern pattern)
Fails if the string contains a match on the given regex.void
doesNotMatch(java.lang.String regex)
Fails if the string matches the given regex.void
doesNotMatch(java.util.regex.Pattern regex)
Fails if the string matches the given regex.void
endsWith(java.lang.String string)
Fails if the string does not end with the given string.protected java.lang.String
getDisplaySubject()
void
hasLength(int expectedLength)
Fails if the string does not have the given length.void
is(java.lang.Object expected)
void
isEmpty()
Fails if the string is not equal to the zero-length "empty string."void
isEqualTo(java.lang.Object expected)
Fails if the subject is not equal to the given object.void
isNotEmpty()
Fails if the string is equal to the zero-length "empty string."void
isNull()
Fails if the string is not null.void
matches(java.lang.String regex)
Fails if the string does not match the given regex.void
matches(java.util.regex.Pattern regex)
Fails if the string does not match the given regex.private static java.lang.String
quote(java.lang.CharSequence toBeWrapped)
void
startsWith(java.lang.String string)
Fails if the string does not start with the given string.-
Methods inherited from class com.google.common.truth.ComparableSubject
comparesEqualTo, isAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
-
Methods inherited from class com.google.common.truth.Subject
check, equals, fail, fail, fail, failWithBadResults, failWithCustomSubject, failWithoutSubject, failWithRawMessage, getSubject, hasField, hashCode, internalCustomName, isA, isInstanceOf, isNotA, isNotEqualTo, isNotInstanceOf, isNotNull, isNotSameAs, isSameAs, labeled, named
-
-
-
-
Field Detail
-
STRING
@Deprecated public static final SubjectFactory<StringSubject,java.lang.String> STRING
Deprecated.Use afor each
style loop over yourIterable<Integer>
instead.
-
-
Constructor Detail
-
StringSubject
public StringSubject(FailureStrategy failureStrategy, java.lang.String string)
-
-
Method Detail
-
getDisplaySubject
protected java.lang.String getDisplaySubject()
- Overrides:
getDisplaySubject
in classSubject<StringSubject,java.lang.String>
-
is
public void is(java.lang.Object expected)
- Overrides:
is
in classSubject<StringSubject,java.lang.String>
-
isEqualTo
public void isEqualTo(java.lang.Object expected)
Description copied from class:Subject
Fails if the subject is not equal to the given object.- Overrides:
isEqualTo
in classSubject<StringSubject,java.lang.String>
-
isNull
public void isNull()
Fails if the string is not null.- Overrides:
isNull
in classSubject<StringSubject,java.lang.String>
-
hasLength
public void hasLength(int expectedLength)
Fails if the string does not have the given length.
-
isEmpty
public void isEmpty()
Fails if the string is not equal to the zero-length "empty string."
-
isNotEmpty
public void isNotEmpty()
Fails if the string is equal to the zero-length "empty string."
-
contains
public void contains(java.lang.CharSequence string)
Fails if the string does not contain the given sequence.
-
doesNotContain
public void doesNotContain(java.lang.CharSequence string)
Fails if the string contains the given sequence.
-
startsWith
public void startsWith(java.lang.String string)
Fails if the string does not start with the given string.
-
endsWith
public void endsWith(java.lang.String string)
Fails if the string does not end with the given string.
-
matches
@GwtIncompatible("java.util.regex.Pattern") public void matches(java.lang.String regex)
Fails if the string does not match the given regex.
-
matches
@GwtIncompatible("java.util.regex.Pattern") public void matches(java.util.regex.Pattern regex)
Fails if the string does not match the given regex.
-
doesNotMatch
@GwtIncompatible("java.util.regex.Pattern") public void doesNotMatch(java.lang.String regex)
Fails if the string matches the given regex.
-
doesNotMatch
@GwtIncompatible("java.util.regex.Pattern") public void doesNotMatch(java.util.regex.Pattern regex)
Fails if the string matches the given regex.
-
containsMatch
@GwtIncompatible("java.util.regex.Pattern") public void containsMatch(java.util.regex.Pattern pattern)
Fails if the string does not contain a match on the given regex.
-
containsMatch
@GwtIncompatible("java.util.regex.Pattern") public void containsMatch(java.lang.String regex)
Fails if the string does not contain a match on the given regex.
-
doesNotContainMatch
@GwtIncompatible("java.util.regex.Pattern") public void doesNotContainMatch(java.util.regex.Pattern pattern)
Fails if the string contains a match on the given regex.
-
doesNotContainMatch
@GwtIncompatible("java.util.regex.Pattern") public void doesNotContainMatch(java.lang.String regex)
Fails if the string contains a match on the given regex.
-
quote
private static java.lang.String quote(java.lang.CharSequence toBeWrapped)
-
-