MCPcopy Index your code
hub / github.com/jesseduffield/lazygit / TestLineNumberOfLine

Function TestLineNumberOfLine

pkg/commands/patch/patch_test.go:595–628  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

593}
594
595func TestLineNumberOfLine(t *testing.T) {
596 type scenario struct {
597 testName string
598 patchStr string
599 indexes []int
600 expecteds []int
601 }
602
603 scenarios := []scenario{
604 {
605 testName: "twoHunks",
606 patchStr: twoHunks,
607 // this is really more of a characteristic test than anything.
608 indexes: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 1000},
609 expecteds: []int{1, 1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15},
610 },
611 {
612 testName: "twoHunksWithMoreAdditionsThanRemovals",
613 patchStr: twoHunksWithMoreAdditionsThanRemovals,
614 indexes: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 1000},
615 expecteds: []int{1, 1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 9, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16},
616 },
617 }
618
619 for _, s := range scenarios {
620 t.Run(s.testName, func(t *testing.T) {
621 for i, idx := range s.indexes {
622 patch := Parse(s.patchStr)
623 result := patch.LineNumberOfLine(idx)
624 assert.Equal(t, s.expecteds[i], result)
625 }
626 })
627 }
628}
629
630func TestGetNextStageableLineIndex(t *testing.T) {
631 type scenario struct {

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
LineNumberOfLineMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected