예제 #1
0
  /** Tests the functionality for getEndTime */
  public void testGetEndTime() {
    StopWatch watch = new StopWatch();
    long endTime;

    try {
      Thread.sleep(10);
    } catch (InterruptedException e) {
    }

    // check if stop time is different from start
    watch.stop();
    endTime = watch.getEndTime();
    assertTrue(0 != endTime);

    // check if end time now is the same (we haven't started the timer agaiin
    assertEquals(endTime, watch.getEndTime());
  }
예제 #2
0
  /** Tests the functionality of getTimeDiff */
  public void testGetTimeDiff() {
    StopWatch watch = new StopWatch();
    long startTime;
    long endTime;

    startTime = watch.getStartTime();
    watch.stop();
    endTime = watch.getEndTime();
    assertEquals(endTime - startTime, watch.getTimeDiff());
  }