View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.util;
5   
6   import static org.junit.Assert.assertEquals;
7   
8   import java.util.Collection;
9   
10  import net.sourceforge.pmd.ReadableDurationTest;
11  import net.sourceforge.pmd.util.DateTimeUtil;
12  
13  import org.junit.Test;
14  
15  
16  /**
17   * 
18   * @author Brian Remedios
19   */
20  public class DateTimeUtilTest {
21  
22      @Test
23      public void testConversions() {
24      	
25      	Collection<Object[]> stringNumberPairs = ReadableDurationTest.data();
26      	
27      	for (Object[] stringAndNumber : stringNumberPairs) {
28      		String result = (String)stringAndNumber[0];
29      		Integer milliseconds = (Integer)stringAndNumber[1];
30      		
31      		assertEquals(result, DateTimeUtil.asHoursMinutesSeconds(milliseconds));
32      	}
33        
34      }
35  
36  
37      public static junit.framework.Test suite() {
38          return new junit.framework.JUnit4TestAdapter(DateTimeUtilTest.class);
39      }
40  }
41