OSDN Git Service

Hulk did something
[bytom/vapor.git] / vendor / github.com / golang / protobuf / descriptor / descriptor_test.go
1 package descriptor_test
2
3 import (
4         "fmt"
5         "testing"
6
7         "github.com/golang/protobuf/descriptor"
8         tpb "github.com/golang/protobuf/proto/testdata"
9         protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor"
10 )
11
12 func TestMessage(t *testing.T) {
13         var msg *protobuf.DescriptorProto
14         fd, md := descriptor.ForMessage(msg)
15         if pkg, want := fd.GetPackage(), "google.protobuf"; pkg != want {
16                 t.Errorf("descriptor.ForMessage(%T).GetPackage() = %q; want %q", msg, pkg, want)
17         }
18         if name, want := md.GetName(), "DescriptorProto"; name != want {
19                 t.Fatalf("descriptor.ForMessage(%T).GetName() = %q; want %q", msg, name, want)
20         }
21 }
22
23 func Example_Options() {
24         var msg *tpb.MyMessageSet
25         _, md := descriptor.ForMessage(msg)
26         if md.GetOptions().GetMessageSetWireFormat() {
27                 fmt.Printf("%v uses option message_set_wire_format.\n", md.GetName())
28         }
29
30         // Output:
31         // MyMessageSet uses option message_set_wire_format.
32 }