diff options
| author | Lukas Markeffsky <@> | 2022-10-02 14:25:36 +0200 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2022-10-02 14:25:36 +0200 |
| commit | 6acc29f88b2fdf7a048fae77b031b803f86e1551 (patch) | |
| tree | b17663d21ff68eacddf489ce69fd6a9ace2e201d | |
| parent | 69cafc069900905b2b48661dd013ade13186345e (diff) | |
| download | rust-6acc29f88b2fdf7a048fae77b031b803f86e1551.tar.gz rust-6acc29f88b2fdf7a048fae77b031b803f86e1551.zip | |
add tests for panicking integer logarithms
| -rw-r--r-- | library/core/tests/num/int_log.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/library/core/tests/num/int_log.rs b/library/core/tests/num/int_log.rs index be203fb5c04..a1edb1a5186 100644 --- a/library/core/tests/num/int_log.rs +++ b/library/core/tests/num/int_log.rs @@ -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); +} |
