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
,java.io.Serializable
final class ComparisonFailureWithFacts extends Platform.PlatformComparisonFailure implements ErrorWithFacts
AnAssertionError
(usually a JUnitComparisonFailure
, but not under GWT) composed of structuredFact
instances and other string messages.This class includes logic to format expected and actual values for easier reading.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
CONTEXT
(package private) com.google.common.collect.ImmutableList<Fact>
facts
private static int
WORTH_HIDING
-
Constructor Summary
Constructors Modifier Constructor Description private
ComparisonFailureWithFacts(com.google.common.collect.ImmutableList<java.lang.String> messages, com.google.common.collect.ImmutableList<Fact> facts, java.lang.String expected, java.lang.String actual, java.lang.Throwable cause)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static ComparisonFailureWithFacts
create(com.google.common.collect.ImmutableList<java.lang.String> messages, com.google.common.collect.ImmutableList<Fact> headFacts, com.google.common.collect.ImmutableList<Fact> tailFacts, java.lang.String expected, java.lang.String actual, java.lang.Throwable cause)
com.google.common.collect.ImmutableList<Fact>
facts()
(package private) static com.google.common.collect.ImmutableList<Fact>
formatExpectedAndActual(java.lang.String expected, java.lang.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, java.lang.String expected, java.lang.String actual)
private static com.google.common.collect.ImmutableList<Fact>
removeCommonPrefixAndSuffix(java.lang.String expected, java.lang.String actual)
private static boolean
validSurrogatePairAt(java.lang.CharSequence string, int index)
-
Methods inherited from class com.google.common.truth.Platform.PlatformComparisonFailure
toString
-
-
-
-
Field Detail
-
facts
final com.google.common.collect.ImmutableList<Fact> facts
-
CONTEXT
private static final int CONTEXT
- See Also:
- Constant Field Values
-
WORTH_HIDING
private static final int WORTH_HIDING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ComparisonFailureWithFacts
private ComparisonFailureWithFacts(com.google.common.collect.ImmutableList<java.lang.String> messages, com.google.common.collect.ImmutableList<Fact> facts, java.lang.String expected, java.lang.String actual, java.lang.Throwable cause)
-
-
Method Detail
-
create
static ComparisonFailureWithFacts create(com.google.common.collect.ImmutableList<java.lang.String> messages, com.google.common.collect.ImmutableList<Fact> headFacts, com.google.common.collect.ImmutableList<Fact> tailFacts, java.lang.String expected, java.lang.String actual, java.lang.Throwable cause)
-
facts
public com.google.common.collect.ImmutableList<Fact> facts()
- Specified by:
facts
in interfaceErrorWithFacts
-
makeFacts
private static com.google.common.collect.ImmutableList<Fact> makeFacts(com.google.common.collect.ImmutableList<Fact> headFacts, com.google.common.collect.ImmutableList<Fact> tailFacts, java.lang.String expected, java.lang.String actual)
-
formatExpectedAndActual
static com.google.common.collect.ImmutableList<Fact> formatExpectedAndActual(java.lang.String expected, java.lang.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
private static com.google.common.collect.ImmutableList<Fact> removeCommonPrefixAndSuffix(java.lang.String expected, java.lang.String actual)
-
validSurrogatePairAt
private static boolean validSurrogatePairAt(java.lang.CharSequence string, int index)
-
-