1
1
// Copyright (c) 2024 Carter Canedy <[email protected] >
2
2
use zips:: zip;
3
3
4
- fn return_some ( ) -> Option < ( ) > {
5
- Some ( ( ) )
6
- }
7
-
8
- fn return_none ( ) -> Option < ( ) > {
9
- None
10
- }
11
-
12
4
#[ allow( unused_parens) ]
13
5
#[ test]
14
6
pub fn test_zip_1_option ( ) -> ( ) {
@@ -40,15 +32,15 @@ pub fn test_zip_3_options() -> () {
40
32
41
33
#[ test]
42
34
pub fn test_zip_1_option_none ( ) -> ( ) {
43
- let opt1 = return_none ( ) ;
35
+ let opt1 = Option :: < ( ) > :: None ;
44
36
let zipped = zip ! ( opt1) ;
45
37
assert_eq ! ( zipped, None ) ;
46
38
}
47
39
48
40
#[ test]
49
41
pub fn test_zip_2_options_mixed ( ) -> ( ) {
50
- let opt1 = return_none ( ) ;
51
- let opt2 = return_some ( ) ;
42
+ let opt1 = Option :: < ( ) > :: None ;
43
+ let opt2 = Option :: < ( ) > :: None ;
52
44
53
45
let zipped = zip ! ( opt1, opt2) ;
54
46
@@ -57,9 +49,9 @@ pub fn test_zip_2_options_mixed() -> () {
57
49
58
50
#[ test]
59
51
pub fn test_zip_3_options_mixed ( ) -> ( ) {
60
- let opt1 = return_none ( ) ;
61
- let opt2 = return_some ( ) ;
62
- let opt3 = return_some ( ) ;
52
+ let opt1 = Option :: < ( ) > :: None ;
53
+ let opt2 = Some ( Option :: < ( ) > :: None ) ;
54
+ let opt3 = Some ( ( ) ) ;
63
55
64
56
let zipped = zip ! ( opt1, opt2, opt3) ;
65
57
@@ -69,23 +61,23 @@ pub fn test_zip_3_options_mixed() -> () {
69
61
#[ allow( unused_parens) ]
70
62
#[ test]
71
63
pub fn test_zip_some_unaliased_arg ( ) -> ( ) {
72
- let zipped = zip ! ( return_some ( ) ) ;
73
-
74
- assert_eq ! ( zipped, Some ( ( ( ) ) ) ) ;
64
+ let zipped = zip ! ( Some ( ( ) ) ) ;
65
+
66
+ assert_eq ! ( zipped, Some ( ( ) ) ) ;
75
67
}
76
68
77
69
#[ test]
78
70
pub fn test_zip_none_unaliased_arg ( ) -> ( ) {
79
- let zipped = zip ! ( return_none ( ) ) ;
80
-
71
+ let zipped = zip ! ( Option :: < ( ) > :: None ) ;
72
+
81
73
assert_eq ! ( zipped, None ) ;
82
74
}
83
75
84
76
#[ test]
85
77
pub fn test_zip_mixed_unaliased_args ( ) -> ( ) {
86
78
let zipped = zip ! (
87
- return_some ( ) ,
88
- return_none ( )
79
+ Some ( ( ) ) ,
80
+ Option :: < ( ) > :: None
89
81
) ;
90
82
91
83
assert_eq ! ( zipped, None ) ;
@@ -95,9 +87,31 @@ pub fn test_zip_mixed_unaliased_args() -> () {
95
87
pub fn test_zip_some_unaliased_args ( ) -> ( ) {
96
88
let zipped = zip ! (
97
89
Some ( 1u32 ) ,
98
- Some ( "2" ) ,
90
+ Some ( ( ) ) ,
99
91
Some ( 3usize )
100
92
) ;
101
-
102
- assert_eq ! ( zipped, Some ( ( 1u32 , "2" , 3usize ) ) ) ;
93
+
94
+ assert_eq ! ( zipped, Some ( ( 1u32 , ( ) , 3usize ) ) ) ;
95
+ }
96
+
97
+ #[ test]
98
+ pub fn test_zip_some_nested_invokations ( ) -> ( ) {
99
+ let a = Some ( 1i32 ) ;
100
+ let b = Some ( 0usize ) ;
101
+ let c = Some ( ( ) ) ;
102
+
103
+ let zipped = zip ! ( zip!( a, b) , c) ;
104
+
105
+ assert_eq ! ( zipped, Some ( ( ( 1i32 , 0usize ) , ( ) ) ) ) ;
106
+ }
107
+
108
+ #[ test]
109
+ pub fn test_zip_none_nested_invokations ( ) -> ( ) {
110
+ let a = Some ( 1i32 ) ;
111
+ let b = Some ( 0usize ) ;
112
+ let c = Option :: < ( ) > :: None ;
113
+
114
+ let zipped = zip ! ( a, zip!( b, c) ) ;
115
+
116
+ assert_eq ! ( zipped, None ) ;
103
117
}
0 commit comments