enum_test.go 828 B

123456789101112131415161718192021222324
  1. // Copyright 2019 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. package impl_test
  5. import (
  6. "reflect"
  7. "testing"
  8. pref "google.golang.org/protobuf/reflect/protoreflect"
  9. testpb "google.golang.org/protobuf/internal/testprotos/test"
  10. )
  11. func TestEnum(t *testing.T) {
  12. et := testpb.ForeignEnum_FOREIGN_FOO.Type()
  13. if got, want := et.GoType(), reflect.TypeOf(testpb.ForeignEnum_FOREIGN_FOO); got != want {
  14. t.Errorf("testpb.ForeignEnum_FOREIGN_FOO.Type().GoType() = %v, want %v", got, want)
  15. }
  16. if got, want := et.New(pref.EnumNumber(testpb.ForeignEnum_FOREIGN_FOO)), pref.Enum(testpb.ForeignEnum_FOREIGN_FOO); got != want {
  17. t.Errorf("testpb.ForeignEnum_FOREIGN_FOO.Type().New() = %[1]T(%[1]v), want %[2]T(%[2]v)", got, want)
  18. }
  19. }