test ezpz json

This commit is contained in:
Bel LaPointe
2021-12-31 15:23:59 -05:00
parent 80af3093b0
commit 12886416b7
4 changed files with 104 additions and 1 deletions

30
pttodo/ts_test.go Normal file
View File

@@ -0,0 +1,30 @@
package pttodo
import (
"encoding/json"
"testing"
"time"
)
func TestJSONTS(t *testing.T) {
ts := TS(time.Now().Unix())
js, err := json.Marshal(ts)
if err != nil {
t.Fatal(err)
}
var ts2 TS
if err := json.Unmarshal(js, &ts2); err != nil {
t.Fatal(err)
}
if ts != ts2 {
t.Fatal(ts2)
}
if err := json.Unmarshal([]byte(`123`), &ts2); err != nil {
t.Fatal(err)
}
if 123 != ts2 {
t.Fatal(ts2)
}
}