@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 testAddMethod() { StopWatch s1 = new StopWatch(5, 59, 300); s1.add(2000); assertEquals(s1.toString(), "6:01:300"); s1 = new StopWatch(5, 59, 300); StopWatch s2 = new StopWatch(2, 2, 300); s1.add(s2); System.out.println(s1); assertEquals(s1.toString(), "8:01:600"); for (int i = 0; i < 15000; i++) s1.inc(); System.out.println(s1); assertEquals(s1.toString(), "8:16:600"); }