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 5package proto_test 6 7import ( 8 "reflect" 9 "testing" 10 11 "github.com/golang/protobuf/proto" 12 "google.golang.org/protobuf/reflect/protoreflect" 13 14 descpb "github.com/golang/protobuf/protoc-gen-go/descriptor" 15) 16 17func TestRegistry(t *testing.T) { 18 file := new(descpb.DescriptorProto).ProtoReflect().Descriptor().ParentFile() 19 path := file.Path() 20 pkg := file.Package() 21 if got := proto.FileDescriptor(path); len(got) == 0 { 22 t.Errorf("FileDescriptor(%q) = empty, want non-empty", path) 23 } 24 25 name := protoreflect.FullName(pkg + ".FieldDescriptorProto_Label") 26 if got := proto.EnumValueMap(string(name)); len(got) == 0 { 27 t.Errorf("EnumValueMap(%q) = empty, want non-empty", name) 28 } 29 30 msg := new(descpb.EnumDescriptorProto_EnumReservedRange) 31 name = msg.ProtoReflect().Descriptor().FullName() 32 wantType := reflect.TypeOf(msg) 33 gotType := proto.MessageType(string(name)) 34 if gotType != wantType { 35 t.Errorf("MessageType(%q) = %v, want %v", name, gotType, wantType) 36 } 37} 38