File: array.rs

package info (click to toggle)
rust-rmp 0.8.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 396 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use rmp::encode::*;
use rmp::Marker;

#[test]
fn pass_pack_len_fix() {
    let mut buf = [0x00];

    assert_eq!(Marker::FixArray(15), write_array_len(&mut &mut buf[..], 15).unwrap());

    assert_eq!([0x9f], buf);
}

#[test]
fn pass_pack_len_u16() {
    let mut buf = [0x00, 0x00, 0x00];

    assert_eq!(Marker::Array16, write_array_len(&mut &mut buf[..], 65535).unwrap());

    assert_eq!([0xdc, 0xff, 0xff], buf);
}

#[test]
fn pass_pack_len_u32() {
    let mut buf = [0x00, 0x00, 0x00, 0x00, 0x00];

    assert_eq!(Marker::Array32, write_array_len(&mut &mut buf[..], 4294967295).unwrap());

    assert_eq!([0xdd, 0xff, 0xff, 0xff, 0xff], buf);
}