CompareTo Theory

Extending the CompareToTheory allows to test an implementation of the compareTo method.

All that has to be done is to define the data points to test.

@Category(ObjectBasics.class)
@Uut(type = Position.class)
public class PositionCompareToTest extends CompareToTheory<Position> {
  @DataPoint
  public static final Position POS_1_1 = new Position(1L, 1L);

  @DataPoint
  public static final Position POS_7_1 = new Position(7L, 1L);

  @DataPoint
  public static final Position POS_1_7 = new Position(1L, 7L);

  @DataPoint
  public static final Position POS_7_7 = new Position(7L, 7L);

  @DataPoint
  public static final Position POS_MAX_MAX = new Position(Long.MAX_VALUE, Long.MAX_VALUE);
}

We use JUnit's @Category annotation to tag the test case class as dealing with object basics. The category class and @Uut annotation are provided by smartics-testdoc-tools. Both annotations are not required for the theory to work and can be omitted.