File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,30 @@ func TestFromTypedStructZeroFieldsIntoExistingFields(t *testing.T) {
152152 }), nv )
153153}
154154
155+ func TestFromTypedStructZeroFieldsIntoExistingFieldsFloat64 (t * testing.T ) {
156+ type Tmp struct {
157+ Foo float64 `json:"foo"`
158+ Bar float64 `json:"bar,omitempty"`
159+ BazBugz float64 `json:"baz_bugs,omitempty"`
160+ ForceSendFields []string `json:"-"`
161+ }
162+
163+ src := Tmp {ForceSendFields : []string {"BazBugz" }}
164+
165+ ref := dyn .V (map [string ]dyn.Value {
166+ "foo" : dyn .V (1.2 ),
167+ "bar" : dyn .V (1.2 ),
168+ "baz_bugs" : dyn .V (1.2 ),
169+ })
170+
171+ nv , err := FromTyped (src , ref )
172+ require .NoError (t , err )
173+ dynassert .Equal (t , dyn .V (map [string ]dyn.Value {
174+ "foo" : dyn .V (0.0 ),
175+ "baz_bugs" : dyn .V (0.0 ),
176+ }), nv )
177+ }
178+
155179func TestFromTypedStructSetFieldsRetainLocation (t * testing.T ) {
156180 type Tmp struct {
157181 Foo string `json:"foo"`
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ func (v Value) IsZero() bool {
154154 case KindInt :
155155 return v .v == 0
156156 case KindFloat :
157- return v .v == 0
157+ return v .v == 0.0
158158 case KindTime :
159159 t := v .v .(Time )
160160 return t .IsZero ()
You can’t perform that action at this time.
0 commit comments