MCPcopy
hub / github.com/expr-lang/expr / initSpewTests

Function initSpewTests

internal/spew/spew_test.go:126–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124}
125
126func initSpewTests() {
127 // Config states with various settings.
128 scsDefault := spew.NewDefaultConfig()
129 scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true}
130 scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true}
131 scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1}
132 scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true}
133 scsNoPtrAddr := &spew.ConfigState{DisablePointerAddresses: true}
134 scsNoCap := &spew.ConfigState{DisableCapacities: true}
135
136 // Variables for tests on types which implement Stringer interface with and
137 // without a pointer receiver.
138 ts := stringer("test")
139 tps := pstringer("test")
140
141 type ptrTester struct {
142 s *struct{}
143 }
144 tptr := &ptrTester{s: &struct{}{}}
145
146 // depthTester is used to test max depth handling for structs, array, slices
147 // and maps.
148 type depthTester struct {
149 ic indirCir1
150 arr [1]string
151 slice []string
152 m map[string]int
153 }
154 dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"},
155 map[string]int{"one": 1}}
156
157 // Variable for tests on types which implement error interface.
158 te := customError(10)
159
160 spewTests = []spewTest{
161 {scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"},
162 {scsDefault, fCSFprint, "", int16(32767), "32767"},
163 {scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"},
164 {scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"},
165 {scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"},
166 {scsDefault, fCSPrintln, "", uint8(255), "255\n"},
167 {scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"},
168 {scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"},
169 {scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"},
170 {scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"},
171 {scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"},
172 {scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"},
173 {scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"},
174 {scsDefault, fFprint, "", float32(3.14), "3.14"},
175 {scsDefault, fFprintln, "", float64(6.28), "6.28\n"},
176 {scsDefault, fPrint, "", true, "true"},
177 {scsDefault, fPrintln, "", false, "false\n"},
178 {scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"},
179 {scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"},
180 {scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"},
181 {scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"},
182 {scsNoMethods, fCSFprint, "", ts, "test"},
183 {scsNoMethods, fCSFprint, "", &ts, "<*>test"},

Callers 1

TestSpewFunction · 0.85

Calls 4

NewDefaultConfigFunction · 0.92
stringerTypeAlias · 0.85
pstringerTypeAlias · 0.85
customErrorTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…