add tests for panicking integer logarithms

This commit is contained in:
Lukas Markeffsky 2022-10-02 14:25:36 +02:00
parent 69cafc0699
commit 6acc29f88b
1 changed files with 30 additions and 0 deletions

View 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);
}