Files
go-astikit/json_test.go
Quentin Renard 31f2c16fdf Added json clone
2021-10-06 09:41:29 +02:00

33 lines
561 B
Go

package astikit
import "testing"
type jsonA struct {
A string `json:"a"`
}
type jsonB struct {
B string `json:"a"`
}
func TestJSONClone(t *testing.T) {
a := jsonA{A: "a"}
b := &jsonB{}
err := JSONClone(a, b)
if err != nil {
t.Errorf("expected no error, got %s", err)
}
if !JSONEqual(a, b) {
t.Error("expected true, got false")
}
}
func TestJSONEqual(t *testing.T) {
if JSONEqual(jsonA{A: "a"}, jsonB{B: "b"}) {
t.Error("expected false, got true")
}
if !JSONEqual(jsonA{A: "a"}, jsonB{B: "a"}) {
t.Error("expected true, got false")
}
}