mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-14 16:06:42 +03:00
- JSON serialization for all lists
This commit is contained in:
@@ -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++ {
|
||||
|
||||
Reference in New Issue
Block a user