Skip to content

Commit

Permalink
fix: errorf parserStep doesn't correctly pass format args
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinalwadhwa committed Nov 9, 2018
1 parent 9ed875b commit 52e47d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion did.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (p *parser) parseFragment() parserStep {
// other parser steps use this function to exit the state machine with an error
func (p *parser) errorf(index int, format string, args ...interface{}) parserStep {
p.currentIndex = index
p.err = fmt.Errorf(format, args)
p.err = fmt.Errorf(format, args...)
return nil
}

Expand Down
14 changes: 14 additions & 0 deletions did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,20 @@ func TestParse(t *testing.T) {
})
}

func Test_errorf(t *testing.T) {
p := &parser{}
p.errorf(10, "%s,%s", "a", "b")

if p.currentIndex != 10 {
t.Errorf("did not set currentIndex")
}

e := p.err.Error()
if e != "a,b" {
t.Errorf("err message is: '%s' expected: 'a,b'", e)
}
}

func Test_isNotValidIDChar(t *testing.T) {
a := []byte{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'Z', 'Y', 'Z',
Expand Down

0 comments on commit 52e47d6

Please sign in to comment.