]> git.lizzy.rs Git - rust.git/blobdiff - library/core/tests/num/int_log.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / library / core / tests / num / int_log.rs
index be203fb5c04ff00eb04757cec2448f43db1adf68..a1edb1a51863214bf9c12feb8e745ec12d74a5bb 100644 (file)
@@ -164,3 +164,33 @@ fn ilog10_u64() {
 fn ilog10_u128() {
     ilog10_loop! { u128, 38 }
 }
+
+#[test]
+#[should_panic(expected = "argument of integer logarithm must be positive")]
+fn ilog2_of_0_panic() {
+    let _ = 0u32.ilog2();
+}
+
+#[test]
+#[should_panic(expected = "argument of integer logarithm must be positive")]
+fn ilog10_of_0_panic() {
+    let _ = 0u32.ilog10();
+}
+
+#[test]
+#[should_panic(expected = "argument of integer logarithm must be positive")]
+fn ilog3_of_0_panic() {
+    let _ = 0u32.ilog(3);
+}
+
+#[test]
+#[should_panic(expected = "base of integer logarithm must be at least 2")]
+fn ilog0_of_1_panic() {
+    let _ = 1u32.ilog(0);
+}
+
+#[test]
+#[should_panic(expected = "base of integer logarithm must be at least 2")]
+fn ilog1_of_1_panic() {
+    let _ = 1u32.ilog(1);
+}