Skip to content

Commit

Permalink
Made arrays with 32 elements or less never encode their length
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorKoenders committed Mar 30, 2023
1 parent 3431e6e commit 858d6d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions compatibility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ where
// This is what bincode 1 serializes to. This will be our comparison value.
let encoded = bincode_1_options.serialize(t).unwrap();

println!("Encoded {:?} as {:?}", t, encoded);
println!("Encoded {t:?} as {encoded:?}");

// Test bincode 2 encode
let bincode_2_output = bincode_2::encode_to_vec(t, bincode_2_config).unwrap();
assert_eq!(encoded, bincode_2_output, "{:?} serializes differently", t);
assert_eq!(
encoded,
bincode_2_output,
"{t:?} serializes differently\nbincode 2 config {:?}",
core::any::type_name::<C>(),
);

// Test bincode 2 serde serialize
let bincode_2_serde_output = bincode_2::serde::encode_to_vec(t, bincode_2_config).unwrap();
assert_eq!(
encoded, bincode_2_serde_output,
"{:?} serializes differently",
t
"{t:?} serializes differently"
);

// Test bincode 1 deserialize
Expand Down
1 change: 1 addition & 0 deletions compatibility/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
fn test() {
super::test_same((1,));
super::test_same(TupleS(2.0, 3.0, 4.0));
super::test_same([2.0, 3.0, 4.0]);
super::test_same(Option::<u32>::Some(5));
super::test_same(Option::<u32>::None);
super::test_same(Result::<u32, u8>::Ok(5));
Expand Down

0 comments on commit 858d6d3

Please sign in to comment.