forked from xanzy/go-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings_test.go
48 lines (40 loc) · 1.07 KB
/
strings_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
package gitlab
import (
"testing"
"github.com/stretchr/testify/assert"
)
type Person struct {
Name string
Age int
NickNames []string
Address Address
Company *Company
}
type Address struct {
Street string
City string
Province string
Country string
}
type Company struct {
Name string
Address Address
Country string
}
func TestStringify_nil(t *testing.T) {
var person *Person
resp := Stringify(person)
assert.Equal(t, "<nil>", resp)
}
func TestStringify(t *testing.T) {
person := &Person{"name", 16, []string{"n", "a", "m", "e"}, Address{}, nil}
resp := Stringify(person)
want := "gitlab.Person{Name:\"name\", Age:16, NickNames:[\"n\" \"a\" \"m\" \"e\"], Address:gitlab.Address{Street:\"\", City:\"\", Province:\"\", Country:\"\"}}"
assert.Equal(t, want, resp)
}
func TestStringify_emptySlice(t *testing.T) {
person := &Person{"name", 16, nil, Address{}, nil}
resp := Stringify(person)
want := "gitlab.Person{Name:\"name\", Age:16, Address:gitlab.Address{Street:\"\", City:\"\", Province:\"\", Country:\"\"}}"
assert.Equal(t, want, resp)
}