|
@@ -5,7 +5,7 @@ |
5 |
5 |
|
|
6 |
6 |
|
import org.litesoft.core.typeutils.*; |
7 |
7 |
|
|
8 |
|
- |
public class CalendarYMTest extends TestCase |
|
8 |
+ |
public class CalendarYMTest extends AbstractTemporalTestSupport<CalendarYM> |
9 |
9 |
|
{ |
10 |
10 |
|
public static TestSuite suite() |
11 |
11 |
|
{ |
|
@@ -136,25 +136,7 @@ |
136 |
136 |
|
CalendarYM od = CalendarYM.fromYM( pDateYM ); |
137 |
137 |
|
CalendarYM nd = od.addYears( pAdjustBy ); |
138 |
138 |
|
assertEquals( pExpectedYM, nd.toYM() ); |
139 |
|
- |
if ( pAdjustBy == 0 ) |
140 |
|
- |
{ |
141 |
|
- |
assertTrue( od == nd ); |
142 |
|
- |
assertTrue( 0 == od.compareTo( nd ) ); |
143 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
144 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
145 |
|
- |
} |
146 |
|
- |
else if ( pAdjustBy > 0 ) |
147 |
|
- |
{ |
148 |
|
- |
assertTrue( 0 > od.compareTo( nd ) ); |
149 |
|
- |
assertFalse( od.afterOrEqual( nd ) ); |
150 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
151 |
|
- |
} |
152 |
|
- |
else // pAdjustBy < 0 |
153 |
|
- |
{ |
154 |
|
- |
assertTrue( 0 < od.compareTo( nd ) ); |
155 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
156 |
|
- |
assertFalse( od.beforeOrEqual( nd ) ); |
157 |
|
- |
} |
|
139 |
+ |
compareCheck( add( pAdjustBy ), od, nd ); |
158 |
140 |
|
} |
159 |
141 |
|
|
160 |
142 |
|
public void test_minusYears() |
|
@@ -171,25 +153,7 @@ |
171 |
153 |
|
CalendarYM od = CalendarYM.fromYM( pDateYM ); |
172 |
154 |
|
CalendarYM nd = od.minusYears( pAdjustBy ); |
173 |
155 |
|
assertEquals( pExpectedYM, nd.toYM() ); |
174 |
|
- |
if ( pAdjustBy == 0 ) |
175 |
|
- |
{ |
176 |
|
- |
assertTrue( od == nd ); |
177 |
|
- |
assertTrue( 0 == od.compareTo( nd ) ); |
178 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
179 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
180 |
|
- |
} |
181 |
|
- |
else if ( pAdjustBy < 0 ) |
182 |
|
- |
{ |
183 |
|
- |
assertTrue( 0 > od.compareTo( nd ) ); |
184 |
|
- |
assertFalse( od.afterOrEqual( nd ) ); |
185 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
186 |
|
- |
} |
187 |
|
- |
else // pAdjustBy > 0 |
188 |
|
- |
{ |
189 |
|
- |
assertTrue( 0 < od.compareTo( nd ) ); |
190 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
191 |
|
- |
assertFalse( od.beforeOrEqual( nd ) ); |
192 |
|
- |
} |
|
156 |
+ |
compareCheck( minus( pAdjustBy ), od, nd ); |
193 |
157 |
|
} |
194 |
158 |
|
|
195 |
159 |
|
public void test_addMonths() |
|
@@ -206,25 +170,7 @@ |
206 |
170 |
|
CalendarYM od = CalendarYM.fromYM( pDateYM ); |
207 |
171 |
|
CalendarYM nd = od.addMonths( pAdjustBy ); |
208 |
172 |
|
assertEquals( pExpectedYM, nd.toYM() ); |
209 |
|
- |
if ( pAdjustBy == 0 ) |
210 |
|
- |
{ |
211 |
|
- |
assertTrue( od == nd ); |
212 |
|
- |
assertTrue( 0 == od.compareTo( nd ) ); |
213 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
214 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
215 |
|
- |
} |
216 |
|
- |
else if ( pAdjustBy > 0 ) |
217 |
|
- |
{ |
218 |
|
- |
assertTrue( 0 > od.compareTo( nd ) ); |
219 |
|
- |
assertFalse( od.afterOrEqual( nd ) ); |
220 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
221 |
|
- |
} |
222 |
|
- |
else // pAdjustBy < 0 |
223 |
|
- |
{ |
224 |
|
- |
assertTrue( 0 < od.compareTo( nd ) ); |
225 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
226 |
|
- |
assertFalse( od.beforeOrEqual( nd ) ); |
227 |
|
- |
} |
|
173 |
+ |
compareCheck( add( pAdjustBy ), od, nd ); |
228 |
174 |
|
} |
229 |
175 |
|
|
230 |
176 |
|
public void test_minusMonths() |
|
@@ -241,47 +187,11 @@ |
241 |
187 |
|
CalendarYM od = CalendarYM.fromYM( pDateYM ); |
242 |
188 |
|
CalendarYM nd = od.minusMonths( pAdjustBy ); |
243 |
189 |
|
assertEquals( pExpectedYM, nd.toYM() ); |
244 |
|
- |
if ( pAdjustBy == 0 ) |
245 |
|
- |
{ |
246 |
|
- |
assertTrue( od == nd ); |
247 |
|
- |
assertTrue( 0 == od.compareTo( nd ) ); |
248 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
249 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
250 |
|
- |
} |
251 |
|
- |
else if ( pAdjustBy < 0 ) |
252 |
|
- |
{ |
253 |
|
- |
assertTrue( 0 > od.compareTo( nd ) ); |
254 |
|
- |
assertFalse( od.afterOrEqual( nd ) ); |
255 |
|
- |
assertTrue( od.beforeOrEqual( nd ) ); |
256 |
|
- |
} |
257 |
|
- |
else // pAdjustBy > 0 |
258 |
|
- |
{ |
259 |
|
- |
assertTrue( 0 < od.compareTo( nd ) ); |
260 |
|
- |
assertTrue( od.afterOrEqual( nd ) ); |
261 |
|
- |
assertFalse( od.beforeOrEqual( nd ) ); |
262 |
|
- |
} |
|
190 |
+ |
compareCheck( minus( pAdjustBy ), od, nd ); |
263 |
191 |
|
} |
264 |
192 |
|
|
265 |
193 |
|
public void test_after_before_null() |
266 |
194 |
|
{ |
267 |
|
- |
CalendarYM sd = new CalendarYM( 2000, 1 ); |
268 |
|
- |
try |
269 |
|
- |
{ |
270 |
|
- |
sd.afterOrEqual( null ); |
271 |
|
- |
fail( "Did Not fail on '" + sd + "': after( null )" ); |
272 |
|
- |
} |
273 |
|
- |
catch ( IllegalArgumentException expected ) |
274 |
|
- |
{ |
275 |
|
- |
// expected |
276 |
|
- |
} |
277 |
|
- |
try |
278 |
|
- |
{ |
279 |
|
- |
sd.beforeOrEqual( null ); |
280 |
|
- |
fail( "Did Not fail on '" + sd + "': before( null )" ); |
281 |
|
- |
} |
282 |
|
- |
catch ( IllegalArgumentException expected ) |
283 |
|
- |
{ |
284 |
|
- |
// expected |
285 |
|
- |
} |
|
195 |
+ |
chkAfterBeforeNull( new CalendarYM( 2000, 1 ) ); |
286 |
196 |
|
} |
287 |
197 |
|
} |