protobuf-go/cmd/protoc-gen-go/enumprefix_test.go
Michael Stapelberg d14ebce888 all: implement strip_enum_prefix editions feature
This change required updating editions_defaults.binpb with
--edition_defaults_maximum=2024 so that we can use edition 2024 in our
testdata/enumprefix.proto test file.

For end users, this feature will only be available once:
1. protoc declares support for edition 2024 (expected early 2025).
2. protoc-gen-go declares support for edition 2024.

related to golang/protobuf#513

Change-Id: Ib8daeecae39ef32eff942279707d256c312f2a53
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618979
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Mike Kruskal <mkruskal@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-10-23 09:04:58 +00:00

30 lines
899 B
Go

// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"testing"
"google.golang.org/protobuf/cmd/protoc-gen-go/testdata/enumprefix"
)
func TestStripEnumPrefix(t *testing.T) {
// The file default for enumprefix.proto is to strip prefixes:
_ = enumprefix.Strip_ZERO
// The enum Both should generate both names:
_ = enumprefix.Both_ZERO
_ = enumprefix.Both_BOTH_ZERO
// The enum BothNoPrefix is configured to generate both names, but there is
// no prefix to be stripped, so only an unmodified name is generated.
_ = enumprefix.BothNoPrefix_ZERO
// The enum BothButOne is configured to generate both names, except for the
// ONE value, where only the prefixed name is generated.
_ = enumprefix.BothButOne_ZERO
_ = enumprefix.BothButOne_BOTH_BUT_ONE_ONE
}