Implements json.Marshaler and json.Unmarshaler interfaces

This commit is contained in:
Emir Pasic
2022-04-12 04:31:44 +02:00
parent b5735bcc4d
commit 1f0b87f0e1
35 changed files with 183 additions and 104 deletions
+8 -2
View File
@@ -5,6 +5,7 @@
package arraystack
import (
"encoding/json"
"fmt"
"strings"
"testing"
@@ -360,11 +361,16 @@ func TestStackSerialization(t *testing.T) {
assert()
json, err := stack.ToJSON()
bytes, err := stack.ToJSON()
assert()
err = stack.FromJSON(json)
err = stack.FromJSON(bytes)
assert()
bytes, err = json.Marshal([]interface{}{"a", "b", "c", stack})
if err != nil {
t.Errorf("Got error %v", err)
}
}
func benchmarkPush(b *testing.B, stack *Stack, size int) {