@Test public void testCompareTo() { StopWatch s1 = new StopWatch(5, 59, 300); StopWatch s2 = new StopWatch(6, 01, 200); StopWatch s3 = new StopWatch(5, 50, 200); StopWatch s4 = new StopWatch(5, 59, 300); assertFalse(s1.equals(s2)); assertTrue(s1.equals(s4)); assertTrue(s2.compareTo(s1) > 0); assertTrue(s3.compareTo(s1) < 0); assertTrue(s1.compareTo(s4) == 0); }
@Test public void testMutate() { StopWatch s1 = new StopWatch(5, 59, 300); StopWatch s2 = new StopWatch(5, 59, 300); StopWatch.setMutate(false); s1.add(1000); s1.setMilliseconds(100); s1.setSeconds(50); s1.setMinutes(2); s1.add(s2); assertTrue(s1.equals(s2)); }
@Test public void testEqual2() { StopWatch s1 = new StopWatch(5, 59, 300); StopWatch s2 = new StopWatch(6, 01, 200); StopWatch s3 = new StopWatch(5, 50, 200); StopWatch s4 = new StopWatch(5, 59, 300); assertFalse(StopWatch.equals(s1, s2)); assertFalse(StopWatch.equals(s1, s3)); assertTrue(StopWatch.equals(s1, s4)); assertFalse(StopWatch.equals(s2, s3)); assertFalse(StopWatch.equals(s2, s4)); assertFalse(StopWatch.equals(s3, s4)); }