Index: src/test/java/ch/qos/logback/core/StopWatchTest.java =================================================================== --- src/test/java/ch/qos/logback/core/StopWatchTest.java (revision 1612) +++ src/test/java/ch/qos/logback/core/StopWatchTest.java (working copy) @@ -2,6 +2,8 @@ import junit.framework.TestCase; +import java.text.DecimalFormat; + public class StopWatchTest extends TestCase { public StopWatchTest(String name) { @@ -15,42 +17,44 @@ protected void tearDown() throws Exception { super.tearDown(); } - + public void testBasic() throws InterruptedException { StopWatch sw = new StopWatch("testBasic"); - - { + + { long d = sw.startTime+10; String s = sw.stop(d).toString(); assertTrue(s.endsWith("10 nanoseconds.")); } - - { + + { long d = sw.startTime+9*StopWatch.NANOS_IN_ONE_MICROSECOND; String s = sw.stop(d).toString(); assertTrue(s.endsWith("9000 nanoseconds.")); } - { + { long d = sw.startTime+11*StopWatch.NANOS_IN_ONE_MICROSECOND; String s = sw.stop(d).toString(); assertTrue(s.endsWith("11 microseconds.")); } - { + { long d = sw.startTime+9*StopWatch.NANOS_IN_ONE_MILLISECOND; String s = sw.stop(d).toString(); assertTrue(s.endsWith("9000 microseconds.")); } - { + { long d = sw.startTime+3*StopWatch.NANOS_IN_ONE_SECOND; String s = sw.stop(d).toString(); assertTrue(s.endsWith("3000 milliseconds.")); - } - { + } + { long d = sw.startTime+6*StopWatch.NANOS_IN_ONE_SECOND; String s = sw.stop(d).toString(); - assertTrue(s.endsWith("6.000 seconds.")); - } + DecimalFormat df = new DecimalFormat("0.000"); + String expected=df.format(6)+" seconds."; + assertTrue(s.endsWith(expected)); + } } public void testSelectDurationUnitForDisplay() throws InterruptedException { @@ -63,5 +67,5 @@ assertEquals(StopWatch.DurationUnit.MILLISSECOND, sw.selectDurationUnitForDisplay(3*StopWatch.NANOS_IN_ONE_SECOND)); assertEquals(StopWatch.DurationUnit.SECOND, sw.selectDurationUnitForDisplay(6*StopWatch.NANOS_IN_ONE_SECOND)); } - + }