github.com/whiteCcinn/protobuf-go@v1.0.9/cmd/protoc-gen-go/testdata/registry_test.go (about) 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 5 package main 6 7 import ( 8 "testing" 9 10 "github.com/whiteCcinn/protobuf-go/internal/filedesc" 11 "github.com/whiteCcinn/protobuf-go/reflect/protoreflect" 12 "github.com/whiteCcinn/protobuf-go/reflect/protoregistry" 13 ) 14 15 func TestRegistry(t *testing.T) { 16 var hasFiles bool 17 protoregistry.GlobalFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool { 18 if fd.(*filedesc.File).L2 != nil { 19 t.Errorf("file %q eagerly went through lazy initialization", fd.Path()) 20 } 21 hasFiles = true 22 return true 23 }) 24 if !hasFiles { 25 t.Errorf("protoregistry.GlobalFiles is empty") 26 } 27 }