...

Source file src/google.golang.org/protobuf/cmd/protoc-gen-go/testdata/registry_test.go

Documentation: google.golang.org/protobuf/cmd/protoc-gen-go/testdata

     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  	"google.golang.org/protobuf/internal/filedesc"
    11  	"google.golang.org/protobuf/reflect/protoreflect"
    12  	"google.golang.org/protobuf/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  }
    28  

View as plain text