miniflux-v2/vendor/github.com/golang/protobuf/descriptor/descriptor_test.go

33 lines
905 B
Go
Raw Normal View History

2017-11-23 07:22:33 +01:00
package descriptor_test
import (
"fmt"
"testing"
"github.com/golang/protobuf/descriptor"
2018-07-07 06:18:14 +02:00
tpb "github.com/golang/protobuf/proto/test_proto"
2017-11-23 07:22:33 +01:00
protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor"
)
func TestMessage(t *testing.T) {
var msg *protobuf.DescriptorProto
fd, md := descriptor.ForMessage(msg)
if pkg, want := fd.GetPackage(), "google.protobuf"; pkg != want {
t.Errorf("descriptor.ForMessage(%T).GetPackage() = %q; want %q", msg, pkg, want)
}
if name, want := md.GetName(), "DescriptorProto"; name != want {
t.Fatalf("descriptor.ForMessage(%T).GetName() = %q; want %q", msg, name, want)
}
}
2018-07-07 06:18:14 +02:00
func Example_options() {
2017-11-23 07:22:33 +01:00
var msg *tpb.MyMessageSet
_, md := descriptor.ForMessage(msg)
if md.GetOptions().GetMessageSetWireFormat() {
fmt.Printf("%v uses option message_set_wire_format.\n", md.GetName())
}
// Output:
// MyMessageSet uses option message_set_wire_format.
}