Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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)
}
13 changes: 13 additions & 0 deletions internal/tdp/tag_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tdp

import (
"google.golang.org/protobuf/encoding/protowire"
"testing"
)

func TestTagOverflows(t *testing.T) {
tag := EncodeTag(protowire.MaxValidNumber, protowire.BytesType)
if tag.Overflows() {
t.Error("protowire.MaxValidNumber should not overflow")
}
}