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 main
6
7import (
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
15func 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