aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-04-05 22:22:17 +0100
committerMichael Williamson <mike@zwobble.org>2026-04-05 22:22:17 +0100
commit4c8ae467eb56859583f599bd830bc22ef85a63c9 (patch)
tree69a6f3ed931fb6608f7018f348037c5ced9dbf55
parentd6b32251f9f607780df1cb25069785da4a634e71 (diff)
Add test for writing struct data values in patio-to-cranelift
-rw-r--r--patio-to-cranelift/src/codegen/values.rs17
1 files changed, 17 insertions, 0 deletions
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)]