| 1 |
use super::*; |
| 2 |
|
| 3 |
#[test] |
| 4 |
fn test_bit_zero_high_index_u32() { |
| 5 |
assert_eq!(bit_zero_high_index_u32(0b1111, 0), 0b0000); |
| 6 |
assert_eq!(bit_zero_high_index_u32(0b1111, 1), 0b0001); |
| 7 |
assert_eq!(bit_zero_high_index_u32(0b1111, 2), 0b0011); |
| 8 |
assert_eq!(bit_zero_high_index_u32(0b1111, 3), 0b0111); |
| 9 |
} |
| 10 |
|
| 11 |
#[test] |
| 12 |
#[cfg(target_arch = "x86_64")] |
| 13 |
fn test_bit_zero_high_index_u64() { |
| 14 |
assert_eq!(bit_zero_high_index_u64(0b1111, 0), 0b0000); |
| 15 |
assert_eq!(bit_zero_high_index_u64(0b1111, 1), 0b0001); |
| 16 |
assert_eq!(bit_zero_high_index_u64(0b1111, 2), 0b0011); |
| 17 |
assert_eq!(bit_zero_high_index_u64(0b1111, 3), 0b0111); |
| 18 |
} |
| 19 |
|
| 20 |
#[test] |
| 21 |
fn test_mul_extended_u32() { |
| 22 |
let mut x = 0_u32; |
| 23 |
assert_eq!(mul_extended_u32(u32::MAX, 17, &mut x), 4294967279); |
| 24 |
assert_eq!(x, 16); |
| 25 |
} |
| 26 |
|
| 27 |
#[test] |
| 28 |
#[cfg(target_arch = "x86_64")] |
| 29 |
fn test_mul_extended_u64() { |
| 30 |
let mut x = 0_u64; |
| 31 |
assert_eq!(mul_extended_u64(u64::MAX, 17, &mut x), 18446744073709551599); |
| 32 |
assert_eq!(x, 16); |
| 33 |
} |
| 34 |
|
| 35 |
#[test] |
| 36 |
fn test_population_deposit_u32() { |
| 37 |
assert_eq!(population_deposit_u32(0b1001, 0b1111), 0b1001); |
| 38 |
assert_eq!(population_deposit_u32(0b1001, 0b1110), 0b0010); |
| 39 |
assert_eq!(population_deposit_u32(0b1001, 0b1100), 0b0100); |
| 40 |
} |
| 41 |
|
| 42 |
#[test] |
| 43 |
#[cfg(target_arch = "x86_64")] |
| 44 |
fn test_population_deposit_u64() { |
| 45 |
assert_eq!(population_deposit_u64(0b1001, 0b1111), 0b1001); |
| 46 |
assert_eq!(population_deposit_u64(0b1001, 0b1110), 0b0010); |
| 47 |
assert_eq!(population_deposit_u64(0b1001, 0b1100), 0b0100); |
| 48 |
} |
| 49 |
|
| 50 |
#[test] |
| 51 |
fn test_population_extract_u32() { |
| 52 |
assert_eq!(population_extract_u32(0b1001, 0b1111), 0b1001); |
| 53 |
assert_eq!(population_extract_u32(0b1001, 0b1110), 0b0100); |
| 54 |
assert_eq!(population_extract_u32(0b1001, 0b1100), 0b0010); |
| 55 |
} |
| 56 |
|
| 57 |
#[test] |
| 58 |
#[cfg(target_arch = "x86_64")] |
| 59 |
fn test_population_extract_u64() { |
| 60 |
assert_eq!(population_extract_u64(0b1001, 0b1111), 0b1001); |
| 61 |
assert_eq!(population_extract_u64(0b1001, 0b1110), 0b0100); |
| 62 |
assert_eq!(population_extract_u64(0b1001, 0b1100), 0b0010); |
| 63 |
} |