Class 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 Details

  • Constructor Details

    • ComparisonFailureWithFacts

      private ComparisonFailureWithFacts(com.google.common.collect.ImmutableList<String> messages, com.google.common.collect.ImmutableList<Fact> facts, String expected, String actual, Throwable cause)
  • Method Details

    • create

      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)
    • facts

      public com.google.common.collect.ImmutableList<Fact> facts()
      Specified by:
      facts in interface ErrorWithFacts
    • makeFacts

      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)
    • 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

      private static com.google.common.collect.ImmutableList<Fact> removeCommonPrefixAndSuffix(String expected, String actual)
    • validSurrogatePairAt

      private static boolean validSurrogatePairAt(CharSequence string, int index)