01: package test.net.sourceforge.pmd;
02:
03: import static org.junit.Assert.assertEquals;
04: import net.sourceforge.pmd.Report;
05:
06: import org.junit.Test;
07: import org.junit.runner.RunWith;
08: import org.junit.runners.Parameterized;
09: import org.junit.runners.Parameterized.Parameters;
10:
11: import java.util.Arrays;
12: import java.util.Collection;
13:
14: import junit.framework.JUnit4TestAdapter;
15:
16: @RunWith(Parameterized.class)
17: public class ReadableDurationTest {
18:
19: private Integer value;
20: private String expected;
21:
22: public ReadableDurationTest(String expected, Integer value) {
23: this .value = value;
24: this .expected = expected;
25: }
26:
27: @Parameters
28: public static Collection data() {
29: return Arrays.asList(new Object[][] { { "0s", 35 },
30: { "25s", (25 * 1000) }, { "5m 0s", (60 * 1000 * 5) },
31: { "2h 0m 0s", (60 * 1000 * 120) } });
32: }
33:
34: @Test
35: public void test() {
36: assertEquals(expected, new Report.ReadableDuration(value)
37: .getTime());
38: }
39:
40: public static junit.framework.Test suite() {
41: return new JUnit4TestAdapter(ReadableDurationTest.class);
42: }
43: }
|