blob: d122a6c8c6b1a0ebd27d9f4dec06180c0194eb6a [file] [log] [blame]
Damien Neil95539ea2019-08-30 10:20:26 -07001// 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
Joe Tsaicbdefb12019-09-16 09:57:27 -07005package impl_test
Damien Neil95539ea2019-08-30 10:20:26 -07006
7import (
8 "reflect"
9 "testing"
10
Damien Neil95539ea2019-08-30 10:20:26 -070011 pref "google.golang.org/protobuf/reflect/protoreflect"
Joe Tsaicbdefb12019-09-16 09:57:27 -070012
13 testpb "google.golang.org/protobuf/internal/testprotos/test"
Damien Neil95539ea2019-08-30 10:20:26 -070014)
15
16func TestEnum(t *testing.T) {
17 et := testpb.ForeignEnum_FOREIGN_FOO.Type()
18 if got, want := et.GoType(), reflect.TypeOf(testpb.ForeignEnum_FOREIGN_FOO); got != want {
19 t.Errorf("testpb.ForeignEnum_FOREIGN_FOO.Type().GoType() = %v, want %v", got, want)
20 }
21 if got, want := et.New(pref.EnumNumber(testpb.ForeignEnum_FOREIGN_FOO)), pref.Enum(testpb.ForeignEnum_FOREIGN_FOO); got != want {
22 t.Errorf("testpb.ForeignEnum_FOREIGN_FOO.Type().New() = %[1]T(%[1]v), want %[2]T(%[2]v)", got, want)
23 }
24}