@@ -486,29 +486,29 @@ mod tests {
486
486
#[test]
487
487
pub fn test_to_str_exact_do_decimal() {
488
488
let s = to_str_exact(5.0, 4u);
489
- assert !(s == ~" 5.0000 ");
489
+ assert_eq !(s, ~" 5.0000 ");
490
490
}
491
491
492
492
#[test]
493
493
pub fn test_from_str() {
494
- assert !(from_str(~" 3 ") == Some(3.));
495
- assert !(from_str(~" 3.14 ") == Some(3.14));
496
- assert !(from_str(~" +3.14 ") == Some(3.14));
497
- assert !(from_str(~" -3.14 ") == Some(-3.14));
498
- assert !(from_str(~" 2.5E10 ") == Some(25000000000.));
499
- assert !(from_str(~" 2.5e10 ") == Some(25000000000.));
500
- assert !(from_str(~" 25000000000 . E -10 ") == Some(2.5));
501
- assert !(from_str(~" . ") == Some(0.));
502
- assert !(from_str(~" . e1") == Some(0.));
503
- assert !(from_str(~" . e-1 ") == Some(0.));
504
- assert !(from_str(~" 5. ") == Some(5.));
505
- assert !(from_str(~" . 5 ") == Some(0.5));
506
- assert !(from_str(~" 0.5 ") == Some(0.5));
507
- assert !(from_str(~" -. 5 ") == Some(-0.5));
508
- assert !(from_str(~" -5 ") == Some(-5.));
509
- assert !(from_str(~" inf") == Some(infinity));
510
- assert !(from_str(~" +inf") == Some(infinity));
511
- assert !(from_str(~" -inf") == Some(neg_infinity));
494
+ assert_eq !(from_str(~" 3 "), Some(3.));
495
+ assert_eq !(from_str(~" 3.14 "), Some(3.14));
496
+ assert_eq !(from_str(~" +3.14 "), Some(3.14));
497
+ assert_eq !(from_str(~" -3.14 "), Some(-3.14));
498
+ assert_eq !(from_str(~" 2.5E10 "), Some(25000000000.));
499
+ assert_eq !(from_str(~" 2.5e10 "), Some(25000000000.));
500
+ assert_eq !(from_str(~" 25000000000 . E -10 "), Some(2.5));
501
+ assert_eq !(from_str(~" . "), Some(0.));
502
+ assert_eq !(from_str(~" . e1"), Some(0.));
503
+ assert_eq !(from_str(~" . e-1 "), Some(0.));
504
+ assert_eq !(from_str(~" 5. "), Some(5.));
505
+ assert_eq !(from_str(~" . 5 "), Some(0.5));
506
+ assert_eq !(from_str(~" 0.5 "), Some(0.5));
507
+ assert_eq !(from_str(~" -. 5 "), Some(-0.5));
508
+ assert_eq !(from_str(~" -5 "), Some(-5.));
509
+ assert_eq !(from_str(~" inf"), Some(infinity));
510
+ assert_eq !(from_str(~" +inf"), Some(infinity));
511
+ assert_eq !(from_str(~" -inf"), Some(neg_infinity));
512
512
// note: NaN != NaN, hence this slightly complex test
513
513
match from_str(~" NaN ") {
514
514
Some(f) => assert!(is_NaN(f)),
@@ -538,24 +538,24 @@ mod tests {
538
538
539
539
#[test]
540
540
pub fn test_from_str_hex() {
541
- assert !(from_str_hex(~" a4") == Some(164.));
542
- assert !(from_str_hex(~" a4. fe") == Some(164.9921875));
543
- assert !(from_str_hex(~" -a4. fe") == Some(-164.9921875));
544
- assert !(from_str_hex(~" +a4. fe") == Some(164.9921875));
545
- assert !(from_str_hex(~" ff0P4") == Some(0xff00 as float));
546
- assert !(from_str_hex(~" ff0p4") == Some(0xff00 as float));
547
- assert !(from_str_hex(~" ff0p-4 ") == Some(0xff as float));
548
- assert !(from_str_hex(~" . ") == Some(0.));
549
- assert !(from_str_hex(~" . p1") == Some(0.));
550
- assert !(from_str_hex(~" . p-1 ") == Some(0.));
551
- assert !(from_str_hex(~" f. ") == Some(15.));
552
- assert !(from_str_hex(~" . f") == Some(0.9375));
553
- assert !(from_str_hex(~" 0 . f") == Some(0.9375));
554
- assert !(from_str_hex(~" -. f") == Some(-0.9375));
555
- assert !(from_str_hex(~" -f") == Some(-15.));
556
- assert !(from_str_hex(~" inf") == Some(infinity));
557
- assert !(from_str_hex(~" +inf") == Some(infinity));
558
- assert !(from_str_hex(~" -inf") == Some(neg_infinity));
541
+ assert_eq !(from_str_hex(~" a4"), Some(164.));
542
+ assert_eq !(from_str_hex(~" a4. fe"), Some(164.9921875));
543
+ assert_eq !(from_str_hex(~" -a4. fe"), Some(-164.9921875));
544
+ assert_eq !(from_str_hex(~" +a4. fe"), Some(164.9921875));
545
+ assert_eq !(from_str_hex(~" ff0P4"), Some(0xff00 as float));
546
+ assert_eq !(from_str_hex(~" ff0p4"), Some(0xff00 as float));
547
+ assert_eq !(from_str_hex(~" ff0p-4 "), Some(0xff as float));
548
+ assert_eq !(from_str_hex(~" . "), Some(0.));
549
+ assert_eq !(from_str_hex(~" . p1"), Some(0.));
550
+ assert_eq !(from_str_hex(~" . p-1 "), Some(0.));
551
+ assert_eq !(from_str_hex(~" f. "), Some(15.));
552
+ assert_eq !(from_str_hex(~" . f"), Some(0.9375));
553
+ assert_eq !(from_str_hex(~" 0 . f"), Some(0.9375));
554
+ assert_eq !(from_str_hex(~" -. f"), Some(-0.9375));
555
+ assert_eq !(from_str_hex(~" -f"), Some(-15.));
556
+ assert_eq !(from_str_hex(~" inf"), Some(infinity));
557
+ assert_eq !(from_str_hex(~" +inf"), Some(infinity));
558
+ assert_eq !(from_str_hex(~" -inf"), Some(neg_infinity));
559
559
// note: NaN != NaN, hence this slightly complex test
560
560
match from_str_hex(~" NaN ") {
561
561
Some(f) => assert!(is_NaN(f)),
@@ -570,11 +570,11 @@ mod tests {
570
570
Some(v) if is_zero(v) => assert!(is_positive(v)),
571
571
_ => fail!()
572
572
}
573
- assert !(from_str_hex(~" e") == Some(14.));
574
- assert !(from_str_hex(~" E ") == Some(14.));
575
- assert !(from_str_hex(~" E1 ") == Some(225.));
576
- assert !(from_str_hex(~" 1e1 e1") == Some(123361.));
577
- assert !(from_str_hex(~" 1e1 . 1 ") == Some(481.0625));
573
+ assert_eq !(from_str_hex(~" e"), Some(14.));
574
+ assert_eq !(from_str_hex(~" E "), Some(14.));
575
+ assert_eq !(from_str_hex(~" E1 "), Some(225.));
576
+ assert_eq !(from_str_hex(~" 1e1 e1"), Some(123361.));
577
+ assert_eq !(from_str_hex(~" 1e1 . 1 "), Some(481.0625));
578
578
579
579
assert!(from_str_hex(~" ").is_none());
580
580
assert!(from_str_hex(~" x").is_none());
@@ -590,92 +590,92 @@ mod tests {
590
590
591
591
#[test]
592
592
pub fn test_to_str_hex() {
593
- assert !(to_str_hex(164.) == ~" a4");
594
- assert !(to_str_hex(164.9921875) == ~" a4. fe");
595
- assert !(to_str_hex(-164.9921875) == ~" -a4. fe");
596
- assert !(to_str_hex(0xff00 as float) == ~" ff00");
597
- assert !(to_str_hex(-(0xff00 as float)) == ~" -ff00");
598
- assert !(to_str_hex(0.) == ~" 0 ");
599
- assert !(to_str_hex(15.) == ~" f");
600
- assert !(to_str_hex(-15.) == ~" -f");
601
- assert !(to_str_hex(0.9375) == ~" 0 . f");
602
- assert !(to_str_hex(-0.9375) == ~" -0 . f");
603
- assert !(to_str_hex(infinity) == ~" inf");
604
- assert !(to_str_hex(neg_infinity) == ~" -inf");
605
- assert !(to_str_hex(NaN) == ~" NaN ");
606
- assert !(to_str_hex(0.) == ~" 0 ");
607
- assert !(to_str_hex(-0.) == ~" -0 ");
593
+ assert_eq !(to_str_hex(164.), ~" a4");
594
+ assert_eq !(to_str_hex(164.9921875), ~" a4. fe");
595
+ assert_eq !(to_str_hex(-164.9921875), ~" -a4. fe");
596
+ assert_eq !(to_str_hex(0xff00 as float), ~" ff00");
597
+ assert_eq !(to_str_hex(-(0xff00 as float)), ~" -ff00");
598
+ assert_eq !(to_str_hex(0.), ~" 0 ");
599
+ assert_eq !(to_str_hex(15.), ~" f");
600
+ assert_eq !(to_str_hex(-15.), ~" -f");
601
+ assert_eq !(to_str_hex(0.9375), ~" 0 . f");
602
+ assert_eq !(to_str_hex(-0.9375), ~" -0 . f");
603
+ assert_eq !(to_str_hex(infinity), ~" inf");
604
+ assert_eq !(to_str_hex(neg_infinity), ~" -inf");
605
+ assert_eq !(to_str_hex(NaN), ~" NaN ");
606
+ assert_eq !(to_str_hex(0.), ~" 0 ");
607
+ assert_eq !(to_str_hex(-0.), ~" -0 ");
608
608
}
609
609
610
610
#[test]
611
611
pub fn test_to_str_radix() {
612
- assert !(to_str_radix(36., 36u) == ~" 10 ");
613
- assert !(to_str_radix(8.125, 2u) == ~" 1000.001 ");
612
+ assert_eq !(to_str_radix(36., 36u), ~" 10 ");
613
+ assert_eq !(to_str_radix(8.125, 2u), ~" 1000.001 ");
614
614
}
615
615
616
616
#[test]
617
617
pub fn test_from_str_radix() {
618
- assert !(from_str_radix(~" 10 ", 36u) == Some(36.));
619
- assert !(from_str_radix(~" 1000.001 ", 2u) == Some(8.125));
618
+ assert_eq !(from_str_radix(~" 10 ", 36u), Some(36.));
619
+ assert_eq !(from_str_radix(~" 1000.001 ", 2u), Some(8.125));
620
620
}
621
621
622
622
#[test]
623
623
pub fn test_positive() {
624
- assert!(( is_positive(infinity) ));
625
- assert!(( is_positive(1.) ));
626
- assert!(( is_positive(0.) ));
627
- assert!(( !is_positive(-1.) ));
628
- assert!(( !is_positive(neg_infinity) ));
629
- assert!(( !is_positive(1./neg_infinity) ));
630
- assert!(( !is_positive(NaN) ));
624
+ assert!(is_positive(infinity));
625
+ assert!(is_positive(1.));
626
+ assert!(is_positive(0.));
627
+ assert!(!is_positive(-1.));
628
+ assert!(!is_positive(neg_infinity));
629
+ assert!(!is_positive(1./neg_infinity));
630
+ assert!(!is_positive(NaN));
631
631
}
632
632
633
633
#[test]
634
634
pub fn test_negative() {
635
- assert!(( !is_negative(infinity) ));
636
- assert!(( !is_negative(1.) ));
637
- assert!(( !is_negative(0.) ));
638
- assert!(( is_negative(-1.) ));
639
- assert!(( is_negative(neg_infinity) ));
640
- assert!(( is_negative(1./neg_infinity) ));
641
- assert!(( !is_negative(NaN) ));
635
+ assert!(!is_negative(infinity));
636
+ assert!(!is_negative(1.));
637
+ assert!(!is_negative(0.));
638
+ assert!(is_negative(-1.));
639
+ assert!(is_negative(neg_infinity));
640
+ assert!(is_negative(1./neg_infinity));
641
+ assert!(!is_negative(NaN));
642
642
}
643
643
644
644
#[test]
645
645
pub fn test_nonpositive() {
646
- assert!(( !is_nonpositive(infinity) ));
647
- assert!(( !is_nonpositive(1.) ));
648
- assert!(( !is_nonpositive(0.) ));
649
- assert!(( is_nonpositive(-1.) ));
650
- assert!(( is_nonpositive(neg_infinity) ));
651
- assert!(( is_nonpositive(1./neg_infinity) ));
652
- assert!(( !is_nonpositive(NaN) ));
646
+ assert!(!is_nonpositive(infinity));
647
+ assert!(!is_nonpositive(1.));
648
+ assert!(!is_nonpositive(0.));
649
+ assert!(is_nonpositive(-1.));
650
+ assert!(is_nonpositive(neg_infinity));
651
+ assert!(is_nonpositive(1./neg_infinity));
652
+ assert!(!is_nonpositive(NaN));
653
653
}
654
654
655
655
#[test]
656
656
pub fn test_nonnegative() {
657
- assert!(( is_nonnegative(infinity) ));
658
- assert!(( is_nonnegative(1.) ));
659
- assert!(( is_nonnegative(0.) ));
660
- assert!(( !is_nonnegative(-1.) ));
661
- assert!(( !is_nonnegative(neg_infinity) ));
662
- assert!(( !is_nonnegative(1./neg_infinity) ));
663
- assert!(( !is_nonnegative(NaN) ));
657
+ assert!(is_nonnegative(infinity));
658
+ assert!(is_nonnegative(1.));
659
+ assert!(is_nonnegative(0.));
660
+ assert!(!is_nonnegative(-1.));
661
+ assert!(!is_nonnegative(neg_infinity));
662
+ assert!(!is_nonnegative(1./neg_infinity));
663
+ assert!(!is_nonnegative(NaN));
664
664
}
665
665
666
666
#[test]
667
667
pub fn test_to_str_inf() {
668
- assert !(to_str_digits(infinity, 10u) == ~" inf");
669
- assert !(to_str_digits(-infinity, 10u) == ~" -inf" ) ;
668
+ assert_eq !(to_str_digits(infinity, 10u), ~" inf");
669
+ assert_eq !(to_str_digits(-infinity, 10u), ~" -inf" ) ;
670
670
}
671
671
672
672
#[ test]
673
673
pub fn test_round ( ) {
674
- assert ! ( round( 5.8 ) == 6.0 ) ;
675
- assert ! ( round( 5.2 ) == 5.0 ) ;
676
- assert ! ( round( 3.0 ) == 3.0 ) ;
677
- assert ! ( round( 2.5 ) == 3.0 ) ;
678
- assert ! ( round( -3.5 ) == -4.0 ) ;
674
+ assert_eq ! ( round( 5.8 ) , 6.0 ) ;
675
+ assert_eq ! ( round( 5.2 ) , 5.0 ) ;
676
+ assert_eq ! ( round( 3.0 ) , 3.0 ) ;
677
+ assert_eq ! ( round( 2.5 ) , 3.0 ) ;
678
+ assert_eq ! ( round( -3.5 ) , -4.0 ) ;
679
679
}
680
680
}
681
681
0 commit comments