From 4c8ae467eb56859583f599bd830bc22ef85a63c9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 5 Apr 2026 22:22:17 +0100 Subject: Add test for writing struct data values in patio-to-cranelift --- patio-to-cranelift/src/codegen/values.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/patio-to-cranelift/src/codegen/values.rs b/patio-to-cranelift/src/codegen/values.rs index 74eaa669..11983d3c 100644 --- a/patio-to-cranelift/src/codegen/values.rs +++ b/patio-to-cranelift/src/codegen/values.rs @@ -153,6 +153,23 @@ mod data_value_to_bytes_test { assert_eq!(bytes.as_ref(), &[0x78, 0x56, 0x34, 0x12]); } + + #[test] + fn struct_is_written_as_elements() { + let data_value = PatioDataValue::Struct { + elements: vec![ + PatioDataValue::Int32(PatioIntValue::Literal { value: 0x12345678 }), + PatioDataValue::Int32(PatioIntValue::Literal { value: 0x23456789 }), + ], + }; + + let bytes = data_value_to_bytes(data_value); + + assert_eq!( + bytes.as_ref(), + &[0x78, 0x56, 0x34, 0x12, 0x89, 0x67, 0x45, 0x23] + ); + } } #[cfg(test)] -- cgit v1.2.3