| 1 | // Copyright 2024 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package opaque_default_testscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/cmd/protoc-gen-go/opaque_default_test_test`/ |
| 6 | |
| 7 | import ( |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.23 testing/" |
| 9 | |
| 10 | enumopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/enums/enums_opaque`/ "google.golang.org/protobuf/internal/testprotos/enums/enums_opaquescip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/enums/enums_opaque`/" |
| 11 | testopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/ "google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaquescip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/" |
| 12 | ) |
| 13 | |
| 14 | // From the spec: "Proto2 enums use the first syntactic entry in the enum |
| 15 | // declaration as the default value where it is otherwise unspecified." |
| 16 | func TestOpaqueEnumDefaultsscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/cmd/protoc-gen-go/opaque_default_test_test`/TestOpaqueEnumDefaults().(t *testingscip-go gomod github.com/golang/go/src go1.23 testing/.Tscip-go gomod github.com/golang/go/src go1.23 testing/T#) { |
| 17 | m := &testopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/.RemoteDefaultscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/RemoteDefault#{} |
| 18 | if got, want := m.GetDefaultscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque`/RemoteDefault#GetDefault().(), enumopaquepbscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/enums/enums_opaque`/.Enum_DEFAULTscip-go gomod google.golang.org/protobuf . `google.golang.org/protobuf/internal/testprotos/enums/enums_opaque`/Enum_DEFAULT.; got != want { |
| 19 | t.Errorfscip-go gomod github.com/golang/go/src go1.23 testing/common#Errorf().("default enum value: got %v, expected %v", got, want) |
| 20 | } |
| 21 | } |