@@ -34,7 +34,6 @@ package jsonpb
34
34
import (
35
35
"bytes"
36
36
"encoding/json"
37
- "errors"
38
37
"io"
39
38
"math"
40
39
"reflect"
@@ -535,7 +534,7 @@ func TestMarshalAnyJSONPBMarshaler(t *testing.T) {
535
534
}
536
535
537
536
func TestMarshalWithCustomValidation (t * testing.T ) {
538
- msg := dynamicMessage {rawJson : `{ "foo": "bar", "baz": [0, 1, 2, 3] }` , dummy1 : & dynamicMessage {}}
537
+ msg := dynamicMessage {rawJson : `{ "foo": "bar", "baz": [0, 1, 2, 3] }` , dummy : & dynamicMessage {}}
539
538
540
539
js , err := new (Marshaler ).MarshalToString (& msg )
541
540
if err != nil {
@@ -545,13 +544,6 @@ func TestMarshalWithCustomValidation(t *testing.T) {
545
544
if err != nil {
546
545
t .Errorf ("an unexpected error occurred when unmarshalling from json: %v" , err )
547
546
}
548
-
549
- // tickle an error in custom validation
550
- msg .dummy2 = int32 (len (msg .rawJson ) + 1 )
551
- _ , err = new (Marshaler ).MarshalToString (& msg )
552
- if err == nil {
553
- t .Errorf ("marshalling to json should have generated validation error but did not" )
554
- }
555
547
}
556
548
557
549
// Test marshaling message containing unset required fields should produce error.
@@ -1028,10 +1020,7 @@ type dynamicMessage struct {
1028
1020
1029
1021
// an unexported nested message is present just to ensure that it
1030
1022
// won't result in a panic (see issue #509)
1031
- dummy1 * dynamicMessage `protobuf:"bytes,2,opt,name=dummy1"`
1032
-
1033
- // this is used to implement a custom validation rule
1034
- dummy2 int32 `protobuf:"varint,3,opt,name=dummy2"`
1023
+ dummy * dynamicMessage `protobuf:"bytes,2,opt,name=dummy"`
1035
1024
}
1036
1025
1037
1026
func (m * dynamicMessage ) Reset () {
@@ -1054,13 +1043,6 @@ func (m *dynamicMessage) UnmarshalJSONPB(jum *Unmarshaler, js []byte) error {
1054
1043
return nil
1055
1044
}
1056
1045
1057
- func (m * dynamicMessage ) ValidateRecursive () error {
1058
- if int (m .dummy2 ) > len (m .rawJson ) {
1059
- return errors .New ("dummy2 should be <= rawJson length" )
1060
- }
1061
- return nil
1062
- }
1063
-
1064
1046
// Test unmarshaling message containing unset required fields should produce error.
1065
1047
func TestUnmarshalUnsetRequiredFields (t * testing.T ) {
1066
1048
tests := []struct {
0 commit comments