mirror of
https://bitbucket.org/Mattrixwv/javaclasses.git
synced 2025-12-07 07:23:57 -05:00
Added test for new string functions
This commit is contained in:
@@ -61,4 +61,25 @@ public class TestStopwatch{
|
|||||||
assertEquals("Minute resolution test failed", timer.getMinute(), (nano / 60000000000D), ALLOWANCE);
|
assertEquals("Minute resolution test failed", timer.getMinute(), (nano / 60000000000D), ALLOWANCE);
|
||||||
assertEquals("Hour resolution test failed", timer.getHour(), (nano / 3600000000000D), ALLOWANCE);
|
assertEquals("Hour resolution test failed", timer.getHour(), (nano / 3600000000000D), ALLOWANCE);
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testStringConversion(){
|
||||||
|
//Test nanoseconds
|
||||||
|
String results = Stopwatch.getStr(1.0);
|
||||||
|
assertEquals("1.000 nanoseconds", results);
|
||||||
|
//Test microseconds
|
||||||
|
results = Stopwatch.getStr(1.0e3);
|
||||||
|
assertEquals("1.000 microseconds", results);
|
||||||
|
//Test milliseconds
|
||||||
|
results = Stopwatch.getStr(1.0e6);
|
||||||
|
assertEquals("1.000 milliseconds", results);
|
||||||
|
//Test seconds
|
||||||
|
results = Stopwatch.getStr(1.0e9);
|
||||||
|
assertEquals("1.000 seconds", results);
|
||||||
|
//Test minutes
|
||||||
|
results = Stopwatch.getStr(1.0e12);
|
||||||
|
assertEquals("16.667 minutes", results);
|
||||||
|
//Test hours
|
||||||
|
results = Stopwatch.getStr(1.0e13);
|
||||||
|
assertEquals("2.778 hours", results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user