File: mod.rs

package info (click to toggle)
rust-etherparse 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,464 kB
  • sloc: sh: 68; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 632 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::*;
use proptest::prelude::*;

proptest! {
    #[test]
    fn u32_u16_comparison(
        data in proptest::collection::vec(any::<u8>(), 0..0xfffusize)
    ) {
        use super::etherparse::checksum::*;

        let u32_oc = u32_16bit_word::ones_complement(
            u32_16bit_word::add_slice(0, &data)
        );
        let u64_oc = u64_16bit_word::ones_complement(
            u64_16bit_word::add_slice(0, &data)
        );
        assert_eq!(u32_oc, u64_oc);

        let struct_oc = Sum16BitWords::new()
            .add_slice(&data)
            .ones_complement();
        assert_eq!(u32_oc, struct_oc);
    }
}