lib/ur: Zero our the value before unmarshal (#6790)

* lib/ur: Zero our the value before unmarshal

* Comment

* Complete rewrite
This commit is contained in:
Audrius Butkevicius
2020-06-23 21:23:32 +01:00
committed by GitHub
parent 78d294f78c
commit bb76311ec6
2 changed files with 28 additions and 0 deletions
+24
View File
@@ -128,3 +128,27 @@ func expect(t *testing.T, since int, b interface{}) {
t.Errorf("%#v != %#v", x, b)
}
}
func TestMarshallingBehaviour(t *testing.T) {
r := Report{}
if err := r.Scan([]byte(`{"folderUses":{"sendonly": 100}}`)); err != nil {
t.Fatal(err)
}
if r.FolderUses.SendOnly != 100 {
t.Errorf("%d != 100", r.FolderUses.SendOnly)
}
if err := r.Scan([]byte(`{"folderUses":{"sendreceive": 200}}`)); err != nil {
t.Fatal(err)
}
if r.FolderUses.SendReceive != 200 {
t.Errorf("%d != 200", r.FolderUses.SendReceive)
}
if r.FolderUses.SendOnly != 0 {
t.Errorf("%d != 0", r.FolderUses.SendOnly)
}
}