public void testExplicit_one() { Comparator<Integer> c = Ordering.explicit(0); assertEquals(0, c.compare(0, 0)); try { c.compare(0, 1); fail(); } catch (IncomparableValueException expected) { assertEquals(1, expected.value); } reserializeAndAssert(c); assertEquals("Ordering.explicit([0])", c.toString()); }
public void testOnResultOf_natural() { Comparator<String> comparator = Ordering.natural().onResultOf(StringLengthFunction.StringLength); assertTrue(comparator.compare("to", "be") == 0); assertTrue(comparator.compare("or", "not") < 0); assertTrue(comparator.compare("that", "to") > 0); new EqualsTester() .addEqualityGroup( comparator, Ordering.natural().onResultOf(StringLengthFunction.StringLength)) .addEqualityGroup(DECREASING_INTEGER) .testEquals(); reserializeAndAssert(comparator); assertEquals("Ordering.natural().onResultOf(StringLength)", comparator.toString()); }
/** * String representation of this file comparator. * * @return String representation of this file comparator */ @Override public String toString() { return super.toString() + "[" + delegate.toString() + "]"; }
public String toString() { return a.toString(); }
/** @see java.lang.Object#toString() */ @Override public String toString() { return String.format("Inverse of %1$s", comp.toString()); }