use crate::int::algos::support::limbs::cmp_fixed;
use crate::int::types::Int;
#[inline]
pub(crate) const fn eq_limbwise<const N: usize>(a: Int<N>, b: Int<N>) -> bool {
cmp_fixed(a.as_limbs(), b.as_limbs()) == 0
}
#[cfg(test)]
mod tests {
use super::eq_limbwise;
use crate::int::types::Int;
#[test]
fn eq_same_value() {
let a = Int::<1>::from_i64(42);
let b = Int::<1>::from_i64(42);
assert!(eq_limbwise(a, b));
}
#[test]
fn eq_different_values() {
let a = Int::<1>::from_i64(1);
let b = Int::<1>::from_i64(2);
assert!(!eq_limbwise(a, b));
}
#[test]
fn eq_zeros() {
let z1 = Int::<2>::from_i64(0);
let z2 = Int::<2>::from_i64(0);
assert!(eq_limbwise(z1, z2));
}
#[test]
fn eq_pos_vs_neg_not_equal() {
let a = Int::<1>::from_i64(7);
let b = Int::<1>::from_i64(-7);
assert!(!eq_limbwise(a, b));
}
#[test]
fn eq_multi_limb_large_value() {
let v = Int::<2>::from_u128(u128::MAX);
assert!(eq_limbwise(v, v));
}
#[test]
fn eq_multi_limb_differ_high_limb() {
let a = Int::<2>::from_u128(1_u128 << 64); let b = Int::<2>::from_u128(2_u128 << 64); assert!(!eq_limbwise(a, b));
}
#[test]
fn eq_three_limb_equal() {
let a = Int::<3>::from_i128(i128::MIN);
let b = Int::<3>::from_i128(i128::MIN);
assert!(eq_limbwise(a, b));
}
}