diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-25 17:50:57 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-25 17:50:57 +0100 |
| commit | a5262342c470a20e80ff322859d806aa486acda1 (patch) | |
| tree | f32cb313ff1c8084ee4ca1fe7c05ce8e70b7ecc9 /examples/11-transient-0/output | |
| parent | 71f24eac2de498b76994d901092c56bbfca5a067 (diff) | |
Test struct with different shared types in rust-transient-0
Diffstat (limited to 'examples/11-transient-0/output')
| -rw-r--r-- | examples/11-transient-0/output/rust/src/lib.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/11-transient-0/output/rust/src/lib.rs b/examples/11-transient-0/output/rust/src/lib.rs index 4b346a5..a1f77c9 100644 --- a/examples/11-transient-0/output/rust/src/lib.rs +++ b/examples/11-transient-0/output/rust/src/lib.rs @@ -5,7 +5,7 @@ pub mod transient_0; mod test { use std::io::Cursor; use std::sync::Arc; - use super::data::{EnumWithVariants, StructWithBool, StructWithEnum, StructWithInt32, StructWithInt64, StructWithList, StructWithListOfShared, StructWithOption, StructWithString, StructWithStruct, StructWithSum, SumWithVariants, VariantOne, VariantTwo }; + use super::data::{EnumWithVariants, StructWithBool, StructWithDifferentSharedTypes, StructWithEnum, StructWithInt32, StructWithInt64, StructWithList, StructWithListOfShared, StructWithOption, StructWithString, StructWithStruct, StructWithSum, SumWithVariants, VariantOne, VariantTwo }; #[test] fn struct_with_bool() { @@ -184,6 +184,21 @@ mod test { ); } + #[test] + fn struct_with_different_shared_types() { + let a = Arc::new(StructWithInt32 { a: 10, b: 25 }); + let b = Arc::new(StructWithInt64 { a: 42, b: 47 }); + let c = Arc::new(StructWithInt32 { a: 52, b: 57 }); + + let value = StructWithDifferentSharedTypes { a, b, c }; + + assert_round_trip_encoding( + value, + super::data::transient_0::encode_struct_with_different_shared_types, + super::data::transient_0::decode_struct_with_different_shared_types, + ); + } + fn assert_round_trip_encoding<T: std::cmp::PartialEq + std::fmt::Debug>( value: T, encode: impl Fn(&T, &mut Cursor<Vec<u8>>) -> std::io::Result<()>, |
