diff --git a/lib-bms-protocol/src/types.rs b/lib-bms-protocol/src/types.rs index df944a9..c9c325e 100644 --- a/lib-bms-protocol/src/types.rs +++ b/lib-bms-protocol/src/types.rs @@ -343,4 +343,14 @@ mod base_type_tests { assert_eq!(invalid_hemming^hc, hemming); } } + + #[test] + fn hemming_dual_bit_error_detection() { + let data = 0x123456; + let hemming = calc_hemming(data); + let bit_error = 0x101; + let correction = check_hemming(data ^ bit_error, hemming).unwrap_err(); + let (dc, hc) = correction.calc_correction_data(); + assert!(check_hemming(data ^ dc, hemming ^ hc).is_err()) + } }