@@ -134,6 +134,15 @@ fn test_infallible_try_from_int_error() {
134
134
}
135
135
136
136
macro_rules! test_impl_from {
137
+ ( $fn_name: ident, bool , $target: ty) => {
138
+ #[ test]
139
+ fn $fn_name( ) {
140
+ let one: $target = 1 ;
141
+ let zero: $target = 0 ;
142
+ assert_eq!( one, <$target>:: from( true ) ) ;
143
+ assert_eq!( zero, <$target>:: from( false ) ) ;
144
+ }
145
+ } ;
137
146
( $fn_name: ident, $Small: ty, $Large: ty) => {
138
147
#[ test]
139
148
fn $fn_name( ) {
@@ -173,6 +182,18 @@ test_impl_from! { test_u16i32, u16, i32 }
173
182
test_impl_from ! { test_u16i64, u16 , i64 }
174
183
test_impl_from ! { test_u32i64, u32 , i64 }
175
184
185
+ // Bool -> Integer
186
+ test_impl_from ! { test_boolu8, bool , u8 }
187
+ test_impl_from ! { test_boolu16, bool , u16 }
188
+ test_impl_from ! { test_boolu32, bool , u32 }
189
+ test_impl_from ! { test_boolu64, bool , u64 }
190
+ test_impl_from ! { test_boolu128, bool , u128 }
191
+ test_impl_from ! { test_booli8, bool , i8 }
192
+ test_impl_from ! { test_booli16, bool , i16 }
193
+ test_impl_from ! { test_booli32, bool , i32 }
194
+ test_impl_from ! { test_booli64, bool , i64 }
195
+ test_impl_from ! { test_booli128, bool , i128 }
196
+
176
197
// Signed -> Float
177
198
test_impl_from ! { test_i8f32, i8 , f32 }
178
199
test_impl_from ! { test_i8f64, i8 , f64 }
0 commit comments