summaryrefslogtreecommitdiffstats
path: root/core/data_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/data_test.go')
-rw-r--r--core/data_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/core/data_test.go b/core/data_test.go
new file mode 100644
index 0000000..1275ef4
--- /dev/null
+++ b/core/data_test.go
@@ -0,0 +1,35 @@
+package core
+
+import (
+ "testing"
+ "time"
+
+ "github.com/google/go-cmp/cmp"
+)
+
+func TestEncoder(t *testing.T) {
+ in := Test{
+ Num1: 1,
+ Time1: time.Now().Truncate(time.Second),
+ Str1: "test string",
+ Num2: 2,
+ Bin1: []byte{0x01, 0x02, 0x03},
+ Num3: 3,
+ Str2: "こんにちは",
+ Num4: 4,
+ }
+
+ data, err := Encode(in)
+ if err != nil {
+ t.Error(err)
+ }
+
+ out, err := Decode(data)
+ if err != nil {
+ t.Error(err)
+ }
+
+ if diff := cmp.Diff(in, out); diff != "" {
+ t.Errorf("structs are different (-in +out):\n%s", diff)
+ }
+}