rusticl: add a bunch of trivial tests
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35188>
This commit is contained in:
Karol Herbst 2025-09-09 02:46:57 +02:00 committed by Marge Bot
parent ccf099d0d1
commit dcfa4fafca
2 changed files with 17 additions and 0 deletions

View file

@ -7,3 +7,13 @@ pub fn test_bit(bitset: &[u32], bit: u32) -> bool {
bitset[idx as usize] & (1 << test) != 0
}
#[test]
fn test_test_bit() {
let data = [0x3254424d, 0xffffffff, 0x00000001];
assert!(test_bit(&data, 0));
assert!(!test_bit(&data, 5));
assert!(test_bit(&data, 64));
assert!(!test_bit(&data, 65));
}

View file

@ -18,6 +18,13 @@ where
b
}
#[test]
fn gcd_test() {
assert_eq!(gcd(5, 15), 5);
assert_eq!(gcd(7, 15), 1);
assert_eq!(gcd(60, 45), 15);
}
pub struct SetBitIndices<T> {
val: T,
}