MCPcopy Create free account
hub / github.com/JanSmrcka/differ / TestParseDiff_SimpleHunk

Function TestParseDiff_SimpleHunk

internal/ui/diff_test.go:279–311  ·  view source on GitHub ↗

--- ParseDiff ---

(t *testing.T)

Source from the content-addressed store, hash-verified

277// --- ParseDiff ---
278
279func TestParseDiff_SimpleHunk(t *testing.T) {
280 t.Parallel()
281 raw := `diff --git a/f.go b/f.go
282index abc..def 100644
283--- a/f.go
284+++ b/f.go
285@@ -1,3 +1,4 @@
286 context
287-removed
288+added1
289+added2`
290 parsed := ParseDiff(raw)
291 if parsed.Binary {
292 t.Error("should not be binary")
293 }
294 if len(parsed.Lines) == 0 {
295 t.Fatal("expected parsed lines")
296 }
297 // Should have: hunk header, context, removed, added1, added2
298 types := make(map[DiffLineType]int)
299 for _, l := range parsed.Lines {
300 types[l.Type]++
301 }
302 if types[LineHunkHeader] != 1 {
303 t.Errorf("hunk headers=%d, want 1", types[LineHunkHeader])
304 }
305 if types[LineRemoved] != 1 {
306 t.Errorf("removed=%d, want 1", types[LineRemoved])
307 }
308 if types[LineAdded] != 2 {
309 t.Errorf("added=%d, want 2", types[LineAdded])
310 }
311}
312
313func TestParseDiff_BinaryFile(t *testing.T) {
314 t.Parallel()

Callers

nothing calls this directly

Calls 1

ParseDiffFunction · 0.85

Tested by

no test coverage detected