| 892 | |
| 893 | #[test] |
| 894 | fn test_unified_diff_line_numbers() { |
| 895 | let old = b"a\nb\nc\n"; |
| 896 | let new = b"a\nx\nc\n"; |
| 897 | let diff = UnifiedDiff::new(old, new, Algorithm::Myers); |
| 898 | |
| 899 | let lines: Vec<_> = diff.lines().collect(); |
| 900 | |
| 901 | // First line: unchanged, old=1, new=1 |
| 902 | assert_eq!(lines[0].old_line_num, Some(1)); |
| 903 | assert_eq!(lines[0].new_line_num, Some(1)); |
| 904 | |
| 905 | // Second line: removed, old=2, new=None |
| 906 | assert_eq!(lines[1].old_line_num, Some(2)); |
| 907 | assert_eq!(lines[1].new_line_num, None); |
| 908 | |
| 909 | // Third line: added, old=None, new=2 |
| 910 | assert_eq!(lines[2].old_line_num, None); |
| 911 | assert_eq!(lines[2].new_line_num, Some(2)); |
| 912 | |
| 913 | // Fourth line: unchanged, old=3, new=3 |
| 914 | assert_eq!(lines[3].old_line_num, Some(3)); |
| 915 | assert_eq!(lines[3].new_line_num, Some(3)); |
| 916 | } |
| 917 | |
| 918 | #[test] |
| 919 | fn test_side_by_side_identical() { |