Skip to content

Commit c709a10

Browse files
committed
Refactor tuple comparison tests
1 parent 0633c55 commit c709a10

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

Diff for: src/libcore/tests/tuple.rs

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cmp::Ordering::{Equal, Less, Greater};
2+
use std::f64::NAN;
23

34
#[test]
45
fn test_clone() {
@@ -8,18 +9,18 @@ fn test_clone() {
89
}
910

1011
#[test]
11-
fn test_tuple_cmp() {
12+
fn test_partial_eq() {
1213
let (small, big) = ((1, 2, 3), (3, 2, 1));
13-
14-
let nan = 0.0f64/0.0;
15-
16-
// PartialEq
1714
assert_eq!(small, small);
1815
assert_eq!(big, big);
19-
assert!(small != big);
20-
assert!(big != small);
16+
assert_ne!(small, big);
17+
assert_ne!(big, small);
18+
}
19+
20+
#[test]
21+
fn test_partial_ord() {
22+
let (small, big) = ((1, 2, 3), (3, 2, 1));
2123

22-
// PartialOrd
2324
assert!(small < big);
2425
assert!(!(small < small));
2526
assert!(!(big < small));
@@ -33,18 +34,21 @@ fn test_tuple_cmp() {
3334
assert!(big >= small);
3435
assert!(big >= big);
3536

36-
assert!(!((1.0f64, 2.0f64) < (nan, 3.0)));
37-
assert!(!((1.0f64, 2.0f64) <= (nan, 3.0)));
38-
assert!(!((1.0f64, 2.0f64) > (nan, 3.0)));
39-
assert!(!((1.0f64, 2.0f64) >= (nan, 3.0)));
40-
assert!(((1.0f64, 2.0f64) < (2.0, nan)));
41-
assert!(!((2.0f64, 2.0f64) < (2.0, nan)));
42-
43-
// Ord
44-
assert!(small.cmp(&small) == Equal);
45-
assert!(big.cmp(&big) == Equal);
46-
assert!(small.cmp(&big) == Less);
47-
assert!(big.cmp(&small) == Greater);
37+
assert!(!((1.0f64, 2.0f64) < (NAN, 3.0)));
38+
assert!(!((1.0f64, 2.0f64) <= (NAN, 3.0)));
39+
assert!(!((1.0f64, 2.0f64) > (NAN, 3.0)));
40+
assert!(!((1.0f64, 2.0f64) >= (NAN, 3.0)));
41+
assert!(((1.0f64, 2.0f64) < (2.0, NAN)));
42+
assert!(!((2.0f64, 2.0f64) < (2.0, NAN)));
43+
}
44+
45+
#[test]
46+
fn test_ord() {
47+
let (small, big) = ((1, 2, 3), (3, 2, 1));
48+
assert_eq!(small.cmp(&small), Equal);
49+
assert_eq!(big.cmp(&big), Equal);
50+
assert_eq!(small.cmp(&big), Less);
51+
assert_eq!(big.cmp(&small), Greater);
4852
}
4953

5054
#[test]

0 commit comments

Comments
 (0)