From a63c7bfbb2cdc6ab5bea0906972fc76ffb6f4963 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 31 Dec 2021 15:31:02 -0500 Subject: [PATCH] json test root json --- pttodo/root_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pttodo/root_test.go diff --git a/pttodo/root_test.go b/pttodo/root_test.go new file mode 100644 index 0000000..c70b8cd --- /dev/null +++ b/pttodo/root_test.go @@ -0,0 +1,23 @@ +package pttodo + +import ( + "encoding/json" + "fmt" + "testing" +) + +func TestJSONRoot(t *testing.T) { + root := Root{ + Todo: []Todo{Todo{Todo: "todo", Detail: "detail", Schedule: "teehee", TS: 1}}, + Scheduled: []Todo{Todo{Todo: "scheduled", Detail: "detail", Schedule: "teehee", TS: 1}}, + Done: []Todo{Todo{Todo: "done", Detail: "detail", Schedule: "teehee", TS: 1}}, + } + var root2 Root + if b, err := json.Marshal(root); err != nil { + t.Fatal(err) + } else if err := json.Unmarshal(b, &root2); err != nil { + t.Fatal(err) + } else if fmt.Sprint(root) != fmt.Sprint(root2) { + t.Fatal(root, root2) + } +}