-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoder_test.go
63 lines (46 loc) · 967 Bytes
/
encoder_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package quacktors
import (
"github.com/Azer0s/quacktors/typeregister"
"github.com/stretchr/testify/assert"
"testing"
)
type test struct {
Foo string
Bar float32
}
func TestEncode(t *testing.T) {
val := test{
Foo: "Hello",
Bar: 12.453,
}
typeregister.Store("test", val)
b, _ := encodeValue("test", val)
valDec, _ := decodeValue("test", b)
assert.Equal(t, val, valDec)
}
type empty struct {
}
func TestEncodeEmpty(t *testing.T) {
val := empty{}
typeregister.Store("empty", val)
b, _ := encodeValue("empty", val)
valDec, _ := decodeValue("empty", b)
assert.Equal(t, val, valDec)
}
type nestingStruct struct {
Foo string
Val nestedStruct
}
type nestedStruct struct {
Bar float32
}
func TestNestedEncode(t *testing.T) {
val := nestingStruct{
Foo: "Hello",
Val: nestedStruct{Bar: 12.453},
}
typeregister.Store("test", val)
b, _ := encodeValue("test", val)
valDec, _ := decodeValue("test", b)
assert.Equal(t, val, valDec)
}