registry_test.go 707 B

123456789101112131415161718192021222324252627
  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 main
  5. import (
  6. "testing"
  7. "google.golang.org/protobuf/internal/filedesc"
  8. "google.golang.org/protobuf/reflect/protoreflect"
  9. "google.golang.org/protobuf/reflect/protoregistry"
  10. )
  11. func TestRegistry(t *testing.T) {
  12. var hasFiles bool
  13. protoregistry.GlobalFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool {
  14. if fd.(*filedesc.File).L2 != nil {
  15. t.Errorf("file %q eagerly went through lazy initialization", fd.Path())
  16. }
  17. hasFiles = true
  18. return true
  19. })
  20. if !hasFiles {
  21. t.Errorf("protoregistry.GlobalFiles is empty")
  22. }
  23. }