Pair { @Override public String toString() { return "(" + (left == null ? "NULL" : left.toString()) + ", " + (right == null ? "NULL" : right.toString()) + ")"; } Pair(T left, U right); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); public T left; public U right; }
@Test public void toString_NullWhenLeftIsNull() { Pair<Command, Integer> pair = new Pair<Command, Integer>(null, 0); assertEquals("(NULL, 0)", pair.toString()); }
@Test public void toString_NullWhenRightIsNull() { Pair<Command, Integer> pair = new Pair<Command, Integer>(Command.HasData, null); assertEquals("(HasData, NULL)", pair.toString()); }
@Test public void toString_NullWhenBothLeftAndRightAreNulls() { Pair<Command, Integer> pair = new Pair<Command, Integer>(null, null); assertEquals("(NULL, NULL)", pair.toString()); }