Package com.google.common.truth
Class StringUtil
java.lang.Object
com.google.common.truth.StringUtil
Utilities for string comparisons.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static String
Substitutes each%s
intemplate
with an argument.(package private) static String
messageFor
(String message, CharSequence expected, CharSequence actual) Returns a message appropriate for string comparisons.
-
Constructor Details
-
StringUtil
private StringUtil()
-
-
Method Details
-
messageFor
Returns a message appropriate for string comparisons. TODO(user): Do something closer to what JUnit'sComparisonFailure
does. -
format
Substitutes each%s
intemplate
with an argument. These are matched by position - the first%s
getsargs[0]
, etc. If there are more arguments than placeholders, the unmatched arguments will be appended to the end of the formatted message in square braces. Cribbed from Guava'sPreconditions
to allow for a GWT-compatible alternative toString.format(String, Object...)
- Parameters:
template
- a non-null string containing 0 or more%s
placeholders.args
- the arguments to be substituted into the message template. Arguments are converted to strings usingString.valueOf(Object)
. Arguments can be null.- See Also:
-
Preconditions
-