(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func TestPatchMakeInvalidUTF8(t *testing.T) { |
| 373 | text1 := string([]byte{0xe0}) |
| 374 | normalizedText1 := string([]rune(text1)) |
| 375 | dmp := New() |
| 376 | diffs := dmp.DiffMain(text1, "", true) |
| 377 | |
| 378 | for _, patches := range [][]Patch{ |
| 379 | dmp.PatchMake(text1, ""), |
| 380 | dmp.PatchMake(text1, diffs), |
| 381 | } { |
| 382 | actual, applied := dmp.PatchApply(patches, normalizedText1) |
| 383 | assert.Equal(t, "", actual) |
| 384 | assert.Equal(t, []bool{true}, applied) |
| 385 | } |
| 386 | |
| 387 | // Handcrafted byte-level diffs should continue to use the original bytes. |
| 388 | patches := dmp.PatchMake(text1, []Diff{{DiffDelete, text1}}) |
| 389 | actual, applied := dmp.PatchApply(patches, text1) |
| 390 | assert.Equal(t, "", actual) |
| 391 | assert.Equal(t, []bool{true}, applied) |
| 392 | } |
| 393 | |
| 394 | func BenchmarkPatchFromText(b *testing.B) { |
| 395 | s1, s2 := speedtestTexts() |
nothing calls this directly
no test coverage detected