@@ -6,55 +6,54 @@ import (
66
77type testCase struct {
88 pass []byte
9- fail []byte
9+ fails [] []byte
1010 function func ([]byte ) bool
1111}
1212
1313func TestIsIndexLine (t * testing.T ) {
1414 tests := map [string ]testCase {
1515 "indexLine" : {
1616 pass : []byte ("index 1ed6fbee1..aea1e643a 100644" ),
17- fail : [] byte ("notcorrect" ),
17+ fails : [][] byte {[] byte ("notcorrect" )} ,
1818 function : isIndexLine ,
1919 },
2020 "modeLine" : {
2121 pass : []byte ("new file mode 100644" ),
22- fail : [] byte ("notcorrect" ),
22+ fails : [][] byte {[] byte ("notcorrect" )} ,
2323 function : isModeLine ,
2424 },
2525 "minusFileLine" : {
2626 pass : []byte ("--- a/internal/addrs/move_endpoint_module.go" ),
27- fail : [] byte ("notcorrect" ),
27+ fails : [][] byte {[] byte ("notcorrect" ), [] byte ( "--- s" ), [] byte ( "short" )} ,
2828 function : isMinusFileLine ,
2929 },
3030 "plusFileLine" : {
3131 pass : []byte ("+++ b/internal/addrs/move_endpoint_module.go" ),
32- fail : [] byte ("notcorrect" ),
32+ fails : [][] byte {[] byte ("notcorrect" ), [] byte ( "+++ s" ), [] byte ( "short" )} ,
3333 function : isPlusFileLine ,
3434 },
3535 "plusDiffLine" : {
3636 pass : []byte ("+fmt.Println" ),
37- fail : [] byte ("notcorrect" ),
37+ fails : [][] byte {[] byte ("notcorrect" )} ,
3838 function : isPlusDiffLine ,
3939 },
4040 "minusDiffLine" : {
4141 pass : []byte ("-fmt.Println" ),
42- fail : []byte ("notcorrect" ),
4342 function : isMinusDiffLine ,
4443 },
4544 "messageLine" : {
4645 pass : []byte (" committed" ),
47- fail : [] byte ("notcorrect" ),
46+ fails : [][] byte {[] byte ("notcorrect" )} ,
4847 function : isMessageLine ,
4948 },
5049 "binaryLine" : {
5150 pass : []byte ("Binary files /dev/null and b/plugin.sig differ" ),
52- fail : [] byte ("notcorrect" ),
51+ fails : [][] byte {[] byte ("notcorrect" )} ,
5352 function : isBinaryLine ,
5453 },
5554 "lineNumberLine" : {
5655 pass : []byte ("@@ -298 +298 @@ func maxRetryErrorHandler(resp *http.Response, err error, numTries int)" ),
57- fail : [] byte ("notcorrect" ),
56+ fails : [][] byte {[] byte ("notcorrect" )} ,
5857 function : isLineNumberDiffLine ,
5958 },
6059 }
@@ -63,8 +62,10 @@ func TestIsIndexLine(t *testing.T) {
6362 if ! test .function (test .pass ) {
6463 t .Errorf ("%s: Parser did not recognize correct line." , name )
6564 }
66- if test .function (test .fail ) {
67- t .Errorf ("%s: Parser matched an incorrect line." , name )
65+ for _ , fail := range test .fails {
66+ if test .function (fail ) {
67+ t .Errorf ("%s: Parser did not recognize incorrect line." , name )
68+ }
6869 }
6970 }
7071}
0 commit comments