Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/tdp/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ func (t Tag) Format(s fmt.State, verb rune) {
// Returns whether this tag is "too large", i.e., if it has more than 32 bits
// when decoded.
func (t Tag) Overflows() bool {
return bits.LeadingZeros64(uint64(t)) < (64 - 32 + 4)
return bits.LeadingZeros64(uint64(t)) < (64 - 32 - 4)
}
19 changes: 19 additions & 0 deletions internal/tdp/tag_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tdp

import (
"testing"

Check failure on line 5 in internal/tdp/tag_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.24.x)

File is not properly formatted (gci)
"google.golang.org/protobuf/encoding/protowire"
)

func TestTagOverflows(t *testing.T) {

Check failure on line 9 in internal/tdp/tag_test.go

View workflow job for this annotation

GitHub Actions / Lint (1.24.x)

Function TestTagOverflows missing the call to method parallel (paralleltest)
tag := EncodeTag(protowire.MaxValidNumber, protowire.BytesType)
if tag.Overflows() {
t.Error("protowire.MaxValidNumber should not overflow")
}

tag = EncodeTag(protowire.MaxValidNumber+1, protowire.BytesType)
if !tag.Overflows() {
t.Error("protowire.MaxValidNumber+1 should overflow")
}
}
Loading