registry_test.go 1.0 KB

12345678910111213141516171819202122232425262728
  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 proto_test
  5. import (
  6. "reflect"
  7. "testing"
  8. "github.com/golang/protobuf/proto"
  9. "google.golang.org/protobuf/types/descriptorpb"
  10. )
  11. func TestRegistry(t *testing.T) {
  12. if got := proto.FileDescriptor("google/protobuf/descriptor.proto"); len(got) == 0 {
  13. t.Errorf(`FileDescriptor("google/protobuf/descriptor.proto") = empty, want non-empty`)
  14. }
  15. if got := proto.EnumValueMap("google.protobuf.FieldDescriptorProto_Label"); len(got) == 0 {
  16. t.Errorf(`EnumValueMap("google.protobuf.FieldDescriptorProto_Label") = empty, want non-empty`)
  17. }
  18. wantType := reflect.TypeOf(new(descriptorpb.EnumDescriptorProto_EnumReservedRange))
  19. gotType := proto.MessageType("google.protobuf.EnumDescriptorProto.EnumReservedRange")
  20. if gotType != wantType {
  21. t.Errorf(`MessageType("google.protobuf.EnumDescriptorProto.EnumReservedRange") = %v, want %v`, gotType, wantType)
  22. }
  23. }