this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add additional parser advancement tests

+43 -1
+43 -1
gitdiff/parser_test.go
··· 80 80 }) 81 81 } 82 82 83 - func TestParserAdvancment(t *testing.T) { 83 + func TestParserInvariant_Advancement(t *testing.T) { 84 84 tests := map[string]struct { 85 85 Input string 86 86 Parse func(p *parser) error ··· 121 121 return err 122 122 }, 123 123 EndLine: "context line\n", 124 + }, 125 + "ParseTextChunk": { 126 + Input: ` context line 127 + -old line 128 + +new line 129 + context line 130 + @@ -1 +1 @@ 131 + `, 132 + Parse: func(p *parser) error { 133 + return p.ParseTextChunk(&Fragment{OldLines: 3, NewLines: 3}) 134 + }, 135 + EndLine: "@@ -1 +1 @@\n", 136 + }, 137 + "ParseTextFragments": { 138 + Input: `@@ -1,2 +1,2 @@ 139 + context line 140 + -old line 141 + +new line 142 + @@ -1,2 +1,2 @@ 143 + -old line 144 + +new line 145 + context line 146 + diff --git a/file.txt b/file.txt 147 + `, 148 + Parse: func(p *parser) error { 149 + _, err := p.ParseTextFragments(&File{}) 150 + return err 151 + }, 152 + EndLine: "diff --git a/file.txt b/file.txt\n", 153 + }, 154 + "ParseNextFileHeader": { 155 + Input: `not a header 156 + diff --git a/file.txt b/file.txt 157 + --- a/file.txt 158 + +++ b/file.txt 159 + @@ -1,2 +1,2 @@ 160 + `, 161 + Parse: func(p *parser) error { 162 + _, _, err := p.ParseNextFileHeader() 163 + return err 164 + }, 165 + EndLine: "@@ -1,2 +1,2 @@\n", 124 166 }, 125 167 } 126 168