-
Notifications
You must be signed in to change notification settings - Fork 1
/
print_special_pointer_test.go
130 lines (114 loc) · 2.24 KB
/
print_special_pointer_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package pprnt
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_PrintMapPointerString(t *testing.T) {
caseT := &map[string]string{
"At1": "t1",
"At2": "t2",
}
output := Print(caseT)
tests := []string{
"\t\t\"At1\": \"t1\",\n",
"\t\t\"At2\": \"t2\",\n",
}
for _, test := range tests {
if !assert.Contains(t, output, test) {
t.Fatalf("Case test failed > " + test)
}
}
}
func Test_PrintMapPointerInterface(t *testing.T) {
caseT := map[string]interface{}{
"At1": GetStringAdddress("t1"),
"At2": GetStringAdddress("t2"),
}
output := Print(caseT)
tests := []string{
"\t\t\"At1\": \"t1\",\n",
"\t\t\"At2\": \"t2\",\n",
}
for _, test := range tests {
if !assert.Contains(t, output, test) {
t.Fatalf("Case test failed > " + test)
}
}
}
func Test_PrintMapPointerValueString(t *testing.T) {
caseT := &_Test{
A: "Howdy",
B: 2,
C: true,
D: 1.5000000004,
ARR: []string{
"TEST",
},
}
output := Print(caseT)
tests := []string{
"\t\t\"A\": \"Howdy\",\n",
"\t\t\"B\": 2,\n",
"\t\t\"C\": true,\n",
"\t\t\"D\": 1.5000000004,\n",
"\t\t\"ARR\": [\n",
"\t\t\t\t\"TEST\",\n",
"\t\t],\n",
}
for _, test := range tests {
if !assert.Contains(t, output, test) {
t.Fatalf("Case test failed > " + test)
}
}
}
func Test_PrintHyperAnnidated(t *testing.T) {
caseTest := []interface{}{
&_Test{
A: "Howdy",
B: 2,
C: true,
D: 1.5000000004,
ARR: []string{
"TEST",
},
},
map[string]interface{}{
"At1": "t1",
"At2": GetStringAdddress("t2"),
"Stct1": &_Test{
A: "Cowboy",
B: 3,
C: false,
D: 1,
},
},
}
output := Print(caseTest)
tests := []string{
"\t\t{",
"\t\t\t\t\"A\": \"Howdy\",",
"\t\t\t\t\"B\": 2,",
"\t\t\t\t\"C\": true,",
"\t\t\t\t\"D\": 1.5000000004,",
"\t\t\t\t\"ARR\": [",
"\t\t\t\t\t\t\"TEST\",",
"\t\t\t\t],",
"\t\t},",
"\t\t{",
"\t\t\t\t\"At1\": \"t1\",",
"\t\t\t\t\"At2\": \"t2\",",
"\t\t\t\t\"Stct1\": {",
"\t\t\t\t\t\t\"A\": \"Cowboy\",",
"\t\t\t\t\t\t\"B\": 3,",
"\t\t\t\t\t\t\"C\": false,",
"\t\t\t\t\t\t\"D\": 1,",
"\t\t\t\t\t\t\"ARR\": [",
"\t\t\t\t\t\t],",
"\t\t}",
}
for _, test := range tests {
if !assert.Contains(t, output, test) {
t.Fatalf("Case test failed > " + test)
}
}
}