Package com.google.common.truth
Class ComparisonFailureWithFacts
java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.AssertionError
com.google.common.truth.Platform.PlatformComparisonFailure
com.google.common.truth.ComparisonFailureWithFacts
- All Implemented Interfaces:
ErrorWithFacts
,Serializable
final class ComparisonFailureWithFacts
extends Platform.PlatformComparisonFailure
implements ErrorWithFacts
An
AssertionError
(usually a JUnit ComparisonFailure
, but not under GWT) composed
of structured Fact
instances and other string messages.
This class includes logic to format expected and actual values for easier reading.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
(package private) final com.google.common.collect.ImmutableList
<Fact> private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static ComparisonFailureWithFacts
create
(com.google.common.collect.ImmutableList<String> messages, com.google.common.collect.ImmutableList<Fact> headFacts, com.google.common.collect.ImmutableList<Fact> tailFacts, String expected, String actual, Throwable cause) com.google.common.collect.ImmutableList
<Fact> facts()
(package private) static com.google.common.collect.ImmutableList
<Fact> formatExpectedAndActual
(String expected, String actual) Returns one or more facts describing the difference between the given expected and actual values.private static com.google.common.collect.ImmutableList
<Fact> makeFacts
(com.google.common.collect.ImmutableList<Fact> headFacts, com.google.common.collect.ImmutableList<Fact> tailFacts, String expected, String actual) private static com.google.common.collect.ImmutableList
<Fact> removeCommonPrefixAndSuffix
(String expected, String actual) private static boolean
validSurrogatePairAt
(CharSequence string, int index) Methods inherited from class com.google.common.truth.Platform.PlatformComparisonFailure
toString
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
facts
-
CONTEXT
private static final int CONTEXT- See Also:
-
WORTH_HIDING
private static final int WORTH_HIDING- See Also:
-
-
Constructor Details
-
ComparisonFailureWithFacts
-
-
Method Details
-
create
-
facts
- Specified by:
facts
in interfaceErrorWithFacts
-
makeFacts
-
formatExpectedAndActual
static com.google.common.collect.ImmutableList<Fact> formatExpectedAndActual(String expected, String actual) Returns one or more facts describing the difference between the given expected and actual values.Currently, that means either 2 facts (one each for expected and actual) or 1 fact with a diff-like (but much simpler) view.
In the case of 2 facts, the facts contain either the full expected and actual values or, if the values have a long prefix or suffix in common, abbreviated values with "…" at the beginning or end.
-
removeCommonPrefixAndSuffix
-
validSurrogatePairAt
-