diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-07 05:48:48 +0000 |
commit | ef24de24a82fe681581cc130f342363c47c0969a (patch) | |
tree | 0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/zerovec/src/samples.rs | |
parent | Releasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip |
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/zerovec/src/samples.rs')
-rw-r--r-- | vendor/zerovec/src/samples.rs | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/vendor/zerovec/src/samples.rs b/vendor/zerovec/src/samples.rs index 7a9a73241..723aacded 100644 --- a/vendor/zerovec/src/samples.rs +++ b/vendor/zerovec/src/samples.rs @@ -44,9 +44,31 @@ pub const BINCODE_BUF: &[u8] = &[ 0, 72, 73, 74, 0, 76, 77, 78, 0, ]; -/// Representation of a VarZeroVec<str> of length 4 as bytes. -/// Safety: The bytes were manually verified to be valid. +/// Representation of a VarZeroVec<str> with contents ["w", "ω", "文", "𑄃"] pub const TEST_VARZEROSLICE_BYTES: &[u8] = &[ - 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 6, 0, 0, 0, 119, 207, 137, 230, 150, 135, 240, - 145, 132, 131, + 4, 0, 0, 0, 0, 0, 1, 0, 3, 0, 6, 0, 119, 207, 137, 230, 150, 135, 240, 145, 132, 131, ]; + +#[test] +fn validate() { + use crate::{VarZeroVec, ZeroVec}; + + assert_eq!( + ZeroVec::<u32>::parse_byte_slice(TEST_BUFFER_LE).unwrap(), + ZeroVec::alloc_from_slice(TEST_SLICE) + ); + + assert_eq!(TEST_SLICE.iter().sum::<u32>(), TEST_SUM); + + assert_eq!( + serde_json::from_str::<ZeroVec::<u32>>(JSON_STR).unwrap(), + ZeroVec::alloc_from_slice(TEST_SLICE) + ); + + assert_eq!( + bincode::deserialize::<ZeroVec::<u32>>(BINCODE_BUF).unwrap(), + ZeroVec::alloc_from_slice(TEST_SLICE) + ); + + VarZeroVec::<str>::parse_byte_slice(TEST_VARZEROSLICE_BYTES).unwrap(); +} |