pub use fake_identity_unary::fake_identity_unary;
use crate::properties::tests::{pair, primitive, result_u32, unary};
use crate::spec::law::AlgebraicLaw;
#[inline]
pub fn fake_identity_unary(input: &[u8]) -> Vec<u8> {
input[..4].to_vec()
}
#[inline]
pub fn verify_absorbing(spec: &crate::spec::types::OpSpec, element: u32) {
for a in SAMPLE {
let lhs = call_u32(spec, &pair(a, element));
assert_eq!(
lhs, element,
"{} violates Absorbing({element}) right at {a}",
spec.id
);
let rhs = call_u32(spec, &pair(element, a));
assert_eq!(
rhs, element,
"{} violates Absorbing({element}) left at {a}",
spec.id
);
}
}
#[inline]
pub fn verify_idempotent(spec: &crate::spec::types::OpSpec) {
for a in SAMPLE {
let val = call_u32(spec, &pair(a, a));
assert_eq!(val, a, "{} violates Idempotent at {a}", spec.id);
}
}
#[inline]
pub fn verify_identity(spec: &crate::spec::types::OpSpec, element: u32) {
for a in SAMPLE {
let lhs = call_u32(spec, &pair(a, element));
assert_eq!(
lhs, a,
"{} violates Identity({element}) right at {a}",
spec.id
);
let rhs = call_u32(spec, &pair(element, a));
assert_eq!(
rhs, a,
"{} violates Identity({element}) left at {a}",
spec.id
);
}
}
#[inline]
pub fn verify_involution(spec: &crate::spec::types::OpSpec) {
for a in SAMPLE {
let once = call_u32(spec, &unary(a));
let twice = call_u32(spec, &unary(once));
assert_eq!(twice, a, "{} violates Involution at {a}", spec.id);
}
}
#[inline]
pub fn verify_self_inverse(spec: &crate::spec::types::OpSpec, result: u32) {
for a in SAMPLE {
let val = call_u32(spec, &pair(a, a));
assert_eq!(
val, result,
"{} violates SelfInverse({result}) at {a}",
spec.id
);
}
}