1
0
Fork 0
firefox/third_party/rust/rmp/tests/func/encode/string.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

38 lines
820 B
Rust

use rmp::encode::*;
use rmp::Marker;
#[test]
fn pass_pack_len_fix() {
let mut buf = [0x00];
assert_eq!(Marker::FixStr(31), write_str_len(&mut &mut buf[..], 31).unwrap());
assert_eq!([0xbf], buf);
}
#[test]
fn pass_pack_len_u8() {
let mut buf = [0x00, 0x00];
assert_eq!(Marker::Str8, write_str_len(&mut &mut buf[..], 255).unwrap());
assert_eq!([0xd9, 0xff], buf);
}
#[test]
fn pass_pack_len_u16() {
let mut buf = [0x00, 0x00, 0x00];
assert_eq!(Marker::Str16, write_str_len(&mut &mut buf[..], 65535).unwrap());
assert_eq!([0xda, 0xff, 0xff], buf);
}
#[test]
fn pass_pack_len_u32() {
let mut buf = [0x00, 0x00, 0x00, 0x00, 0x00];
assert_eq!(Marker::Str32, write_str_len(&mut &mut buf[..], 4294967295).unwrap());
assert_eq!([0xdb, 0xff, 0xff, 0xff, 0xff], buf);
}