View Javadoc

1   /*
2    *  Copyright 2001-2005 Stephen Colebourne
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.joda.time;
17  
18  import junit.framework.TestCase;
19  import junit.framework.TestSuite;
20  
21  /**
22   * Test case.
23   *
24   * @author Stephen Colebourne
25   */
26  public class TestDateTimeConstants extends TestCase {
27  
28      /**
29       * The main method for this test program.
30       * @param args command line arguments.
31       */
32      public static void main(String[] args) {
33          junit.textui.TestRunner.run(suite());
34      }
35  
36      /**
37       * TestSuite is a junit required method.
38       */
39      public static TestSuite suite() {
40          return new TestSuite(TestDateTimeConstants.class);
41      }
42  
43      /**
44       * TestDateTimeComparator constructor.
45       * @param name
46       */
47      public TestDateTimeConstants(String name) {
48          super(name);
49      }
50  
51      //-----------------------------------------------------------------------
52      public void testConstructor() {
53          DateTimeConstants c = new DateTimeConstants() {
54          };
55          c.toString();
56      }
57  
58      public void testHalfdaysOfDay() {
59          assertEquals(0, DateTimeConstants.AM);
60          assertEquals(1, DateTimeConstants.PM);
61      }
62  
63      public void testDaysOfWeek() {
64          assertEquals(1, DateTimeConstants.MONDAY);
65          assertEquals(2, DateTimeConstants.TUESDAY);
66          assertEquals(3, DateTimeConstants.WEDNESDAY);
67          assertEquals(4, DateTimeConstants.THURSDAY);
68          assertEquals(5, DateTimeConstants.FRIDAY);
69          assertEquals(6, DateTimeConstants.SATURDAY);
70          assertEquals(7, DateTimeConstants.SUNDAY);
71      }
72  
73      public void testMonthsOfYear() {
74          assertEquals(1, DateTimeConstants.JANUARY);
75          assertEquals(2, DateTimeConstants.FEBRUARY);
76          assertEquals(3, DateTimeConstants.MARCH);
77          assertEquals(4, DateTimeConstants.APRIL);
78          assertEquals(5, DateTimeConstants.MAY);
79          assertEquals(6, DateTimeConstants.JUNE);
80          assertEquals(7, DateTimeConstants.JULY);
81          assertEquals(8, DateTimeConstants.AUGUST);
82          assertEquals(9, DateTimeConstants.SEPTEMBER);
83          assertEquals(10, DateTimeConstants.OCTOBER);
84          assertEquals(11, DateTimeConstants.NOVEMBER);
85          assertEquals(12, DateTimeConstants.DECEMBER);
86      }
87  
88      public void testEras() {
89          assertEquals(0, DateTimeConstants.BC);
90          assertEquals(0, DateTimeConstants.BCE);
91          assertEquals(1, DateTimeConstants.AD);
92          assertEquals(1, DateTimeConstants.CE);
93      }
94  
95      public void testMaths() {
96          assertEquals(1000, DateTimeConstants.MILLIS_PER_SECOND);
97          assertEquals(60 * 1000, DateTimeConstants.MILLIS_PER_MINUTE);
98          assertEquals(60 * 60 * 1000, DateTimeConstants.MILLIS_PER_HOUR);
99          assertEquals(24 * 60 * 60 * 1000, DateTimeConstants.MILLIS_PER_DAY);
100         assertEquals(7 * 24 * 60 * 60 * 1000, DateTimeConstants.MILLIS_PER_WEEK);
101         
102         assertEquals(60, DateTimeConstants.SECONDS_PER_MINUTE);
103         assertEquals(60 * 60, DateTimeConstants.SECONDS_PER_HOUR);
104         assertEquals(24 * 60 * 60, DateTimeConstants.SECONDS_PER_DAY);
105         assertEquals(7 * 24 * 60 * 60, DateTimeConstants.SECONDS_PER_WEEK);
106         
107         assertEquals(60, DateTimeConstants.MINUTES_PER_HOUR);
108         assertEquals(24 * 60, DateTimeConstants.MINUTES_PER_DAY);
109         assertEquals(7 * 24 * 60, DateTimeConstants.MINUTES_PER_WEEK);
110         
111         assertEquals(24, DateTimeConstants.HOURS_PER_DAY);
112         assertEquals(7 * 24, DateTimeConstants.HOURS_PER_WEEK);
113         
114         assertEquals(7, DateTimeConstants.DAYS_PER_WEEK);
115     }
116 
117 }