cuprate/net/epee-encoding/tests/duplicate_key.rs
hinto-janai 57af45e01d
Some checks are pending
Audit / audit (push) Waiting to run
CI / fmt (push) Waiting to run
CI / typo (push) Waiting to run
CI / ci (macos-latest, stable, bash) (push) Waiting to run
CI / ci (ubuntu-latest, stable, bash) (push) Waiting to run
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Waiting to run
Deny / audit (push) Waiting to run
Doc / build (push) Waiting to run
Doc / deploy (push) Blocked by required conditions
epee-encoding: enable workspace lints (#294)
* epee-encoding: enable workspace lints

* fmt

* fixes

* fixes

* fmt
2024-09-20 15:13:55 +01:00

41 lines
737 B
Rust

#![expect(unused_crate_dependencies, reason = "outer test module")]
use cuprate_epee_encoding::{epee_object, from_bytes};
struct T {
a: u8,
}
epee_object!(
T,
a: u8,
);
struct T2 {
a: u8,
}
epee_object!(
T2,
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,
];
assert!(from_bytes::<T, _>(&mut &data[..]).is_err());
}
#[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,
];
assert!(from_bytes::<T2, _>(&mut &data[..]).is_err());
}