-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyunxin_test.go
More file actions
54 lines (45 loc) · 842 Bytes
/
Copy pathyunxin_test.go
File metadata and controls
54 lines (45 loc) · 842 Bytes
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
package yunxin
import (
"net/url"
"testing"
)
func TestStringSliceEncoder(t *testing.T) {
var query = struct {
Names StringSlice `schema:"names"`
}{
Names: StringSlice{"x", "y"},
}
form := url.Values{}
err := defaultEncoder.Encode(query, form)
if err != nil {
t.Fatal(err)
}
data := form.Encode()
data, err = url.QueryUnescape(data)
if err != nil {
t.Fatal(err)
}
if data != `names=["x","y"]` {
t.Fatal(data)
}
}
func TestBasicResponse(t *testing.T) {
var r = BasicResponse{Code: 100, Desc: ""}
if r.IsSuccess() != false {
t.Fail()
}
err := r.AsError()
if _, ok := err.(*YunxinError); !ok {
t.Error(err)
}
}
type unkonwnResponse struct {
BasicResponse
}
func TestUnkonwnResponse(t *testing.T) {
var r unkonwnResponse
err := r.AsError()
if _, ok := err.(*YunxinError); !ok {
t.Error(err)
}
}