internal/pkgbits: add missing tests

The encoding version was recently bumped to V3
but the tests were not updated. Do it now.

For #9859.

Change-Id: Ia61d3e178215e804dcd2db186774883617e5e5a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/757440
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
This commit is contained in:
Robert Griesemer
2026-03-11 19:02:07 -07:00
committed by Gopher Robot
parent 79f3d38562
commit 51abbb12c4

View File

@@ -15,6 +15,7 @@ func TestRoundTrip(t *testing.T) {
pkgbits.V0,
pkgbits.V1,
pkgbits.V2,
pkgbits.V3,
} {
pw := pkgbits.NewPkgEncoder(version, -1)
w := pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPublic)
@@ -33,9 +34,13 @@ func TestRoundTrip(t *testing.T) {
}
}
// Type checker to enforce that know V* have the constant values they must have.
var _ [0]bool = [pkgbits.V0]bool{}
var _ [1]bool = [pkgbits.V1]bool{}
// Type checker to enforce that known V* have the constant values they must have.
var (
_ [0]bool = [pkgbits.V0]bool{}
_ [1]bool = [pkgbits.V1]bool{}
_ [2]bool = [pkgbits.V2]bool{}
_ [3]bool = [pkgbits.V3]bool{}
)
func TestVersions(t *testing.T) {
type vfpair struct {
@@ -54,6 +59,7 @@ func TestVersions(t *testing.T) {
{pkgbits.V0, pkgbits.DerivedInfoNeeded},
{pkgbits.V1, pkgbits.DerivedInfoNeeded},
{pkgbits.V2, pkgbits.AliasTypeParamNames},
{pkgbits.V3, pkgbits.CompactCompLiterals},
} {
if !c.v.Has(c.f) {
t.Errorf("Expected version %v to have field %v", c.v, c.f)
@@ -68,6 +74,9 @@ func TestVersions(t *testing.T) {
{pkgbits.V2, pkgbits.DerivedInfoNeeded},
{pkgbits.V0, pkgbits.AliasTypeParamNames},
{pkgbits.V1, pkgbits.AliasTypeParamNames},
{pkgbits.V0, pkgbits.CompactCompLiterals},
{pkgbits.V1, pkgbits.CompactCompLiterals},
{pkgbits.V2, pkgbits.CompactCompLiterals},
} {
if c.v.Has(c.f) {
t.Errorf("Expected version %v to not have field %v", c.v, c.f)