|
|
@@ -15,7 +15,6 @@ import (
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
detrand "google.golang.org/protobuf/internal/detrand"
|
|
|
"google.golang.org/protobuf/internal/filedesc"
|
|
|
- scalar "google.golang.org/protobuf/internal/scalar"
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
pdesc "google.golang.org/protobuf/reflect/protodesc"
|
|
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
|
|
@@ -32,161 +31,161 @@ func init() {
|
|
|
|
|
|
func TestFile(t *testing.T) {
|
|
|
f1 := &descriptorpb.FileDescriptorProto{
|
|
|
- Syntax: scalar.String("proto2"),
|
|
|
- Name: scalar.String("path/to/file.proto"),
|
|
|
- Package: scalar.String("test"),
|
|
|
- Options: &descriptorpb.FileOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ Syntax: proto.String("proto2"),
|
|
|
+ Name: proto.String("path/to/file.proto"),
|
|
|
+ Package: proto.String("test"),
|
|
|
+ Options: &descriptorpb.FileOptions{Deprecated: proto.Bool(true)},
|
|
|
MessageType: []*descriptorpb.DescriptorProto{{
|
|
|
- Name: scalar.String("A"),
|
|
|
+ Name: proto.String("A"),
|
|
|
Options: &descriptorpb.MessageOptions{
|
|
|
- Deprecated: scalar.Bool(true),
|
|
|
+ Deprecated: proto.Bool(true),
|
|
|
},
|
|
|
}, {
|
|
|
- Name: scalar.String("B"),
|
|
|
+ Name: proto.String("B"),
|
|
|
Field: []*descriptorpb.FieldDescriptorProto{{
|
|
|
- Name: scalar.String("field_one"),
|
|
|
- Number: scalar.Int32(1),
|
|
|
+ Name: proto.String("field_one"),
|
|
|
+ Number: proto.Int32(1),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.StringKind).Enum(),
|
|
|
- DefaultValue: scalar.String("hello, \"world!\"\n"),
|
|
|
- OneofIndex: scalar.Int32(0),
|
|
|
+ DefaultValue: proto.String("hello, \"world!\"\n"),
|
|
|
+ OneofIndex: proto.Int32(0),
|
|
|
}, {
|
|
|
- Name: scalar.String("field_two"),
|
|
|
- JsonName: scalar.String("Field2"),
|
|
|
- Number: scalar.Int32(2),
|
|
|
+ Name: proto.String("field_two"),
|
|
|
+ JsonName: proto.String("Field2"),
|
|
|
+ Number: proto.Int32(2),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.EnumKind).Enum(),
|
|
|
- DefaultValue: scalar.String("BAR"),
|
|
|
- TypeName: scalar.String(".test.E1"),
|
|
|
- OneofIndex: scalar.Int32(1),
|
|
|
+ DefaultValue: proto.String("BAR"),
|
|
|
+ TypeName: proto.String(".test.E1"),
|
|
|
+ OneofIndex: proto.Int32(1),
|
|
|
}, {
|
|
|
- Name: scalar.String("field_three"),
|
|
|
- Number: scalar.Int32(3),
|
|
|
+ Name: proto.String("field_three"),
|
|
|
+ Number: proto.Int32(3),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: scalar.String(".test.C"),
|
|
|
- OneofIndex: scalar.Int32(1),
|
|
|
+ TypeName: proto.String(".test.C"),
|
|
|
+ OneofIndex: proto.Int32(1),
|
|
|
}, {
|
|
|
- Name: scalar.String("field_four"),
|
|
|
- JsonName: scalar.String("Field4"),
|
|
|
- Number: scalar.Int32(4),
|
|
|
+ Name: proto.String("field_four"),
|
|
|
+ JsonName: proto.String("Field4"),
|
|
|
+ Number: proto.Int32(4),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: scalar.String(".test.B.FieldFourEntry"),
|
|
|
+ TypeName: proto.String(".test.B.FieldFourEntry"),
|
|
|
}, {
|
|
|
- Name: scalar.String("field_five"),
|
|
|
- Number: scalar.Int32(5),
|
|
|
+ Name: proto.String("field_five"),
|
|
|
+ Number: proto.Int32(5),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.Int32Kind).Enum(),
|
|
|
- Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
+ Options: &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
|
|
|
}, {
|
|
|
- Name: scalar.String("field_six"),
|
|
|
- Number: scalar.Int32(6),
|
|
|
+ Name: proto.String("field_six"),
|
|
|
+ Number: proto.Int32(6),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Required).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
|
|
|
}},
|
|
|
OneofDecl: []*descriptorpb.OneofDescriptorProto{
|
|
|
{
|
|
|
- Name: scalar.String("O1"),
|
|
|
+ Name: proto.String("O1"),
|
|
|
Options: &descriptorpb.OneofOptions{
|
|
|
UninterpretedOption: []*descriptorpb.UninterpretedOption{
|
|
|
{StringValue: []byte("option")},
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- {Name: scalar.String("O2")},
|
|
|
+ {Name: proto.String("O2")},
|
|
|
},
|
|
|
ReservedName: []string{"fizz", "buzz"},
|
|
|
ReservedRange: []*descriptorpb.DescriptorProto_ReservedRange{
|
|
|
- {Start: scalar.Int32(100), End: scalar.Int32(200)},
|
|
|
- {Start: scalar.Int32(300), End: scalar.Int32(301)},
|
|
|
+ {Start: proto.Int32(100), End: proto.Int32(200)},
|
|
|
+ {Start: proto.Int32(300), End: proto.Int32(301)},
|
|
|
},
|
|
|
ExtensionRange: []*descriptorpb.DescriptorProto_ExtensionRange{
|
|
|
- {Start: scalar.Int32(1000), End: scalar.Int32(2000)},
|
|
|
- {Start: scalar.Int32(3000), End: scalar.Int32(3001), Options: new(descriptorpb.ExtensionRangeOptions)},
|
|
|
+ {Start: proto.Int32(1000), End: proto.Int32(2000)},
|
|
|
+ {Start: proto.Int32(3000), End: proto.Int32(3001), Options: new(descriptorpb.ExtensionRangeOptions)},
|
|
|
},
|
|
|
NestedType: []*descriptorpb.DescriptorProto{{
|
|
|
- Name: scalar.String("FieldFourEntry"),
|
|
|
+ Name: proto.String("FieldFourEntry"),
|
|
|
Field: []*descriptorpb.FieldDescriptorProto{{
|
|
|
- Name: scalar.String("key"),
|
|
|
- Number: scalar.Int32(1),
|
|
|
+ Name: proto.String("key"),
|
|
|
+ Number: proto.Int32(1),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.StringKind).Enum(),
|
|
|
}, {
|
|
|
- Name: scalar.String("value"),
|
|
|
- Number: scalar.Int32(2),
|
|
|
+ Name: proto.String("value"),
|
|
|
+ Number: proto.Int32(2),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: scalar.String(".test.B"),
|
|
|
+ TypeName: proto.String(".test.B"),
|
|
|
}},
|
|
|
Options: &descriptorpb.MessageOptions{
|
|
|
- MapEntry: scalar.Bool(true),
|
|
|
+ MapEntry: proto.Bool(true),
|
|
|
},
|
|
|
}},
|
|
|
}, {
|
|
|
- Name: scalar.String("C"),
|
|
|
+ Name: proto.String("C"),
|
|
|
NestedType: []*descriptorpb.DescriptorProto{{
|
|
|
- Name: scalar.String("A"),
|
|
|
+ Name: proto.String("A"),
|
|
|
Field: []*descriptorpb.FieldDescriptorProto{{
|
|
|
- Name: scalar.String("F"),
|
|
|
- Number: scalar.Int32(1),
|
|
|
+ Name: proto.String("F"),
|
|
|
+ Number: proto.Int32(1),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Required).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
|
|
|
- DefaultValue: scalar.String(`dead\276\357`),
|
|
|
+ DefaultValue: proto.String(`dead\276\357`),
|
|
|
}},
|
|
|
}},
|
|
|
EnumType: []*descriptorpb.EnumDescriptorProto{{
|
|
|
- Name: scalar.String("E1"),
|
|
|
+ Name: proto.String("E1"),
|
|
|
Value: []*descriptorpb.EnumValueDescriptorProto{
|
|
|
- {Name: scalar.String("FOO"), Number: scalar.Int32(0)},
|
|
|
- {Name: scalar.String("BAR"), Number: scalar.Int32(1)},
|
|
|
+ {Name: proto.String("FOO"), Number: proto.Int32(0)},
|
|
|
+ {Name: proto.String("BAR"), Number: proto.Int32(1)},
|
|
|
},
|
|
|
}},
|
|
|
Extension: []*descriptorpb.FieldDescriptorProto{{
|
|
|
- Name: scalar.String("X"),
|
|
|
- Number: scalar.Int32(1000),
|
|
|
+ Name: proto.String("X"),
|
|
|
+ Number: proto.Int32(1000),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
|
|
|
- TypeName: scalar.String(".test.C"),
|
|
|
- Extendee: scalar.String(".test.B"),
|
|
|
+ TypeName: proto.String(".test.C"),
|
|
|
+ Extendee: proto.String(".test.B"),
|
|
|
}},
|
|
|
}},
|
|
|
EnumType: []*descriptorpb.EnumDescriptorProto{{
|
|
|
- Name: scalar.String("E1"),
|
|
|
- Options: &descriptorpb.EnumOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ Name: proto.String("E1"),
|
|
|
+ Options: &descriptorpb.EnumOptions{Deprecated: proto.Bool(true)},
|
|
|
Value: []*descriptorpb.EnumValueDescriptorProto{
|
|
|
{
|
|
|
- Name: scalar.String("FOO"),
|
|
|
- Number: scalar.Int32(0),
|
|
|
- Options: &descriptorpb.EnumValueOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ Name: proto.String("FOO"),
|
|
|
+ Number: proto.Int32(0),
|
|
|
+ Options: &descriptorpb.EnumValueOptions{Deprecated: proto.Bool(true)},
|
|
|
},
|
|
|
- {Name: scalar.String("BAR"), Number: scalar.Int32(1)},
|
|
|
+ {Name: proto.String("BAR"), Number: proto.Int32(1)},
|
|
|
},
|
|
|
ReservedName: []string{"FIZZ", "BUZZ"},
|
|
|
ReservedRange: []*descriptorpb.EnumDescriptorProto_EnumReservedRange{
|
|
|
- {Start: scalar.Int32(10), End: scalar.Int32(19)},
|
|
|
- {Start: scalar.Int32(30), End: scalar.Int32(30)},
|
|
|
+ {Start: proto.Int32(10), End: proto.Int32(19)},
|
|
|
+ {Start: proto.Int32(30), End: proto.Int32(30)},
|
|
|
},
|
|
|
}},
|
|
|
Extension: []*descriptorpb.FieldDescriptorProto{{
|
|
|
- Name: scalar.String("X"),
|
|
|
- Number: scalar.Int32(1000),
|
|
|
+ Name: proto.String("X"),
|
|
|
+ Number: proto.Int32(1000),
|
|
|
Label: descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
|
|
|
Type: descriptorpb.FieldDescriptorProto_Type(pref.EnumKind).Enum(),
|
|
|
- Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
- TypeName: scalar.String(".test.E1"),
|
|
|
- Extendee: scalar.String(".test.B"),
|
|
|
+ Options: &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
|
|
|
+ TypeName: proto.String(".test.E1"),
|
|
|
+ Extendee: proto.String(".test.B"),
|
|
|
}},
|
|
|
Service: []*descriptorpb.ServiceDescriptorProto{{
|
|
|
- Name: scalar.String("S"),
|
|
|
- Options: &descriptorpb.ServiceOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ Name: proto.String("S"),
|
|
|
+ Options: &descriptorpb.ServiceOptions{Deprecated: proto.Bool(true)},
|
|
|
Method: []*descriptorpb.MethodDescriptorProto{{
|
|
|
- Name: scalar.String("M"),
|
|
|
- InputType: scalar.String(".test.A"),
|
|
|
- OutputType: scalar.String(".test.C.A"),
|
|
|
- ClientStreaming: scalar.Bool(true),
|
|
|
- ServerStreaming: scalar.Bool(true),
|
|
|
- Options: &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ Name: proto.String("M"),
|
|
|
+ InputType: proto.String(".test.A"),
|
|
|
+ OutputType: proto.String(".test.C.A"),
|
|
|
+ ClientStreaming: proto.Bool(true),
|
|
|
+ ServerStreaming: proto.Bool(true),
|
|
|
+ Options: &descriptorpb.MethodOptions{Deprecated: proto.Bool(true)},
|
|
|
}},
|
|
|
}},
|
|
|
}
|
|
|
@@ -233,7 +232,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Path": "path/to/file.proto",
|
|
|
"Package": pref.FullName("test"),
|
|
|
"IsPlaceholder": false,
|
|
|
- "Options": &descriptorpb.FileOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.FileOptions{Deprecated: proto.Bool(true)},
|
|
|
"Messages": M{
|
|
|
"Len": 3,
|
|
|
"Get:0": M{
|
|
|
@@ -245,7 +244,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"IsPlaceholder": false,
|
|
|
"IsMapEntry": false,
|
|
|
"Options": &descriptorpb.MessageOptions{
|
|
|
- Deprecated: scalar.Bool(true),
|
|
|
+ Deprecated: proto.Bool(true),
|
|
|
},
|
|
|
"Oneofs": M{"Len": 0},
|
|
|
"RequiredNumbers": M{"Len": 0},
|
|
|
@@ -446,13 +445,13 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Len": 1,
|
|
|
"Get:0": M{
|
|
|
"Name": pref.Name("E1"),
|
|
|
- "Options": &descriptorpb.EnumOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.EnumOptions{Deprecated: proto.Bool(true)},
|
|
|
"Values": M{
|
|
|
"Len": 2,
|
|
|
"ByName:Foo": nil,
|
|
|
"ByName:FOO": M{
|
|
|
"FullName": pref.FullName("test.FOO"),
|
|
|
- "Options": &descriptorpb.EnumValueOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.EnumValueOptions{Deprecated: proto.Bool(true)},
|
|
|
},
|
|
|
"ByNumber:2": nil,
|
|
|
"ByNumber:1": M{"FullName": pref.FullName("test.BAR")},
|
|
|
@@ -492,7 +491,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"ContainingOneof": nil,
|
|
|
"ContainingMessage": M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
|
|
|
"Enum": M{"FullName": pref.FullName("test.E1"), "IsPlaceholder": false},
|
|
|
- "Options": &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
|
|
|
},
|
|
|
},
|
|
|
"Services": M{
|
|
|
@@ -502,7 +501,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Parent": M{"FullName": pref.FullName("test")},
|
|
|
"Name": pref.Name("S"),
|
|
|
"FullName": pref.FullName("test.S"),
|
|
|
- "Options": &descriptorpb.ServiceOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.ServiceOptions{Deprecated: proto.Bool(true)},
|
|
|
"Methods": M{
|
|
|
"Len": 1,
|
|
|
"Get:0": M{
|
|
|
@@ -513,7 +512,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
|
|
|
"Output": M{"FullName": pref.FullName("test.C.A"), "IsPlaceholder": false},
|
|
|
"IsStreamingClient": true,
|
|
|
"IsStreamingServer": true,
|
|
|
- "Options": &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
|
|
|
+ "Options": &descriptorpb.MethodOptions{Deprecated: proto.Bool(true)},
|
|
|
},
|
|
|
},
|
|
|
},
|