]> git.lizzy.rs Git - rust.git/blob - library/core/tests/tuple.rs
Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyup
[rust.git] / library / core / tests / tuple.rs
1 use std::cmp::Ordering::{Equal, Greater, Less};
2
3 #[test]
4 fn test_clone() {
5     let a = (1, "2");
6     let b = a.clone();
7     assert_eq!(a, b);
8 }
9
10 #[test]
11 fn test_partial_eq() {
12     let (small, big) = ((1, 2, 3), (3, 2, 1));
13     assert_eq!(small, small);
14     assert_eq!(big, big);
15     assert_ne!(small, big);
16     assert_ne!(big, small);
17 }
18
19 #[test]
20 fn test_partial_ord() {
21     let (small, big) = ((1, 2, 3), (3, 2, 1));
22
23     assert!(small < big);
24     assert!(!(small < small));
25     assert!(!(big < small));
26     assert!(!(big < big));
27
28     assert!(small <= small);
29     assert!(big <= big);
30
31     assert!(big > small);
32     assert!(small >= small);
33     assert!(big >= small);
34     assert!(big >= big);
35
36     assert!(!((1.0f64, 2.0f64) < (f64::NAN, 3.0)));
37     assert!(!((1.0f64, 2.0f64) <= (f64::NAN, 3.0)));
38     assert!(!((1.0f64, 2.0f64) > (f64::NAN, 3.0)));
39     assert!(!((1.0f64, 2.0f64) >= (f64::NAN, 3.0)));
40     assert!(((1.0f64, 2.0f64) < (2.0, f64::NAN)));
41     assert!(!((2.0f64, 2.0f64) < (2.0, f64::NAN)));
42 }
43
44 #[test]
45 fn test_ord() {
46     let (small, big) = ((1, 2, 3), (3, 2, 1));
47     assert_eq!(small.cmp(&small), Equal);
48     assert_eq!(big.cmp(&big), Equal);
49     assert_eq!(small.cmp(&big), Less);
50     assert_eq!(big.cmp(&small), Greater);
51 }
52
53 #[test]
54 fn test_show() {
55     let s = format!("{:?}", (1,));
56     assert_eq!(s, "(1,)");
57     let s = format!("{:?}", (1, true));
58     assert_eq!(s, "(1, true)");
59     let s = format!("{:?}", (1, "hi", true));
60     assert_eq!(s, "(1, \"hi\", true)");
61 }