This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/src/jsonld/encode_test.go

37 lines
617 B
Go
Raw Normal View History

package jsonld
import (
"encoding/json"
"testing"
)
type mock_base struct {
Id string
Name string
Type string
}
2017-09-30 20:21:51 +00:00
type mock_type_a struct {
*mock_base
PropA string
PropB float32
}
func TestMarshal(t *testing.T) {
a := mock_type_a{&mock_base{"base_id", "MockObjA", "mock_obj"}, "prop_a", 0.001}
c := Context{URL: "http://www.habarnam.ro"}
out, err := Marshal(a, &c)
if err != nil {
t.Errorf("%s", err)
}
outj, errj := json.Marshal(a)
if errj != nil {
t.Errorf("%s", errj)
}
if string(outj) != string(out) {
t.Errorf("Invalid json serialization %s != %s", outj, out)
}
t.Logf("%s", out)
}