@@ -550,28 +550,28 @@ func TestMarshalJSONPBMarshaler(t *testing.T) {
550
550
msg := dynamicMessage {RawJson : rawJson }
551
551
str , err := new (Marshaler ).MarshalToString (& msg )
552
552
if err != nil {
553
- t .Errorf ("an unexpected error occurred when marshalling JSONPBMarshaler: %v" , err )
553
+ t .Errorf ("an unexpected error while marshaling JSONPBMarshaler: %v" , err )
554
554
}
555
555
if str != rawJson {
556
- t .Errorf ("marshalling JSON produced incorrect output: got %s, wanted %s" , str , rawJson )
556
+ t .Errorf ("marshaling JSON produced incorrect output: got %s, wanted %s" , str , rawJson )
557
557
}
558
558
}
559
559
560
560
func TestMarshalAnyJSONPBMarshaler (t * testing.T ) {
561
561
msg := dynamicMessage {RawJson : `{ "foo": "bar", "baz": [0, 1, 2, 3] }` }
562
562
a , err := ptypes .MarshalAny (& msg )
563
563
if err != nil {
564
- t .Errorf ("an unexpected error occurred when marshalling to Any: %v" , err )
564
+ t .Errorf ("an unexpected error while marshaling to Any: %v" , err )
565
565
}
566
566
str , err := new (Marshaler ).MarshalToString (a )
567
567
if err != nil {
568
- t .Errorf ("an unexpected error occurred when marshalling Any to JSON: %v" , err )
568
+ t .Errorf ("an unexpected error while marshaling Any to JSON: %v" , err )
569
569
}
570
570
// after custom marshaling, it's round-tripped through JSON decoding/encoding already,
571
571
// so the keys are sorted, whitespace is compacted, and "@type" key has been added
572
- expected := `{"@type":"type.googleapis.com/` + dynamicMessageName + `","baz":[0,1,2,3],"foo":"bar"}`
573
- if str != expected {
574
- t .Errorf ("marshalling JSON produced incorrect output: got %s, wanted %s" , str , expected )
572
+ want := `{"@type":"type.googleapis.com/` + dynamicMessageName + `","baz":[0,1,2,3],"foo":"bar"}`
573
+ if str != want {
574
+ t .Errorf ("marshaling JSON produced incorrect output: got %s, wanted %s" , str , want )
575
575
}
576
576
}
577
577
@@ -580,11 +580,11 @@ func TestMarshalWithCustomValidation(t *testing.T) {
580
580
581
581
js , err := new (Marshaler ).MarshalToString (& msg )
582
582
if err != nil {
583
- t .Errorf ("an unexpected error occurred when marshalling to json: %v" , err )
583
+ t .Errorf ("an unexpected error while marshaling to json: %v" , err )
584
584
}
585
585
err = Unmarshal (strings .NewReader (js ), & msg )
586
586
if err != nil {
587
- t .Errorf ("an unexpected error occurred when unmarshalling from json: %v" , err )
587
+ t .Errorf ("an unexpected error while unmarshaling from json: %v" , err )
588
588
}
589
589
}
590
590
@@ -668,7 +668,7 @@ func TestMarshalUnsetRequiredFields(t *testing.T) {
668
668
669
669
for _ , tc := range tests {
670
670
if _ , err := tc .marshaler .MarshalToString (tc .pb ); err == nil {
671
- t .Errorf ("%s: expecting error in marshaling with unset required fields %+v" , tc .desc , tc .pb )
671
+ t .Errorf ("%s: expected error while marshaling with unset required fields %+v" , tc .desc , tc .pb )
672
672
}
673
673
}
674
674
}
@@ -822,12 +822,12 @@ var unmarshalingTests = []struct {
822
822
823
823
func TestUnmarshaling (t * testing.T ) {
824
824
for _ , tt := range unmarshalingTests {
825
- // Make a new instance of the type of our expected object.
825
+ // Make a new instance of the type of our wanted object.
826
826
p := reflect .New (reflect .TypeOf (tt .pb ).Elem ()).Interface ().(proto.Message )
827
827
828
828
err := tt .unmarshaler .Unmarshal (strings .NewReader (tt .json ), p )
829
829
if err != nil {
830
- t .Errorf ("unmarshalling %s: %v" , tt .desc , err )
830
+ t .Errorf ("unmarshaling %s: %v" , tt .desc , err )
831
831
continue
832
832
}
833
833
@@ -872,7 +872,7 @@ func TestUnmarshalNext(t *testing.T) {
872
872
873
873
dec := json .NewDecoder (& b )
874
874
for _ , tt := range tests {
875
- // Make a new instance of the type of our expected object.
875
+ // Make a new instance of the type of our wanted object.
876
876
p := reflect .New (reflect .TypeOf (tt .pb ).Elem ()).Interface ().(proto.Message )
877
877
878
878
err := tt .unmarshaler .UnmarshalNext (dec , p )
@@ -892,7 +892,7 @@ func TestUnmarshalNext(t *testing.T) {
892
892
p := & pb2.Simple {}
893
893
err := new (Unmarshaler ).UnmarshalNext (dec , p )
894
894
if err != io .EOF {
895
- t .Errorf ("eof: got %v, expected io.EOF" , err )
895
+ t .Errorf ("eof: got %v, want io.EOF" , err )
896
896
}
897
897
}
898
898
@@ -918,7 +918,7 @@ func TestUnmarshalingBadInput(t *testing.T) {
918
918
for _ , tt := range unmarshalingShouldError {
919
919
err := UnmarshalString (tt .in , tt .pb )
920
920
if err == nil {
921
- t .Errorf ("an error was expected when parsing %q instead of an object " , tt .desc )
921
+ t .Errorf ("expected error while parsing %q" , tt .desc )
922
922
}
923
923
}
924
924
}
@@ -943,7 +943,7 @@ func TestAnyWithCustomResolver(t *testing.T) {
943
943
}
944
944
msgBytes , err := proto .Marshal (msg )
945
945
if err != nil {
946
- t .Errorf ("an unexpected error occurred when marshaling message: %v" , err )
946
+ t .Errorf ("an unexpected error while marshaling message: %v" , err )
947
947
}
948
948
// make an Any with a type URL that won't resolve w/out custom resolver
949
949
any := & anypb.Any {
@@ -954,7 +954,7 @@ func TestAnyWithCustomResolver(t *testing.T) {
954
954
m := Marshaler {AnyResolver : resolver }
955
955
js , err := m .MarshalToString (any )
956
956
if err != nil {
957
- t .Errorf ("an unexpected error occurred when marshaling any to JSON: %v" , err )
957
+ t .Errorf ("an unexpected error while marshaling any to JSON: %v" , err )
958
958
}
959
959
if len (resolvedTypeUrls ) != 1 {
960
960
t .Errorf ("custom resolver was not invoked during marshaling" )
@@ -963,33 +963,33 @@ func TestAnyWithCustomResolver(t *testing.T) {
963
963
}
964
964
wanted := `{"@type":"https://foobar.com/some.random.MessageKind","oBool":true,"oInt64":"1020304","oString":"foobar","oBytes":"AQIDBA=="}`
965
965
if js != wanted {
966
- t .Errorf ("marshalling JSON produced incorrect output: got %s, wanted %s" , js , wanted )
966
+ t .Errorf ("marshaling JSON produced incorrect output: got %s, wanted %s" , js , wanted )
967
967
}
968
968
969
969
u := Unmarshaler {AnyResolver : resolver }
970
970
roundTrip := & anypb.Any {}
971
971
err = u .Unmarshal (bytes .NewReader ([]byte (js )), roundTrip )
972
972
if err != nil {
973
- t .Errorf ("an unexpected error occurred when unmarshaling any from JSON: %v" , err )
973
+ t .Errorf ("an unexpected error while unmarshaling any from JSON: %v" , err )
974
974
}
975
975
if len (resolvedTypeUrls ) != 2 {
976
976
t .Errorf ("custom resolver was not invoked during marshaling" )
977
977
} else if resolvedTypeUrls [1 ] != "https://foobar.com/some.random.MessageKind" {
978
978
t .Errorf ("custom resolver was invoked with wrong URL: got %q, wanted %q" , resolvedTypeUrls [1 ], "https://foobar.com/some.random.MessageKind" )
979
979
}
980
980
if ! proto .Equal (any , roundTrip ) {
981
- t .Errorf ("message contents not set correctly after unmarshalling JSON: got %s, wanted %s" , roundTrip , any )
981
+ t .Errorf ("message contents not set correctly after unmarshaling JSON: got %s, wanted %s" , roundTrip , any )
982
982
}
983
983
}
984
984
985
985
func TestUnmarshalJSONPBUnmarshaler (t * testing.T ) {
986
986
rawJson := `{ "foo": "bar", "baz": [0, 1, 2, 3] }`
987
987
var msg dynamicMessage
988
988
if err := Unmarshal (strings .NewReader (rawJson ), & msg ); err != nil {
989
- t .Errorf ("an unexpected error occurred when parsing into JSONPBUnmarshaler: %v" , err )
989
+ t .Errorf ("an unexpected error while parsing into JSONPBUnmarshaler: %v" , err )
990
990
}
991
991
if msg .RawJson != rawJson {
992
- t .Errorf ("message contents not set correctly after unmarshalling JSON: got %s, wanted %s" , msg .RawJson , rawJson )
992
+ t .Errorf ("message contents not set correctly after unmarshaling JSON: got %s, wanted %s" , msg .RawJson , rawJson )
993
993
}
994
994
}
995
995
@@ -1010,20 +1010,20 @@ func TestUnmarshalAnyJSONPBUnmarshaler(t *testing.T) {
1010
1010
rawJson := `{ "@type": "blah.com/` + dynamicMessageName + `", "foo": "bar", "baz": [0, 1, 2, 3] }`
1011
1011
var got anypb.Any
1012
1012
if err := Unmarshal (strings .NewReader (rawJson ), & got ); err != nil {
1013
- t .Errorf ("an unexpected error occurred when parsing into JSONPBUnmarshaler: %v" , err )
1013
+ t .Errorf ("an unexpected error while parsing into JSONPBUnmarshaler: %v" , err )
1014
1014
}
1015
1015
1016
1016
dm := & dynamicMessage {RawJson : `{"baz":[0,1,2,3],"foo":"bar"}` }
1017
1017
var want anypb.Any
1018
1018
if b , err := proto .Marshal (dm ); err != nil {
1019
- t .Errorf ("an unexpected error occurred when marshaling message: %v" , err )
1019
+ t .Errorf ("an unexpected error while marshaling message: %v" , err )
1020
1020
} else {
1021
1021
want .TypeUrl = "blah.com/" + dynamicMessageName
1022
1022
want .Value = b
1023
1023
}
1024
1024
1025
1025
if ! proto .Equal (& got , & want ) {
1026
- t .Errorf ("message contents not set correctly after unmarshalling JSON: got %v, wanted %v" , & got , & want )
1026
+ t .Errorf ("message contents not set correctly after unmarshaling JSON: got %v, wanted %v" , & got , & want )
1027
1027
}
1028
1028
}
1029
1029
@@ -1247,7 +1247,7 @@ func TestUnmarshalUnsetRequiredFields(t *testing.T) {
1247
1247
1248
1248
for _ , tc := range tests {
1249
1249
if err := UnmarshalString (tc .json , tc .pb ); err == nil {
1250
- t .Errorf ("%s: expecting error in unmarshaling with unset required fields %s" , tc .desc , tc .json )
1250
+ t .Errorf ("%s: expected error while unmarshaling with unset required fields %s" , tc .desc , tc .json )
1251
1251
}
1252
1252
}
1253
1253
}
0 commit comments