MCPcopy Create free account
hub / github.com/sergi/go-diff / TestPatchMakeInvalidUTF8

Function TestPatchMakeInvalidUTF8

diffmatchpatch/patch_test.go:372–392  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

370}
371
372func 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
394func BenchmarkPatchFromText(b *testing.B) {
395 s1, s2 := speedtestTexts()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
DiffMainMethod · 0.80
PatchMakeMethod · 0.80
PatchApplyMethod · 0.80

Tested by

no test coverage detected