//! Returns the four `u64` limbs in big-endian order.
use super::U256;

impl U256 {
    /// Returns the four `u64` limbs in big-endian order.
    ///
    /// The returned array is `[w0, w1, w2, w3]` where `w0` is the most
    /// significant limb and `w3` is the least significant limb.
    ///
    /// # Examples
    ///
    /// ```
    /// use cnfy_uint::u256::U256;
    ///
    /// let v = U256::from_be_limbs([1, 2, 3, 4]);
    /// assert_eq!(v.to_be_limbs(), [1, 2, 3, 4]);
    /// ```
    #[inline]
    pub const fn to_be_limbs(&self) -> [u64; 4] {
        [self.0[3], self.0[2], self.0[1], self.0[0]]
    }
}

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

    /// Round-trip: from_be_limbs then to_be_limbs returns the original array.
    #[test]
    fn round_trip() {
        let arr = [0xA, 0xB, 0xC, 0xD];
        assert_eq!(U256::from_be_limbs(arr).to_be_limbs(), arr);
    }

    /// Zero round-trip.
    #[test]
    fn zero_round_trip() {
        assert_eq!(U256::ZERO.to_be_limbs(), [0; 4]);
    }
}
