| 1 | use super::*; |
| 2 | |
| 3 | macro_rules! diff_list { |
| 4 | () => { |
| 5 | Solution { |
| 6 | text1: Range::empty(), |
| 7 | text2: Range::empty(), |
| 8 | diffs: Vec::new(), |
| 9 | utf8: true, |
| 10 | } |
| 11 | }; |
| 12 | ($($kind:ident($text:literal)),+ $(,)?) => {{ |
| 13 | macro_rules! text1 { |
| 14 | (Insert, $s:literal) => { "" }; |
| 15 | (Delete, $s:literal) => { $s }; |
| 16 | (Equal, $s:literal) => { $s }; |
| 17 | } |
| 18 | macro_rules! text2 { |
| 19 | (Insert, $s:literal) => { $s }; |
| 20 | (Delete, $s:literal) => { "" }; |
| 21 | (Equal, $s:literal) => { $s }; |
| 22 | } |
| 23 | let text1 = concat!($(text1!($kind, $text)),*); |
| 24 | let text2 = concat!($(text2!($kind, $text)),*); |
| 25 | let (_i, _j) = (&mut 0, &mut 0); |
| 26 | macro_rules! range { |
| 27 | (Insert, $s:literal) => { |
| 28 | Diff::Insert(range(text2, _j, $s)) |
| 29 | }; |
| 30 | (Delete, $s:literal) => { |
| 31 | Diff::Delete(range(text1, _i, $s)) |
| 32 | }; |
| 33 | (Equal, $s:literal) => { |
| 34 | Diff::Equal(range(text1, _i, $s), range(text2, _j, $s)) |
| 35 | }; |
| 36 | } |
| 37 | Solution { |
| 38 | text1: Range::new(text1, ..), |
| 39 | text2: Range::new(text2, ..), |
| 40 | diffs: vec![$(range!($kind, $text)),*], |
| 41 | utf8: true, |
| 42 | } |
| 43 | }}; |
| 44 | } |
| 45 | |
| 46 | fn range<'a>(doc: &'a str, offset: &mut usize, text: &str) -> Range<'a> { |
| 47 | let range = Range { |
| 48 | doc, |
| 49 | offset: *offset, |
| 50 | len: text.len(), |
| 51 | }; |
| 52 | *offset += text.len(); |
| 53 | range |
| 54 | } |
| 55 | |
| 56 | macro_rules! assert_diffs { |
| 57 | ([$($kind:ident($text:literal)),* $(,)?], $solution:ident, $msg:expr $(,)?) => { |
| 58 | let expected = &[$(Chunk::$kind($text)),*]; |
| 59 | assert!( |
| 60 | same_diffs(expected, &$solution.diffs), |
| 61 | concat!($msg, "\nexpected={:#?}\nactual={:#?}"), |
| 62 | expected, $solution.diffs, |
| 63 | ); |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | fn same_diffs(expected: &[Chunk], actual: &[Diff]) -> bool { |
| 68 | expected.len() == actual.len() |
| 69 | && expected.iter().zip(actual).all(|pair| match pair { |
| 70 | (Chunk::Insert(expected), Diff::Insert(actual)) => *expected == str(*actual), |
| 71 | (Chunk::Delete(expected), Diff::Delete(actual)) => *expected == str(*actual), |
| 72 | (Chunk::Equal(expected), Diff::Equal(actual1, actual2)) => { |
| 73 | *expected == str(*actual1) && *expected == str(*actual2) |
| 74 | } |
| 75 | (_, _) => false, |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | #[test] |
| 80 | fn test_common_prefix() { |
| 81 | let text1 = Range::new("abc", ..); |
| 82 | let text2 = Range::new("xyz", ..); |
| 83 | assert_eq!(0, common_prefix_bytes(text1, text2), "Null case"); |
| 84 | |
| 85 | let text1 = Range::new("1234abcdef", ..); |
| 86 | let text2 = Range::new("1234xyz", ..); |
| 87 | assert_eq!(4, common_prefix_bytes(text1, text2), "Non-null case"); |
| 88 | |
| 89 | let text1 = Range::new("1234", ..); |
| 90 | let text2 = Range::new("1234xyz", ..); |
| 91 | assert_eq!(4, common_prefix_bytes(text1, text2), "Whole case"); |
| 92 | } |
| 93 | |
| 94 | #[test] |
| 95 | fn test_common_suffix() { |
| 96 | let text1 = Range::new("abc", ..); |
| 97 | let text2 = Range::new("xyz", ..); |
| 98 | assert_eq!(0, common_suffix(text1, text2), "Null case"); |
| 99 | assert_eq!(0, common_suffix_bytes(text1, text2), "Null case"); |
| 100 | |
| 101 | let text1 = Range::new("abcdef1234", ..); |
| 102 | let text2 = Range::new("xyz1234", ..); |
| 103 | assert_eq!(4, common_suffix(text1, text2), "Non-null case"); |
| 104 | assert_eq!(4, common_suffix_bytes(text1, text2), "Non-null case"); |
| 105 | |
| 106 | let text1 = Range::new("1234", ..); |
| 107 | let text2 = Range::new("xyz1234", ..); |
| 108 | assert_eq!(4, common_suffix(text1, text2), "Whole case"); |
| 109 | assert_eq!(4, common_suffix_bytes(text1, text2), "Whole case"); |
| 110 | } |
| 111 | |
| 112 | #[test] |
| 113 | fn test_common_overlap() { |
| 114 | let text1 = Range::empty(); |
| 115 | let text2 = Range::new("abcd", ..); |
| 116 | assert_eq!(0, common_overlap(text1, text2), "Null case"); |
| 117 | |
| 118 | let text1 = Range::new("abc", ..); |
| 119 | let text2 = Range::new("abcd", ..); |
| 120 | assert_eq!(3, common_overlap(text1, text2), "Whole case"); |
| 121 | |
| 122 | let text1 = Range::new("123456", ..); |
| 123 | let text2 = Range::new("abcd", ..); |
| 124 | assert_eq!(0, common_overlap(text1, text2), "No overlap"); |
| 125 | |
| 126 | let text1 = Range::new("123456xxx", ..); |
| 127 | let text2 = Range::new("xxxabcd", ..); |
| 128 | assert_eq!(3, common_overlap(text1, text2), "Overlap"); |
| 129 | |
| 130 | // Some overly clever languages (C#) may treat ligatures as equal to their |
| 131 | // component letters. E.g. U+FB01 == 'fi' |
| 132 | let text1 = Range::new("fi", ..); |
| 133 | let text2 = Range::new("\u{fb01}i", ..); |
| 134 | assert_eq!(0, common_overlap(text1, text2), "Unicode"); |
| 135 | } |
| 136 | |
| 137 | #[test] |
| 138 | fn test_cleanup_merge() { |
| 139 | let mut solution = diff_list![]; |
| 140 | cleanup_merge(&mut solution); |
| 141 | assert_diffs!([], solution, "Null case"); |
| 142 | |
| 143 | let mut solution = diff_list![Equal("a"), Delete("b"), Insert("c")]; |
| 144 | cleanup_merge(&mut solution); |
| 145 | assert_diffs!( |
| 146 | [Equal("a"), Delete("b"), Insert("c")], |
| 147 | solution, |
| 148 | "No change case", |
| 149 | ); |
| 150 | |
| 151 | let mut solution = diff_list![Equal("a"), Equal("b"), Equal("c")]; |
| 152 | cleanup_merge(&mut solution); |
| 153 | assert_diffs!([Equal("abc")], solution, "Merge equalities"); |
| 154 | |
| 155 | let mut solution = diff_list![Delete("a"), Delete("b"), Delete("c")]; |
| 156 | cleanup_merge(&mut solution); |
| 157 | assert_diffs!([Delete("abc")], solution, "Merge deletions"); |
| 158 | |
| 159 | let mut solution = diff_list![Insert("a"), Insert("b"), Insert("c")]; |
| 160 | cleanup_merge(&mut solution); |
| 161 | assert_diffs!([Insert("abc")], solution, "Merge insertions"); |
| 162 | |
| 163 | let mut solution = diff_list![ |
| 164 | Delete("a"), |
| 165 | Insert("b"), |
| 166 | Delete("c"), |
| 167 | Insert("d"), |
| 168 | Equal("e"), |
| 169 | Equal("f"), |
| 170 | ]; |
| 171 | cleanup_merge(&mut solution); |
| 172 | assert_diffs!( |
| 173 | [Delete("ac"), Insert("bd"), Equal("ef")], |
| 174 | solution, |
| 175 | "Merge interweave", |
| 176 | ); |
| 177 | |
| 178 | let mut solution = diff_list![Delete("a"), Insert("abc"), Delete("dc")]; |
| 179 | cleanup_merge(&mut solution); |
| 180 | assert_diffs!( |
| 181 | [Equal("a"), Delete("d"), Insert("b"), Equal("c")], |
| 182 | solution, |
| 183 | "Prefix and suffix detection", |
| 184 | ); |
| 185 | |
| 186 | let mut solution = diff_list![ |
| 187 | Equal("x"), |
| 188 | Delete("a"), |
| 189 | Insert("abc"), |
| 190 | Delete("dc"), |
| 191 | Equal("y"), |
| 192 | ]; |
| 193 | cleanup_merge(&mut solution); |
| 194 | assert_diffs!( |
| 195 | [Equal("xa"), Delete("d"), Insert("b"), Equal("cy")], |
| 196 | solution, |
| 197 | "Prefix and suffix detection with equalities", |
| 198 | ); |
| 199 | |
| 200 | let mut solution = diff_list![Equal("a"), Insert("ba"), Equal("c")]; |
| 201 | cleanup_merge(&mut solution); |
| 202 | assert_diffs!([Insert("ab"), Equal("ac")], solution, "Slide edit left"); |
| 203 | |
| 204 | let mut solution = diff_list![Equal("c"), Insert("ab"), Equal("a")]; |
| 205 | cleanup_merge(&mut solution); |
| 206 | assert_diffs!([Equal("ca"), Insert("ba")], solution, "Slide edit right"); |
| 207 | |
| 208 | let mut solution = diff_list![ |
| 209 | Equal("a"), |
| 210 | Delete("b"), |
| 211 | Equal("c"), |
| 212 | Delete("ac"), |
| 213 | Equal("x"), |
| 214 | ]; |
| 215 | cleanup_merge(&mut solution); |
| 216 | assert_diffs!( |
| 217 | [Delete("abc"), Equal("acx")], |
| 218 | solution, |
| 219 | "Slide edit left recursive", |
| 220 | ); |
| 221 | |
| 222 | let mut solution = diff_list![ |
| 223 | Equal("x"), |
| 224 | Delete("ca"), |
| 225 | Equal("c"), |
| 226 | Delete("b"), |
| 227 | Equal("a"), |
| 228 | ]; |
| 229 | cleanup_merge(&mut solution); |
| 230 | assert_diffs!( |
| 231 | [Equal("xca"), Delete("cba")], |
| 232 | solution, |
| 233 | "Slide edit right recursive", |
| 234 | ); |
| 235 | |
| 236 | let mut solution = diff_list![Delete("b"), Insert("ab"), Equal("c")]; |
| 237 | cleanup_merge(&mut solution); |
| 238 | assert_diffs!([Insert("a"), Equal("bc")], solution, "Empty range"); |
| 239 | |
| 240 | let mut solution = diff_list![Equal(""), Insert("a"), Equal("b")]; |
| 241 | cleanup_merge(&mut solution); |
| 242 | assert_diffs!([Insert("a"), Equal("b")], solution, "Empty equality"); |
| 243 | } |
| 244 | |
| 245 | #[test] |
| 246 | fn test_cleanup_semantic_lossless() { |
| 247 | let mut solution = diff_list![]; |
| 248 | cleanup_semantic_lossless(&mut solution); |
| 249 | assert_diffs!([], solution, "Null case"); |
| 250 | |
| 251 | let mut solution = diff_list![ |
| 252 | Equal("AAA\r\n\r\nBBB"), |
| 253 | Insert("\r\nDDD\r\n\r\nBBB"), |
| 254 | Equal("\r\nEEE"), |
| 255 | ]; |
| 256 | cleanup_semantic_lossless(&mut solution); |
| 257 | assert_diffs!( |
| 258 | [ |
| 259 | Equal("AAA\r\n\r\n"), |
| 260 | Insert("BBB\r\nDDD\r\n\r\n"), |
| 261 | Equal("BBB\r\nEEE"), |
| 262 | ], |
| 263 | solution, |
| 264 | "Blank lines", |
| 265 | ); |
| 266 | |
| 267 | let mut solution = diff_list![Equal("AAA\r\nBBB"), Insert(" DDD\r\nBBB"), Equal(" EEE")]; |
| 268 | cleanup_semantic_lossless(&mut solution); |
| 269 | assert_diffs!( |
| 270 | [Equal("AAA\r\n"), Insert("BBB DDD\r\n"), Equal("BBB EEE")], |
| 271 | solution, |
| 272 | "Line boundaries", |
| 273 | ); |
| 274 | |
| 275 | let mut solution = diff_list![Equal("The c"), Insert("ow and the c"), Equal("at.")]; |
| 276 | cleanup_semantic_lossless(&mut solution); |
| 277 | assert_diffs!( |
| 278 | [Equal("The "), Insert("cow and the "), Equal("cat.")], |
| 279 | solution, |
| 280 | "Word boundaries", |
| 281 | ); |
| 282 | |
| 283 | let mut solution = diff_list![Equal("The-c"), Insert("ow-and-the-c"), Equal("at.")]; |
| 284 | cleanup_semantic_lossless(&mut solution); |
| 285 | assert_diffs!( |
| 286 | [Equal("The-"), Insert("cow-and-the-"), Equal("cat.")], |
| 287 | solution, |
| 288 | "Alphanumeric boundaries", |
| 289 | ); |
| 290 | |
| 291 | let mut solution = diff_list![Equal("a"), Delete("a"), Equal("ax")]; |
| 292 | cleanup_semantic_lossless(&mut solution); |
| 293 | assert_diffs!([Delete("a"), Equal("aax")], solution, "Hitting the start"); |
| 294 | |
| 295 | let mut solution = diff_list![Equal("xa"), Delete("a"), Equal("a")]; |
| 296 | cleanup_semantic_lossless(&mut solution); |
| 297 | assert_diffs!([Equal("xaa"), Delete("a")], solution, "Hitting the end"); |
| 298 | |
| 299 | let mut solution = diff_list![Equal("The xxx. The "), Insert("zzz. The "), Equal("yyy.")]; |
| 300 | cleanup_semantic_lossless(&mut solution); |
| 301 | assert_diffs!( |
| 302 | [Equal("The xxx."), Insert(" The zzz."), Equal(" The yyy.")], |
| 303 | solution, |
| 304 | "Sentence boundaries", |
| 305 | ); |
| 306 | } |
| 307 | |
| 308 | #[test] |
| 309 | fn test_cleanup_semantic() { |
| 310 | let mut solution = diff_list![]; |
| 311 | cleanup_semantic(&mut solution); |
| 312 | assert_diffs!([], solution, "Null case"); |
| 313 | |
| 314 | let mut solution = diff_list![Delete("ab"), Insert("cd"), Equal("12"), Delete("e")]; |
| 315 | cleanup_semantic(&mut solution); |
| 316 | assert_diffs!( |
| 317 | [Delete("ab"), Insert("cd"), Equal("12"), Delete("e")], |
| 318 | solution, |
| 319 | "No elimination #1", |
| 320 | ); |
| 321 | |
| 322 | let mut solution = diff_list![Delete("abc"), Insert("ABC"), Equal("1234"), Delete("wxyz")]; |
| 323 | cleanup_semantic(&mut solution); |
| 324 | assert_diffs!( |
| 325 | [Delete("abc"), Insert("ABC"), Equal("1234"), Delete("wxyz")], |
| 326 | solution, |
| 327 | "No elimination #2", |
| 328 | ); |
| 329 | |
| 330 | let mut solution = diff_list![Delete("a"), Equal("b"), Delete("c")]; |
| 331 | cleanup_semantic(&mut solution); |
| 332 | assert_diffs!([Delete("abc"), Insert("b")], solution, "Simple elimination",); |
| 333 | |
| 334 | let mut solution = diff_list![ |
| 335 | Delete("ab"), |
| 336 | Equal("cd"), |
| 337 | Delete("e"), |
| 338 | Equal("f"), |
| 339 | Insert("g"), |
| 340 | ]; |
| 341 | cleanup_semantic(&mut solution); |
| 342 | assert_diffs!( |
| 343 | [Delete("abcdef"), Insert("cdfg")], |
| 344 | solution, |
| 345 | "Backpass elimination", |
| 346 | ); |
| 347 | |
| 348 | let mut solution = diff_list![ |
| 349 | Insert("1"), |
| 350 | Equal("A"), |
| 351 | Delete("B"), |
| 352 | Insert("2"), |
| 353 | Equal("_"), |
| 354 | Insert("1"), |
| 355 | Equal("A"), |
| 356 | Delete("B"), |
| 357 | Insert("2"), |
| 358 | ]; |
| 359 | cleanup_semantic(&mut solution); |
| 360 | assert_diffs!( |
| 361 | [Delete("AB_AB"), Insert("1A2_1A2")], |
| 362 | solution, |
| 363 | "Multiple elimination", |
| 364 | ); |
| 365 | |
| 366 | let mut solution = diff_list![Equal("The c"), Delete("ow and the c"), Equal("at.")]; |
| 367 | cleanup_semantic(&mut solution); |
| 368 | assert_diffs!( |
| 369 | [Equal("The "), Delete("cow and the "), Equal("cat.")], |
| 370 | solution, |
| 371 | "Word boundaries", |
| 372 | ); |
| 373 | |
| 374 | let mut solution = diff_list![Delete("abcxx"), Insert("xxdef")]; |
| 375 | cleanup_semantic(&mut solution); |
| 376 | assert_diffs!( |
| 377 | [Delete("abcxx"), Insert("xxdef")], |
| 378 | solution, |
| 379 | "No overlap elimination", |
| 380 | ); |
| 381 | |
| 382 | let mut solution = diff_list![Delete("abcxxx"), Insert("xxxdef")]; |
| 383 | cleanup_semantic(&mut solution); |
| 384 | assert_diffs!( |
| 385 | [Delete("abc"), Equal("xxx"), Insert("def")], |
| 386 | solution, |
| 387 | "Overlap elimination", |
| 388 | ); |
| 389 | |
| 390 | let mut solution = diff_list![Delete("xxxabc"), Insert("defxxx")]; |
| 391 | cleanup_semantic(&mut solution); |
| 392 | assert_diffs!( |
| 393 | [Insert("def"), Equal("xxx"), Delete("abc")], |
| 394 | solution, |
| 395 | "Reverse overlap elimination", |
| 396 | ); |
| 397 | |
| 398 | let mut solution = diff_list![ |
| 399 | Delete("abcd1212"), |
| 400 | Insert("1212efghi"), |
| 401 | Equal("----"), |
| 402 | Delete("A3"), |
| 403 | Insert("3BC"), |
| 404 | ]; |
| 405 | cleanup_semantic(&mut solution); |
| 406 | assert_diffs!( |
| 407 | [ |
| 408 | Delete("abcd"), |
| 409 | Equal("1212"), |
| 410 | Insert("efghi"), |
| 411 | Equal("----"), |
| 412 | Delete("A"), |
| 413 | Equal("3"), |
| 414 | Insert("BC"), |
| 415 | ], |
| 416 | solution, |
| 417 | "Two overlap eliminations", |
| 418 | ); |
| 419 | } |
| 420 | |
| 421 | #[test] |
| 422 | fn test_bisect() { |
| 423 | let text1 = Range::new("cat", ..); |
| 424 | let text2 = Range::new("map", ..); |
| 425 | let solution = Solution { |
| 426 | text1, |
| 427 | text2, |
| 428 | diffs: bisect(text1, text2), |
| 429 | utf8: false, |
| 430 | }; |
| 431 | assert_diffs!( |
| 432 | [ |
| 433 | Delete("c"), |
| 434 | Insert("m"), |
| 435 | Equal("a"), |
| 436 | Delete("t"), |
| 437 | Insert("p"), |
| 438 | ], |
| 439 | solution, |
| 440 | "Normal", |
| 441 | ); |
| 442 | } |
| 443 | |
| 444 | #[test] |
| 445 | fn test_main() { |
| 446 | let solution = main(Range::empty(), Range::empty()); |
| 447 | assert_diffs!([], solution, "Null case"); |
| 448 | |
| 449 | let solution = main(Range::new("abc", ..), Range::new("abc", ..)); |
| 450 | assert_diffs!([Equal("abc")], solution, "Equality"); |
| 451 | |
| 452 | let solution = main(Range::new("abc", ..), Range::new("ab123c", ..)); |
| 453 | assert_diffs!( |
| 454 | [Equal("ab"), Insert("123"), Equal("c")], |
| 455 | solution, |
| 456 | "Simple insertion", |
| 457 | ); |
| 458 | |
| 459 | let solution = main(Range::new("a123bc", ..), Range::new("abc", ..)); |
| 460 | assert_diffs!( |
| 461 | [Equal("a"), Delete("123"), Equal("bc")], |
| 462 | solution, |
| 463 | "Simple deletion", |
| 464 | ); |
| 465 | |
| 466 | let solution = main(Range::new("abc", ..), Range::new("a123b456c", ..)); |
| 467 | assert_diffs!( |
| 468 | [ |
| 469 | Equal("a"), |
| 470 | Insert("123"), |
| 471 | Equal("b"), |
| 472 | Insert("456"), |
| 473 | Equal("c"), |
| 474 | ], |
| 475 | solution, |
| 476 | "Two insertions", |
| 477 | ); |
| 478 | |
| 479 | let solution = main(Range::new("a123b456c", ..), Range::new("abc", ..)); |
| 480 | assert_diffs!( |
| 481 | [ |
| 482 | Equal("a"), |
| 483 | Delete("123"), |
| 484 | Equal("b"), |
| 485 | Delete("456"), |
| 486 | Equal("c"), |
| 487 | ], |
| 488 | solution, |
| 489 | "Two deletions", |
| 490 | ); |
| 491 | |
| 492 | let solution = main(Range::new("a", ..), Range::new("b", ..)); |
| 493 | assert_diffs!([Delete("a"), Insert("b")], solution, "Simple case #1"); |
| 494 | |
| 495 | let solution = main( |
| 496 | Range::new("Apples are a fruit.", ..), |
| 497 | Range::new("Bananas are also fruit.", ..), |
| 498 | ); |
| 499 | assert_diffs!( |
| 500 | [ |
| 501 | Delete("Apple"), |
| 502 | Insert("Banana"), |
| 503 | Equal("s are a"), |
| 504 | Insert("lso"), |
| 505 | Equal(" fruit."), |
| 506 | ], |
| 507 | solution, |
| 508 | "Simple case #2", |
| 509 | ); |
| 510 | |
| 511 | let solution = main(Range::new("ax\t", ..), Range::new("\u{0680}x\000", ..)); |
| 512 | assert_diffs!( |
| 513 | [ |
| 514 | Delete("a"), |
| 515 | Insert("\u{0680}"), |
| 516 | Equal("x"), |
| 517 | Delete("\t"), |
| 518 | Insert("\000"), |
| 519 | ], |
| 520 | solution, |
| 521 | "Simple case #3", |
| 522 | ); |
| 523 | |
| 524 | let solution = main(Range::new("1ayb2", ..), Range::new("abxab", ..)); |
| 525 | assert_diffs!( |
| 526 | [ |
| 527 | Delete("1"), |
| 528 | Equal("a"), |
| 529 | Delete("y"), |
| 530 | Equal("b"), |
| 531 | Delete("2"), |
| 532 | Insert("xab"), |
| 533 | ], |
| 534 | solution, |
| 535 | "Overlap #1", |
| 536 | ); |
| 537 | |
| 538 | let solution = main(Range::new("abcy", ..), Range::new("xaxcxabc", ..)); |
| 539 | assert_diffs!( |
| 540 | [Insert("xaxcx"), Equal("abc"), Delete("y")], |
| 541 | solution, |
| 542 | "Overlap #2", |
| 543 | ); |
| 544 | |
| 545 | let solution = main( |
| 546 | Range::new("ABCDa=bcd=efghijklmnopqrsEFGHIJKLMNOefg", ..), |
| 547 | Range::new("a-bcd-efghijklmnopqrs", ..), |
| 548 | ); |
| 549 | assert_diffs!( |
| 550 | [ |
| 551 | Delete("ABCD"), |
| 552 | Equal("a"), |
| 553 | Delete("="), |
| 554 | Insert("-"), |
| 555 | Equal("bcd"), |
| 556 | Delete("="), |
| 557 | Insert("-"), |
| 558 | Equal("efghijklmnopqrs"), |
| 559 | Delete("EFGHIJKLMNOefg"), |
| 560 | ], |
| 561 | solution, |
| 562 | "Overlap #3", |
| 563 | ); |
| 564 | |
| 565 | let solution = main( |
| 566 | Range::new("a [[Pennsylvania]] and [[New", ..), |
| 567 | Range::new(" and [[Pennsylvania]]", ..), |
| 568 | ); |
| 569 | assert_diffs!( |
| 570 | [ |
| 571 | Insert(" "), |
| 572 | Equal("a"), |
| 573 | Insert("nd"), |
| 574 | Equal(" [[Pennsylvania]]"), |
| 575 | Delete(" and [[New"), |
| 576 | ], |
| 577 | solution, |
| 578 | "Large equality", |
| 579 | ); |
| 580 | } |