1   /* Copyright 2002-2025 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.time;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  
22  public class MonthTest {
23  
24      @Test
25      public void testUpperCaseName() {
26          Assertions.assertEquals("JANUARY",   Month.JANUARY.getUpperCaseName());
27          Assertions.assertEquals("FEBRUARY",  Month.FEBRUARY.getUpperCaseName());
28          Assertions.assertEquals("MARCH",     Month.MARCH.getUpperCaseName());
29          Assertions.assertEquals("APRIL",     Month.APRIL.getUpperCaseName());
30          Assertions.assertEquals("MAY",       Month.MAY.getUpperCaseName());
31          Assertions.assertEquals("JUNE",      Month.JUNE.getUpperCaseName());
32          Assertions.assertEquals("JULY",      Month.JULY.getUpperCaseName());
33          Assertions.assertEquals("AUGUST",    Month.AUGUST.getUpperCaseName());
34          Assertions.assertEquals("SEPTEMBER", Month.SEPTEMBER.getUpperCaseName());
35          Assertions.assertEquals("OCTOBER",   Month.OCTOBER.getUpperCaseName());
36          Assertions.assertEquals("NOVEMBER",  Month.NOVEMBER.getUpperCaseName());
37          Assertions.assertEquals("DECEMBER",  Month.DECEMBER.getUpperCaseName());
38      }
39  
40      @Test
41      public void testLowerCaseName() {
42          Assertions.assertEquals("january",   Month.JANUARY.getLowerCaseName());
43          Assertions.assertEquals("february",  Month.FEBRUARY.getLowerCaseName());
44          Assertions.assertEquals("march",     Month.MARCH.getLowerCaseName());
45          Assertions.assertEquals("april",     Month.APRIL.getLowerCaseName());
46          Assertions.assertEquals("may",       Month.MAY.getLowerCaseName());
47          Assertions.assertEquals("june",      Month.JUNE.getLowerCaseName());
48          Assertions.assertEquals("july",      Month.JULY.getLowerCaseName());
49          Assertions.assertEquals("august",    Month.AUGUST.getLowerCaseName());
50          Assertions.assertEquals("september", Month.SEPTEMBER.getLowerCaseName());
51          Assertions.assertEquals("october",   Month.OCTOBER.getLowerCaseName());
52          Assertions.assertEquals("november",  Month.NOVEMBER.getLowerCaseName());
53          Assertions.assertEquals("december",  Month.DECEMBER.getLowerCaseName());
54      }
55  
56      @Test
57      public void testCapitalizedCaseName() {
58          Assertions.assertEquals("January",   Month.JANUARY.getCapitalizedName());
59          Assertions.assertEquals("February",  Month.FEBRUARY.getCapitalizedName());
60          Assertions.assertEquals("March",     Month.MARCH.getCapitalizedName());
61          Assertions.assertEquals("April",     Month.APRIL.getCapitalizedName());
62          Assertions.assertEquals("May",       Month.MAY.getCapitalizedName());
63          Assertions.assertEquals("June",      Month.JUNE.getCapitalizedName());
64          Assertions.assertEquals("July",      Month.JULY.getCapitalizedName());
65          Assertions.assertEquals("August",    Month.AUGUST.getCapitalizedName());
66          Assertions.assertEquals("September", Month.SEPTEMBER.getCapitalizedName());
67          Assertions.assertEquals("October",   Month.OCTOBER.getCapitalizedName());
68          Assertions.assertEquals("November",  Month.NOVEMBER.getCapitalizedName());
69          Assertions.assertEquals("December",  Month.DECEMBER.getCapitalizedName());
70      }
71  
72      @Test
73      public void testUpperCaseAbbreviation() {
74          Assertions.assertEquals("JAN",       Month.JANUARY.getUpperCaseAbbreviation());
75          Assertions.assertEquals("FEB",       Month.FEBRUARY.getUpperCaseAbbreviation());
76          Assertions.assertEquals("MAR",       Month.MARCH.getUpperCaseAbbreviation());
77          Assertions.assertEquals("APR",       Month.APRIL.getUpperCaseAbbreviation());
78          Assertions.assertEquals("MAY",       Month.MAY.getUpperCaseAbbreviation());
79          Assertions.assertEquals("JUN",       Month.JUNE.getUpperCaseAbbreviation());
80          Assertions.assertEquals("JUL",       Month.JULY.getUpperCaseAbbreviation());
81          Assertions.assertEquals("AUG",       Month.AUGUST.getUpperCaseAbbreviation());
82          Assertions.assertEquals("SEP",       Month.SEPTEMBER.getUpperCaseAbbreviation());
83          Assertions.assertEquals("OCT",       Month.OCTOBER.getUpperCaseAbbreviation());
84          Assertions.assertEquals("NOV",       Month.NOVEMBER.getUpperCaseAbbreviation());
85          Assertions.assertEquals("DEC",       Month.DECEMBER.getUpperCaseAbbreviation());
86      }
87  
88      @Test
89      public void testLowerCaseAbbreviation() {
90          Assertions.assertEquals("jan",       Month.JANUARY.getLowerCaseAbbreviation());
91          Assertions.assertEquals("feb",       Month.FEBRUARY.getLowerCaseAbbreviation());
92          Assertions.assertEquals("mar",       Month.MARCH.getLowerCaseAbbreviation());
93          Assertions.assertEquals("apr",       Month.APRIL.getLowerCaseAbbreviation());
94          Assertions.assertEquals("may",       Month.MAY.getLowerCaseAbbreviation());
95          Assertions.assertEquals("jun",       Month.JUNE.getLowerCaseAbbreviation());
96          Assertions.assertEquals("jul",       Month.JULY.getLowerCaseAbbreviation());
97          Assertions.assertEquals("aug",       Month.AUGUST.getLowerCaseAbbreviation());
98          Assertions.assertEquals("sep",       Month.SEPTEMBER.getLowerCaseAbbreviation());
99          Assertions.assertEquals("oct",       Month.OCTOBER.getLowerCaseAbbreviation());
100         Assertions.assertEquals("nov",       Month.NOVEMBER.getLowerCaseAbbreviation());
101         Assertions.assertEquals("dec",       Month.DECEMBER.getLowerCaseAbbreviation());
102     }
103 
104     @Test
105     public void testCapitalizedCaseAbbreviation() {
106         Assertions.assertEquals("Jan",       Month.JANUARY.getCapitalizedAbbreviation());
107         Assertions.assertEquals("Feb",       Month.FEBRUARY.getCapitalizedAbbreviation());
108         Assertions.assertEquals("Mar",       Month.MARCH.getCapitalizedAbbreviation());
109         Assertions.assertEquals("Apr",       Month.APRIL.getCapitalizedAbbreviation());
110         Assertions.assertEquals("May",       Month.MAY.getCapitalizedAbbreviation());
111         Assertions.assertEquals("Jun",       Month.JUNE.getCapitalizedAbbreviation());
112         Assertions.assertEquals("Jul",       Month.JULY.getCapitalizedAbbreviation());
113         Assertions.assertEquals("Aug",       Month.AUGUST.getCapitalizedAbbreviation());
114         Assertions.assertEquals("Sep",       Month.SEPTEMBER.getCapitalizedAbbreviation());
115         Assertions.assertEquals("Oct",       Month.OCTOBER.getCapitalizedAbbreviation());
116         Assertions.assertEquals("Nov",       Month.NOVEMBER.getCapitalizedAbbreviation());
117         Assertions.assertEquals("Dec",       Month.DECEMBER.getCapitalizedAbbreviation());
118     }
119 
120     @Test
121     public void testParsing() {
122         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("   AUGUST "));
123         Assertions.assertEquals(Month.AUGUST, Month.parseMonth(" august  "));
124         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("August"));
125         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("\tAUG"));
126         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("august"));
127         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("Aug"));
128         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("aUgUsT  "));
129         Assertions.assertEquals(Month.AUGUST, Month.parseMonth(" 8 "));
130         Assertions.assertEquals(Month.AUGUST, Month.parseMonth("00008"));
131     }
132 
133     @Test
134     public void testParsingErrorEmpty() {
135         Assertions.assertThrows(IllegalArgumentException.class, () -> {
136             Month.parseMonth("  ");
137         });
138     }
139 
140     @Test
141     public void testParsingErrorTooLow() {
142         Assertions.assertThrows(IllegalArgumentException.class, () -> {
143             Month.parseMonth("0");
144         });
145     }
146 
147     @Test
148     public void testParsingErrorTooHigh() {
149         Assertions.assertThrows(IllegalArgumentException.class, () -> {
150             Month.parseMonth("13");
151         });
152     }
153 
154     @Test
155     public void testParsingErrorCorruptedString() {
156         Assertions.assertThrows(IllegalArgumentException.class, () -> {
157             Month.parseMonth("AUGUSTE");
158         });
159     }
160 
161 }