2024-06-24 01:30:47 +00:00
|
|
|
use cuprate_epee_encoding::{epee_object, from_bytes};
|
2024-01-29 22:32:16 +00:00
|
|
|
|
|
|
|
struct T {
|
|
|
|
a: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
epee_object!(
|
|
|
|
T,
|
|
|
|
a: u8,
|
|
|
|
);
|
|
|
|
|
2024-09-02 17:10:45 +00:00
|
|
|
struct T2 {
|
2024-01-29 22:32:16 +00:00
|
|
|
a: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
epee_object!(
|
2024-09-02 17:10:45 +00:00
|
|
|
T2,
|
2024-01-29 22:32:16 +00:00
|
|
|
a: u8 = 0,
|
|
|
|
);
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn duplicate_key() {
|
|
|
|
let data = [
|
|
|
|
0x01, 0x11, 0x01, 0x1, 0x01, 0x01, 0x02, 0x1, 0x1, 0x08, 0x01, b'a', 0x0B, 0x00, 0x01,
|
|
|
|
b'a', 0x0B, 0x00,
|
|
|
|
];
|
|
|
|
|
2024-01-30 16:09:54 +00:00
|
|
|
assert!(from_bytes::<T, _>(&mut &data[..]).is_err());
|
2024-01-29 22:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn duplicate_key_with_default() {
|
|
|
|
let data = [
|
|
|
|
0x01, 0x11, 0x01, 0x1, 0x01, 0x01, 0x02, 0x1, 0x1, 0x08, 0x01, b'a', 0x0B, 0x00, 0x01,
|
|
|
|
b'a', 0x0B, 0x00,
|
|
|
|
];
|
|
|
|
|
2024-09-02 17:10:45 +00:00
|
|
|
assert!(from_bytes::<T2, _>(&mut &data[..]).is_err());
|
2024-01-29 22:32:16 +00:00
|
|
|
}
|