From c7d118c3edb95965bd4daad5c2478fb34e751008 Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Tue, 20 Jun 2023 17:24:05 -0700 Subject: [PATCH] serdect: test that no packing is happening for byte values --- serdect/tests/bincode.rs | 5 +++-- serdect/tests/cbor.rs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/serdect/tests/bincode.rs b/serdect/tests/bincode.rs index e4a39ccea..9b5035051 100644 --- a/serdect/tests/bincode.rs +++ b/serdect/tests/bincode.rs @@ -7,10 +7,11 @@ use proptest::{array::*, collection::vec, prelude::*}; use serdect::{array, slice}; /// Example input to be serialized. -const EXAMPLE_BYTES: [u8; 16] = hex!("000102030405060708090A0B0C0D0E0F"); +/// Last byte is `0xFF` to test that no packing is performed for values under 128. +const EXAMPLE_BYTES: [u8; 16] = hex!("000102030405060708090A0B0C0D0EFF"); /// bincode serialization of [`EXAMPLE_BYTES`] as a slice. -const BINCODE_SLICE: [u8; 24] = hex!("1000000000000000000102030405060708090A0B0C0D0E0F"); +const BINCODE_SLICE: [u8; 24] = hex!("1000000000000000000102030405060708090A0B0C0D0EFF"); /// bincode serialization of [`EXAMPLE_BYTES`] as an array. const BINCODE_ARRAY: [u8; 16] = EXAMPLE_BYTES; diff --git a/serdect/tests/cbor.rs b/serdect/tests/cbor.rs index a4173c69e..ea2d71ad7 100644 --- a/serdect/tests/cbor.rs +++ b/serdect/tests/cbor.rs @@ -9,15 +9,16 @@ use serde::Serialize; use serdect::{array, slice}; /// Example input to be serialized. -const EXAMPLE_BYTES: [u8; 16] = hex!("000102030405060708090A0B0C0D0E0F"); +/// Last byte is `0xFF` to test that no packing is performed for values under 128. +const EXAMPLE_BYTES: [u8; 16] = hex!("000102030405060708090A0B0C0D0EFF"); /// CBOR serialization of [`EXAMPLE_BYTES`] as a slice. /// (first three bits, `0b010` denote a byte string, and the last five, `0b10000` denote the length) -const CBOR_SLICE: [u8; 17] = hex!("50000102030405060708090A0B0C0D0E0F"); +const CBOR_SLICE: [u8; 17] = hex!("50000102030405060708090A0B0C0D0EFF"); /// CBOR serialization of [`EXAMPLE_BYTES`] as an array. /// (first three bits, `0b100` denote an array, and the last five, `0b10000` denote the length) -const CBOR_ARRAY: [u8; 17] = hex!("90000102030405060708090A0B0C0D0E0F"); +const CBOR_ARRAY: [u8; 17] = hex!("90000102030405060708090A0B0C0D0EFF"); #[test] fn deserialize_slice() {