### Question:
LineOffset implements Comparable { @Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; } LineOffset(int lineNum, int offset); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Object o); final int lineNum; final int offset; }### Answer:
@Test void testCompareToDifferentOffset() { LineOffset offsetOne = new LineOffset(1, 1); LineOffset offsetTwo = new LineOffset(1, 2); assertTrue(offsetOne.compareTo(offsetTwo) < 0); assertTrue(offsetTwo.compareTo(offsetOne) > 0); }
@Test void testCompareToDifferentLineNum() { LineOffset offsetOne = new LineOffset(1, 1); LineOffset offsetTwo = new LineOffset(2, 1); assertTrue(offsetOne.compareTo(offsetTwo) < 0); assertTrue(offsetTwo.compareTo(offsetOne) > 0); }
@Test void testCompareToSameOffset() { LineOffset offsetOne = new LineOffset(1, 1); LineOffset offsetTwo = new LineOffset(1, 1); assertTrue(offsetOne.compareTo(offsetTwo) == 0); }