mod shared;
use shared::assert_streamed_eq;
use data_stream::{default_settings::PortableSettings, from_stream, to_stream};
#[test]
fn fixed_array_roundtrip_u32() {
assert_streamed_eq::<PortableSettings, _>(&[1u32, 2, 3, 4]);
}
#[test]
fn fixed_array_roundtrip_empty() {
assert_streamed_eq::<PortableSettings, _>(&[0u32; 0]);
}
#[test]
fn fixed_array_deserialize_from_too_short_stream_fails() {
let bytes = [1u8, 0, 0, 0]; let result = from_stream::<PortableSettings, [u32; 2], _>(&mut &bytes[..]);
assert!(result.is_err());
}
#[test]
fn slice_and_vec_have_same_encoding() {
let arr = [10u32, 20, 30];
let vec = vec![10u32, 20, 30];
let mut a = Vec::new();
let mut b = Vec::new();
to_stream::<PortableSettings, _, _>(&arr[..], &mut a).unwrap();
to_stream::<PortableSettings, _, _>(&vec, &mut b).unwrap();
assert_eq!(a, b);
}