use proptest::prelude::*;
use weir::oracle::summary::range_check as cpu_ref;
proptest! {
#![proptest_config(ProptestConfig::with_cases(10_000))]
#[test]
fn elementwise_strict_less_than(
hi in proptest::collection::vec(any::<u32>(), 0..32),
bnd in proptest::collection::vec(any::<u32>(), 0..32),
) {
let out = cpu_ref(&hi, &bnd);
let n = hi.len().min(bnd.len());
prop_assert_eq!(out.len(), n);
for i in 0..n {
let expected = u32::from(hi[i] < bnd[i]);
prop_assert_eq!(out[i], expected, "i={}: hi={} bnd={}", i, hi[i], bnd[i]);
}
}
#[test]
fn truncates_to_shorter_input(
hi in proptest::collection::vec(any::<u32>(), 0..16),
bnd in proptest::collection::vec(any::<u32>(), 0..16),
) {
let out = cpu_ref(&hi, &bnd);
prop_assert!(out.len() <= hi.len());
prop_assert!(out.len() <= bnd.len());
prop_assert_eq!(out.len(), hi.len().min(bnd.len()));
}
#[test]
fn zero_bound_yields_all_zero(
hi in proptest::collection::vec(any::<u32>(), 1..32),
) {
let zero = vec![0u32; hi.len()];
let out = cpu_ref(&hi, &zero);
prop_assert!(out.iter().all(|&w| w == 0));
}
#[test]
fn zero_hi_with_positive_bound_yields_one(
bnd in proptest::collection::vec(1u32..u32::MAX, 1..16),
) {
let zero = vec![0u32; bnd.len()];
let out = cpu_ref(&zero, &bnd);
prop_assert!(out.iter().all(|&w| w == 1));
}
#[test]
fn output_is_bool_indicator(
hi in proptest::collection::vec(any::<u32>(), 0..32),
bnd in proptest::collection::vec(any::<u32>(), 0..32),
) {
let out = cpu_ref(&hi, &bnd);
for &w in &out {
prop_assert!(w == 0 || w == 1, "non-boolean output: {}", w);
}
}
}