- JSON serialization for all lists

This commit is contained in:
Emir Pasic
2017-03-06 01:05:01 +01:00
parent 51d19e739f
commit 0dcb10bcab
7 changed files with 162 additions and 0 deletions
+26
View File
@@ -426,6 +426,32 @@ func TestListIteratorLast(t *testing.T) {
}
}
func TestListSerialization(t *testing.T) {
list := New()
list.Add("a", "b", "c")
var err error
assert := func() {
if actualValue, expectedValue := fmt.Sprintf("%s%s%s", list.Values()...), "abc"; actualValue != expectedValue {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}
if actualValue, expectedValue := list.Size(), 3; actualValue != expectedValue {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}
if err != nil {
t.Errorf("Got error %v", err)
}
}
assert()
json, err := list.ToJSON()
assert()
err = list.FromJSON(json)
assert()
}
func benchmarkGet(b *testing.B, list *List, size int) {
for i := 0; i < b.N; i++ {
for n := 0; n < size; n++ {