diff --git a/did.go b/did.go index c7cd28d..d043023 100644 --- a/did.go +++ b/did.go @@ -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 } diff --git a/did_test.go b/did_test.go index a25d5f0..6b67d7f 100644 --- a/did_test.go +++ b/did_test.go @@ -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',