Rust · 1001 bytes Raw Blame History
1 //! Two byte slices that differ in a non-tolerated region must surface as
2 //! critical diffs. Proves the harness actually notices regressions — otherwise
3 //! every later differential test becomes a silent false-negative generator.
4
5 mod common;
6
7 use common::harness::diff_macho;
8
9 #[test]
10 fn differing_bytes_surface_as_critical() {
11 let ours = b"hello world".to_vec();
12 let mut theirs = ours.clone();
13 theirs[6] = b'W'; // capitalize the W in "world"
14
15 let report = diff_macho(&ours, &theirs);
16 assert!(!report.is_clean(), "harness missed a real byte difference");
17 assert_eq!(report.critical.len(), 1);
18 let chunk = &report.critical[0];
19 assert_eq!(chunk.offset, 6);
20 assert_eq!(chunk.len, 1);
21 }
22
23 #[test]
24 fn size_mismatch_is_critical() {
25 let ours = b"short".to_vec();
26 let theirs = b"considerably longer bytes".to_vec();
27 let report = diff_macho(&ours, &theirs);
28 assert!(!report.is_clean());
29 assert!(report.critical[0].reason.contains("size differs"));
30 }
31