Package com.google.common.truth
Class StringSubject
java.lang.Object
com.google.common.truth.Subject<StringSubject,String>
com.google.common.truth.ComparableSubject<StringSubject,String>
com.google.common.truth.StringSubject
Propositions for string subjects.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.HasField
-
Field Summary
FieldsFields inherited from class com.google.common.truth.Subject
failureStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
contains
(CharSequence string) Fails if the string does not contain the given sequence.void
containsMatch
(String regex) Fails if the string does not contain a match on the given regex.void
containsMatch
(Pattern pattern) 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
(String regex) Fails if the string contains a match on the given regex.void
doesNotContainMatch
(Pattern pattern) Fails if the string contains a match on the given regex.void
doesNotMatch
(String regex) Fails if the string matches the given regex.void
doesNotMatch
(Pattern regex) Fails if the string matches the given regex.void
Fails if the string does not end with the given string.protected String
void
hasLength
(int expectedLength) Fails if the string does not have the given length.void
void
isEmpty()
Fails if the string is not equal to the zero-length "empty string."void
Fails if the subject is not equal to the given object.void
Fails if the string is equal to the zero-length "empty string."void
isNull()
Fails if the string is not null.void
Fails if the string does not match the given regex.void
Fails if the string does not match the given regex.private static String
quote
(CharSequence toBeWrapped) void
startsWith
(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 Details
-
STRING
Deprecated.Use afor each
style loop over yourIterable<Integer>
instead.
-
-
Constructor Details
-
StringSubject
-
-
Method Details
-
getDisplaySubject
- Overrides:
getDisplaySubject
in classSubject<StringSubject,
String>
-
is
- Overrides:
is
in classSubject<StringSubject,
String>
-
isEqualTo
Description copied from class:Subject
Fails if the subject is not equal to the given object.- Overrides:
isEqualTo
in classSubject<StringSubject,
String>
-
isNull
public void isNull()Fails if the string is not null.- Overrides:
isNull
in classSubject<StringSubject,
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
Fails if the string does not contain the given sequence. -
doesNotContain
Fails if the string contains the given sequence. -
startsWith
Fails if the string does not start with the given string. -
endsWith
Fails if the string does not end with the given string. -
matches
Fails if the string does not match the given regex. -
matches
Fails if the string does not match the given regex. -
doesNotMatch
Fails if the string matches the given regex. -
doesNotMatch
Fails if the string matches the given regex. -
containsMatch
Fails if the string does not contain a match on the given regex. -
containsMatch
Fails if the string does not contain a match on the given regex. -
doesNotContainMatch
Fails if the string contains a match on the given regex. -
doesNotContainMatch
Fails if the string contains a match on the given regex. -
quote
-
for each
style loop over yourIterable<Integer>
instead.