@@ -354,45 +354,6 @@ impl Weekday {
354
354
}
355
355
}
356
356
357
- #[ cfg( test) ]
358
- #[ test]
359
- fn weekdays ( ) {
360
- assert_eq ! (
361
- Weekday :: calculate( 1970 , Month :: January , 1 ) ,
362
- Weekday :: Thursday
363
- ) ;
364
- assert_eq ! (
365
- Weekday :: calculate( 2017 , Month :: February , 11 ) ,
366
- Weekday :: Saturday
367
- ) ;
368
- assert_eq ! ( Weekday :: calculate( 1890 , Month :: March , 2 ) , Weekday :: Sunday ) ;
369
- assert_eq ! ( Weekday :: calculate( 2100 , Month :: April , 20 ) , Weekday :: Tuesday ) ;
370
- assert_eq ! ( Weekday :: calculate( 2009 , Month :: May , 31 ) , Weekday :: Sunday ) ;
371
- assert_eq ! ( Weekday :: calculate( 2001 , Month :: June , 9 ) , Weekday :: Saturday ) ;
372
- assert_eq ! ( Weekday :: calculate( 1995 , Month :: July , 21 ) , Weekday :: Friday ) ;
373
- assert_eq ! ( Weekday :: calculate( 1982 , Month :: August , 8 ) , Weekday :: Sunday ) ;
374
- assert_eq ! (
375
- Weekday :: calculate( 1962 , Month :: September , 6 ) ,
376
- Weekday :: Thursday
377
- ) ;
378
- assert_eq ! (
379
- Weekday :: calculate( 1899 , Month :: October , 14 ) ,
380
- Weekday :: Saturday
381
- ) ;
382
- assert_eq ! (
383
- Weekday :: calculate( 2016 , Month :: November , 18 ) ,
384
- Weekday :: Friday
385
- ) ;
386
- assert_eq ! (
387
- Weekday :: calculate( 2010 , Month :: December , 19 ) ,
388
- Weekday :: Sunday
389
- ) ;
390
- assert_eq ! (
391
- Weekday :: calculate( 2016 , Month :: February , 29 ) ,
392
- Weekday :: Monday
393
- ) ;
394
- }
395
-
396
357
fn is_leap ( year : i64 ) -> bool {
397
358
// Leap year rules: years which are factors of 4, except those divisible
398
359
// by 100, unless they are divisible by 400.
@@ -407,21 +368,6 @@ fn is_leap(year: i64) -> bool {
407
368
year & 3 == 0 && ( year % 25 != 0 || year & 15 == 0 )
408
369
}
409
370
410
- #[ cfg( test) ]
411
- #[ test]
412
- fn leap_years ( ) {
413
- assert ! ( !is_leap( 1900 ) ) ;
414
- assert ! ( is_leap( 1904 ) ) ;
415
- assert ! ( is_leap( 1964 ) ) ;
416
- assert ! ( is_leap( 1996 ) ) ;
417
- assert ! ( !is_leap( 1997 ) ) ;
418
- assert ! ( !is_leap( 1997 ) ) ;
419
- assert ! ( !is_leap( 1999 ) ) ;
420
- assert ! ( is_leap( 2000 ) ) ;
421
- assert ! ( is_leap( 2016 ) ) ;
422
- assert ! ( !is_leap( 2100 ) ) ;
423
- }
424
-
425
371
impl DaySpec {
426
372
/// Converts this day specification to a concrete date, given the year and
427
373
/// month it should occur in.
@@ -1320,6 +1266,44 @@ impl<'a> Line<'a> {
1320
1266
mod tests {
1321
1267
use super :: * ;
1322
1268
1269
+ #[ test]
1270
+ fn weekdays ( ) {
1271
+ assert_eq ! (
1272
+ Weekday :: calculate( 1970 , Month :: January , 1 ) ,
1273
+ Weekday :: Thursday
1274
+ ) ;
1275
+ assert_eq ! (
1276
+ Weekday :: calculate( 2017 , Month :: February , 11 ) ,
1277
+ Weekday :: Saturday
1278
+ ) ;
1279
+ assert_eq ! ( Weekday :: calculate( 1890 , Month :: March , 2 ) , Weekday :: Sunday ) ;
1280
+ assert_eq ! ( Weekday :: calculate( 2100 , Month :: April , 20 ) , Weekday :: Tuesday ) ;
1281
+ assert_eq ! ( Weekday :: calculate( 2009 , Month :: May , 31 ) , Weekday :: Sunday ) ;
1282
+ assert_eq ! ( Weekday :: calculate( 2001 , Month :: June , 9 ) , Weekday :: Saturday ) ;
1283
+ assert_eq ! ( Weekday :: calculate( 1995 , Month :: July , 21 ) , Weekday :: Friday ) ;
1284
+ assert_eq ! ( Weekday :: calculate( 1982 , Month :: August , 8 ) , Weekday :: Sunday ) ;
1285
+ assert_eq ! (
1286
+ Weekday :: calculate( 1962 , Month :: September , 6 ) ,
1287
+ Weekday :: Thursday
1288
+ ) ;
1289
+ assert_eq ! (
1290
+ Weekday :: calculate( 1899 , Month :: October , 14 ) ,
1291
+ Weekday :: Saturday
1292
+ ) ;
1293
+ assert_eq ! (
1294
+ Weekday :: calculate( 2016 , Month :: November , 18 ) ,
1295
+ Weekday :: Friday
1296
+ ) ;
1297
+ assert_eq ! (
1298
+ Weekday :: calculate( 2010 , Month :: December , 19 ) ,
1299
+ Weekday :: Sunday
1300
+ ) ;
1301
+ assert_eq ! (
1302
+ Weekday :: calculate( 2016 , Month :: February , 29 ) ,
1303
+ Weekday :: Monday
1304
+ ) ;
1305
+ }
1306
+
1323
1307
#[ test]
1324
1308
fn last_monday ( ) {
1325
1309
let dayspec = DaySpec :: Last ( Weekday :: Monday ) ;
@@ -1590,4 +1574,18 @@ mod tests {
1590
1574
existing: "Europe/Istanbul" ,
1591
1575
new: "Asia/Istanbul" ,
1592
1576
} ) ) ) ;
1577
+
1578
+ #[ test]
1579
+ fn leap_years ( ) {
1580
+ assert ! ( !is_leap( 1900 ) ) ;
1581
+ assert ! ( is_leap( 1904 ) ) ;
1582
+ assert ! ( is_leap( 1964 ) ) ;
1583
+ assert ! ( is_leap( 1996 ) ) ;
1584
+ assert ! ( !is_leap( 1997 ) ) ;
1585
+ assert ! ( !is_leap( 1997 ) ) ;
1586
+ assert ! ( !is_leap( 1999 ) ) ;
1587
+ assert ! ( is_leap( 2000 ) ) ;
1588
+ assert ! ( is_leap( 2016 ) ) ;
1589
+ assert ! ( !is_leap( 2100 ) ) ;
1590
+ }
1593
1591
}
0 commit comments