Skip to content

Commit

Permalink
fix(decoder): Next() returned false where it should be true (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari committed Oct 13, 2023
1 parent 76b86da commit 6f85954
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (d *Decoder) Next() bool {
d.initDecodeHeaderOnce() // reset to enable invocation.

// err is saved in the func, any exported will call this func anyway.
return d.decodeHeaderOnce() != nil
return d.decodeHeaderOnce() == nil
}

// DecodeWithContext wraps Decode to respect context propagation.
Expand Down
5 changes: 4 additions & 1 deletion decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ func TestNext(t *testing.T) {
}

// Check whether after decode, fields are reset and next sequence is retrieved.
dec.Next()

if !dec.Next() {
t.Fatalf("should have next, return false")
}

if prevAccumulator == dec.accumulator {
t.Fatalf("expected new accumulator got same")
Expand Down

0 comments on commit 6f85954

Please sign in to comment.