miden-protocol-macros 0.14.5

Procedural macros for Miden protocol
Documentation
#[cfg(test)]
mod tests {
    use miden_protocol::{Felt, Word};
    use miden_protocol_macros::WordWrapper;

    #[derive(Debug, Clone, Copy, PartialEq, Eq, WordWrapper)]
    pub struct TestId(Word);

    #[test]
    fn test_word_wrapper_accessors() {
        // Create a test Word
        let word = Word::from([Felt::ONE, Felt::ONE, Felt::ZERO, Felt::ZERO]);
        // Use the new_unchecked method generated by the macro
        let test_id = TestId::from_raw(word);

        // Test as_elements
        let elements = test_id.as_elements();
        assert_eq!(elements.len(), 4);
        assert_eq!(elements[0], Felt::ONE);
        assert_eq!(elements[1], Felt::ONE);

        // Test as_bytes
        let bytes = test_id.as_bytes();
        assert_eq!(bytes.len(), 32);

        // Test to_hex
        let hex = test_id.to_hex();
        assert!(!hex.is_empty());

        // Test as_word
        let retrieved_word = test_id.as_word();
        assert_eq!(retrieved_word, word);
    }

    #[test]
    fn test_new_unchecked_is_generated() {
        // This test verifies that new_unchecked is generated by the macro
        let word = Word::from([Felt::ONE, Felt::ONE, Felt::ZERO, Felt::ZERO]);
        let test_id = TestId::from_raw(word);
        assert_eq!(test_id.as_word(), word);
    }
}