-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathhttp_server_test.go
More file actions
40 lines (31 loc) · 1.35 KB
/
Copy pathhttp_server_test.go
File metadata and controls
40 lines (31 loc) · 1.35 KB
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
package server
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestUnmarshalJSON(t *testing.T) {
u := repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[1, 2, 3]")))
assert.Equal(t, []int64{1, 2, 3}, u.int64Val)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[1.2, 2.3, 3.4]")))
assert.Equal(t, []float64{1.2, 2.3, 3.4}, u.doubleVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[\"foo\", \"bar\"]")))
assert.Equal(t, []string{"foo", "bar"}, u.stringVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[true, false, true]")))
assert.Equal(t, []bool{true, false, true}, u.boolVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[[1, 2, 3], [4, 5, 6]]")))
assert.Equal(t, [][]int64{{1, 2, 3}, {4, 5, 6}}, u.int64ListVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[[1.2, 2.3, 3.4], [10.2, 20.3, 30.4]]")))
assert.Equal(t, [][]float64{{1.2, 2.3, 3.4}, {10.2, 20.3, 30.4}}, u.doubleListVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[[\"foo\", \"bar\"], [\"foo2\", \"bar2\"]]")))
assert.Equal(t, [][]string{{"foo", "bar"}, {"foo2", "bar2"}}, u.stringListVal)
u = repeatedValue{}
assert.Nil(t, u.UnmarshalJSON([]byte("[[true, false, true], [false, true, false]]")))
assert.Equal(t, [][]bool{{true, false, true}, {false, true, false}}, u.boolListVal)
}