Commit e5043ff0 authored by Brendan O'Brien's avatar Brendan O'Brien Committed by Steven Allen

add basic single quote test, restore key test on marshal cases

parent 5fc52816
......@@ -163,6 +163,7 @@ func TestKeyMarshalJSON(t *testing.T) {
err string
}{
{NewKey("/a/b/c"), []byte("\"/a/b/c\""), ""},
{NewKey("/shouldescapekey\"/with/quote"), []byte("\"/shouldescapekey\"/with/quote\""), ""},
}
for i, c := range cases {
......@@ -173,6 +174,16 @@ func TestKeyMarshalJSON(t *testing.T) {
if !bytes.Equal(c.data, out) {
t.Errorf("case %d value mismatch: expected: %s, got: %s", i, string(c.data), string(out))
}
if c.err == "" {
key := Key{}
if err := key.UnmarshalJSON(out); err != nil {
t.Errorf("case %d error parsing key from json output: %s", i, err.Error())
}
if !c.key.Equal(key) {
t.Errorf("case %d parsed key from json output mismatch. expected: %s, got: %s", i, c.key.String(), key.String())
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment