//! Zero-value predicate for [`U384`].
use super::U384;

impl U384 {
    /// Returns `true` if all six limbs are zero.
    ///
    /// # Examples
    ///
    /// ```
    /// use cnfy_uint::u384::U384;
    ///
    /// assert!(U384::ZERO.is_zero());
    /// assert!(!U384::ONE.is_zero());
    /// ```
    #[inline]
    pub const fn is_zero(&self) -> bool {
        self.0[0] == 0
            && self.0[1] == 0
            && self.0[2] == 0
            && self.0[3] == 0
            && self.0[4] == 0
            && self.0[5] == 0
    }
}

#[cfg(test)]
mod ai_tests {
    use super::*;

    /// Zero is zero.
    #[test]
    fn zero() {
        assert!(U384::ZERO.is_zero());
    }

    /// One is not zero.
    #[test]
    fn one() {
        assert!(!U384::ONE.is_zero());
    }

    /// MAX is not zero.
    #[test]
    fn max() {
        assert!(!U384::MAX.is_zero());
    }

    /// Any single non-zero limb makes it non-zero.
    #[test]
    fn single_nonzero_limb() {
        for i in 0..6 {
            let mut limbs = [0u64; 6];
            limbs[i] = 1;
            assert!(!U384::from_be_limbs(limbs).is_zero());
        }
    }
}
