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
30
31
32
33
34
mod encode;
mod decode;
pub use decode::*;
pub use encode::*;
#[cfg(test)]
mod tests {
#[test]
fn encode_decode() {
let data = vec![
(1u8, "one".as_bytes().to_vec()),
(2u8, "two".as_bytes().to_vec()),
(3u8, "three".as_bytes().to_vec()),
(1u8, "😀"
.as_bytes().to_vec()),
(255u8,
"This is a very long message to see how well it works.
😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈👌👌😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈😈
Yay!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".as_bytes().to_vec()),
(5u8, vec![46u8, 134u8, 67u8, 9u8]),
];
let original = data.clone();
let encoded = crate::encode(data).unwrap();
println!("{:?}", encoded);
assert_eq!(crate::decode(encoded).unwrap(), original);
}
}