1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.time;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21
22 public class MonthTest {
23
24 @Test
25 public void testUpperCaseName() {
26 Assert.assertEquals("JANUARY", Month.JANUARY.getUpperCaseName());
27 Assert.assertEquals("FEBRUARY", Month.FEBRUARY.getUpperCaseName());
28 Assert.assertEquals("MARCH", Month.MARCH.getUpperCaseName());
29 Assert.assertEquals("APRIL", Month.APRIL.getUpperCaseName());
30 Assert.assertEquals("MAY", Month.MAY.getUpperCaseName());
31 Assert.assertEquals("JUNE", Month.JUNE.getUpperCaseName());
32 Assert.assertEquals("JULY", Month.JULY.getUpperCaseName());
33 Assert.assertEquals("AUGUST", Month.AUGUST.getUpperCaseName());
34 Assert.assertEquals("SEPTEMBER", Month.SEPTEMBER.getUpperCaseName());
35 Assert.assertEquals("OCTOBER", Month.OCTOBER.getUpperCaseName());
36 Assert.assertEquals("NOVEMBER", Month.NOVEMBER.getUpperCaseName());
37 Assert.assertEquals("DECEMBER", Month.DECEMBER.getUpperCaseName());
38 }
39
40 @Test
41 public void testLowerCaseName() {
42 Assert.assertEquals("january", Month.JANUARY.getLowerCaseName());
43 Assert.assertEquals("february", Month.FEBRUARY.getLowerCaseName());
44 Assert.assertEquals("march", Month.MARCH.getLowerCaseName());
45 Assert.assertEquals("april", Month.APRIL.getLowerCaseName());
46 Assert.assertEquals("may", Month.MAY.getLowerCaseName());
47 Assert.assertEquals("june", Month.JUNE.getLowerCaseName());
48 Assert.assertEquals("july", Month.JULY.getLowerCaseName());
49 Assert.assertEquals("august", Month.AUGUST.getLowerCaseName());
50 Assert.assertEquals("september", Month.SEPTEMBER.getLowerCaseName());
51 Assert.assertEquals("october", Month.OCTOBER.getLowerCaseName());
52 Assert.assertEquals("november", Month.NOVEMBER.getLowerCaseName());
53 Assert.assertEquals("december", Month.DECEMBER.getLowerCaseName());
54 }
55
56 @Test
57 public void testCapitalizedCaseName() {
58 Assert.assertEquals("January", Month.JANUARY.getCapitalizedName());
59 Assert.assertEquals("February", Month.FEBRUARY.getCapitalizedName());
60 Assert.assertEquals("March", Month.MARCH.getCapitalizedName());
61 Assert.assertEquals("April", Month.APRIL.getCapitalizedName());
62 Assert.assertEquals("May", Month.MAY.getCapitalizedName());
63 Assert.assertEquals("June", Month.JUNE.getCapitalizedName());
64 Assert.assertEquals("July", Month.JULY.getCapitalizedName());
65 Assert.assertEquals("August", Month.AUGUST.getCapitalizedName());
66 Assert.assertEquals("September", Month.SEPTEMBER.getCapitalizedName());
67 Assert.assertEquals("October", Month.OCTOBER.getCapitalizedName());
68 Assert.assertEquals("November", Month.NOVEMBER.getCapitalizedName());
69 Assert.assertEquals("December", Month.DECEMBER.getCapitalizedName());
70 }
71
72 @Test
73 public void testUpperCaseAbbreviation() {
74 Assert.assertEquals("JAN", Month.JANUARY.getUpperCaseAbbreviation());
75 Assert.assertEquals("FEB", Month.FEBRUARY.getUpperCaseAbbreviation());
76 Assert.assertEquals("MAR", Month.MARCH.getUpperCaseAbbreviation());
77 Assert.assertEquals("APR", Month.APRIL.getUpperCaseAbbreviation());
78 Assert.assertEquals("MAY", Month.MAY.getUpperCaseAbbreviation());
79 Assert.assertEquals("JUN", Month.JUNE.getUpperCaseAbbreviation());
80 Assert.assertEquals("JUL", Month.JULY.getUpperCaseAbbreviation());
81 Assert.assertEquals("AUG", Month.AUGUST.getUpperCaseAbbreviation());
82 Assert.assertEquals("SEP", Month.SEPTEMBER.getUpperCaseAbbreviation());
83 Assert.assertEquals("OCT", Month.OCTOBER.getUpperCaseAbbreviation());
84 Assert.assertEquals("NOV", Month.NOVEMBER.getUpperCaseAbbreviation());
85 Assert.assertEquals("DEC", Month.DECEMBER.getUpperCaseAbbreviation());
86 }
87
88 @Test
89 public void testLowerCaseAbbreviation() {
90 Assert.assertEquals("jan", Month.JANUARY.getLowerCaseAbbreviation());
91 Assert.assertEquals("feb", Month.FEBRUARY.getLowerCaseAbbreviation());
92 Assert.assertEquals("mar", Month.MARCH.getLowerCaseAbbreviation());
93 Assert.assertEquals("apr", Month.APRIL.getLowerCaseAbbreviation());
94 Assert.assertEquals("may", Month.MAY.getLowerCaseAbbreviation());
95 Assert.assertEquals("jun", Month.JUNE.getLowerCaseAbbreviation());
96 Assert.assertEquals("jul", Month.JULY.getLowerCaseAbbreviation());
97 Assert.assertEquals("aug", Month.AUGUST.getLowerCaseAbbreviation());
98 Assert.assertEquals("sep", Month.SEPTEMBER.getLowerCaseAbbreviation());
99 Assert.assertEquals("oct", Month.OCTOBER.getLowerCaseAbbreviation());
100 Assert.assertEquals("nov", Month.NOVEMBER.getLowerCaseAbbreviation());
101 Assert.assertEquals("dec", Month.DECEMBER.getLowerCaseAbbreviation());
102 }
103
104 @Test
105 public void testCapitalizedCaseAbbreviation() {
106 Assert.assertEquals("Jan", Month.JANUARY.getCapitalizedAbbreviation());
107 Assert.assertEquals("Feb", Month.FEBRUARY.getCapitalizedAbbreviation());
108 Assert.assertEquals("Mar", Month.MARCH.getCapitalizedAbbreviation());
109 Assert.assertEquals("Apr", Month.APRIL.getCapitalizedAbbreviation());
110 Assert.assertEquals("May", Month.MAY.getCapitalizedAbbreviation());
111 Assert.assertEquals("Jun", Month.JUNE.getCapitalizedAbbreviation());
112 Assert.assertEquals("Jul", Month.JULY.getCapitalizedAbbreviation());
113 Assert.assertEquals("Aug", Month.AUGUST.getCapitalizedAbbreviation());
114 Assert.assertEquals("Sep", Month.SEPTEMBER.getCapitalizedAbbreviation());
115 Assert.assertEquals("Oct", Month.OCTOBER.getCapitalizedAbbreviation());
116 Assert.assertEquals("Nov", Month.NOVEMBER.getCapitalizedAbbreviation());
117 Assert.assertEquals("Dec", Month.DECEMBER.getCapitalizedAbbreviation());
118 }
119
120 @Test
121 public void testParsing() {
122 Assert.assertEquals(Month.AUGUST, Month.parseMonth(" AUGUST "));
123 Assert.assertEquals(Month.AUGUST, Month.parseMonth(" august "));
124 Assert.assertEquals(Month.AUGUST, Month.parseMonth("August"));
125 Assert.assertEquals(Month.AUGUST, Month.parseMonth("\tAUG"));
126 Assert.assertEquals(Month.AUGUST, Month.parseMonth("august"));
127 Assert.assertEquals(Month.AUGUST, Month.parseMonth("Aug"));
128 Assert.assertEquals(Month.AUGUST, Month.parseMonth("aUgUsT "));
129 Assert.assertEquals(Month.AUGUST, Month.parseMonth(" 8 "));
130 Assert.assertEquals(Month.AUGUST, Month.parseMonth("00008"));
131 }
132
133 @Test(expected=IllegalArgumentException.class)
134 public void testParsingErrorEmpty() {
135 Month.parseMonth(" ");
136 }
137
138 @Test(expected=IllegalArgumentException.class)
139 public void testParsingErrorTooLow() {
140 Month.parseMonth("0");
141 }
142
143 @Test(expected=IllegalArgumentException.class)
144 public void testParsingErrorTooHigh() {
145 Month.parseMonth("13");
146 }
147
148 @Test(expected=IllegalArgumentException.class)
149 public void testParsingErrorCorruptedString() {
150 Month.parseMonth("AUGUSTE");
151 }
152
153 }