json test root json
This commit is contained in:
23
pttodo/root_test.go
Normal file
23
pttodo/root_test.go
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user