File: strings_test.go

package info (click to toggle)
golang-github-xanzy-go-gitlab 0.90.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 3,684 kB
  • sloc: makefile: 17
file content (48 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download | duplicates (4)
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)
}