about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClar Charr <clar@charr.xyz>2018-05-20 14:56:46 -0400
committerClar Charr <clar@charr.xyz>2018-06-01 17:46:19 -0400
commitb1797d57ffb42a063a8ecc8cc5f9d2b625708c72 (patch)
tree04d5c3ae0178ae48786ec51420c2ea78c5cedb90
parent7fe56e81b74e90b78d268e1749ee0de3e2ff54cd (diff)
downloadrust-b1797d57ffb42a063a8ecc8cc5f9d2b625708c72.tar.gz
rust-b1797d57ffb42a063a8ecc8cc5f9d2b625708c72.zip
Add @ithinuel's tests from #50597
-rw-r--r--src/libcore/tests/num/mod.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs
index f3439890fce..b5e6a019a22 100644
--- a/src/libcore/tests/num/mod.rs
+++ b/src/libcore/tests/num/mod.rs
@@ -134,6 +134,15 @@ fn test_infallible_try_from_int_error() {
 }
 
 macro_rules! test_impl_from {
+    ($fn_name:ident, bool, $target: ty) => {
+        #[test]
+        fn $fn_name() {
+            let one: $target = 1;
+            let zero: $target = 0;
+            assert_eq!(one, <$target>::from(true));
+            assert_eq!(zero, <$target>::from(false));
+        }
+    };
     ($fn_name: ident, $Small: ty, $Large: ty) => {
         #[test]
         fn $fn_name() {
@@ -173,6 +182,18 @@ test_impl_from! { test_u16i32, u16, i32 }
 test_impl_from! { test_u16i64, u16, i64 }
 test_impl_from! { test_u32i64, u32, i64 }
 
+// Bool -> Integer
+test_impl_from! { test_boolu8, bool, u8 }
+test_impl_from! { test_boolu16, bool, u16 }
+test_impl_from! { test_boolu32, bool, u32 }
+test_impl_from! { test_boolu64, bool, u64 }
+test_impl_from! { test_boolu128, bool, u128 }
+test_impl_from! { test_booli8, bool, i8 }
+test_impl_from! { test_booli16, bool, i16 }
+test_impl_from! { test_booli32, bool, i32 }
+test_impl_from! { test_booli64, bool, i64 }
+test_impl_from! { test_booli128, bool, i128 }
+
 // Signed -> Float
 test_impl_from! { test_i8f32, i8, f32 }
 test_impl_from! { test_i8f64, i8, f64 }