File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1414package expfmt
1515
1616import (
17+ "errors"
1718 "math"
1819 "strings"
1920 "testing"
@@ -667,3 +668,39 @@ func BenchmarkParseError(b *testing.B) {
667668 testTextParseError (b )
668669 }
669670}
671+
672+ func TestTextParserStartOfLine (t * testing.T ) {
673+ t .Run ("EOF" , func (t * testing.T ) {
674+ p := TextParser {}
675+ in := strings .NewReader ("" )
676+ p .reset (in )
677+ fn := p .startOfLine ()
678+ if fn != nil {
679+ t .Errorf ("Unexpected non-nil function: %v" , fn )
680+ }
681+ if p .err != nil {
682+ t .Errorf ("Unexpected error: %v" , p .err )
683+ }
684+ })
685+
686+ t .Run ("OtherError" , func (t * testing.T ) {
687+ p := TextParser {}
688+ in := & errReader {err : errors .New ("unexpected error" )}
689+ p .reset (in )
690+ fn := p .startOfLine ()
691+ if fn != nil {
692+ t .Errorf ("Unexpected non-nil function: %v" , fn )
693+ }
694+ if p .err != in .err {
695+ t .Errorf ("Unexpected error: %v, expected %v" , p .err , in .err )
696+ }
697+ })
698+ }
699+
700+ type errReader struct {
701+ err error
702+ }
703+
704+ func (r * errReader ) Read (p []byte ) (int , error ) {
705+ return 0 , r .err
706+ }
You can’t perform that action at this time.
0 commit comments