//! Constructor for [`U256Batch`].

use super::U256Batch;
use crate::u256::U256;

impl<const N: usize> U256Batch<N> {
    /// Creates a batch with all elements set to [`U256::ZERO`].
    ///
    /// Useful for initializing output buffers before a batch operation.
    /// All `N` elements are zero-initialized on the stack.
    ///
    /// # Examples
    ///
    /// ```
    /// use cnfy_uint::u256_batch::U256Batch;
    /// use cnfy_uint::u256::U256;
    ///
    /// let batch = U256Batch::<4>::zeroed();
    /// assert_eq!(batch.0[0], U256::ZERO);
    /// assert_eq!(batch.0[3], U256::ZERO);
    /// ```
    pub fn zeroed() -> Self {
        U256Batch([U256::ZERO; N])
    }
}

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

    /// All elements of a zeroed batch are U256::ZERO.
    #[test]
    fn zeroed_all_zero() {
        let batch = U256Batch::<8>::zeroed();
        for i in 0..8 {
            assert_eq!(batch.0[i], U256::ZERO, "element {i} not zero");
        }
    }

    /// Zeroed batch with N=0 produces an empty array.
    #[test]
    fn zeroed_empty() {
        let batch = U256Batch::<0>::zeroed();
        assert_eq!(batch.0.len(), 0);
    }

    /// Zeroed batch with N=1 produces a single zero element.
    #[test]
    fn zeroed_single() {
        let batch = U256Batch::<1>::zeroed();
        assert_eq!(batch.0[0], U256::ZERO);
    }
}
