TestSpew executes all of the tests described by spewTests.
(t *testing.T)
| 208 | |
| 209 | // TestSpew executes all of the tests described by spewTests. |
| 210 | func TestSpew(t *testing.T) { |
| 211 | initSpewTests() |
| 212 | |
| 213 | t.Logf("Running %d tests", len(spewTests)) |
| 214 | for i, test := range spewTests { |
| 215 | buf := new(bytes.Buffer) |
| 216 | switch test.f { |
| 217 | case fCSFdump: |
| 218 | test.cs.Fdump(buf, test.in) |
| 219 | |
| 220 | case fCSFprint: |
| 221 | test.cs.Fprint(buf, test.in) |
| 222 | |
| 223 | case fCSFprintf: |
| 224 | test.cs.Fprintf(buf, test.format, test.in) |
| 225 | |
| 226 | case fCSFprintln: |
| 227 | test.cs.Fprintln(buf, test.in) |
| 228 | |
| 229 | case fCSPrint: |
| 230 | b, err := redirStdout(func() { test.cs.Print(test.in) }) |
| 231 | if err != nil { |
| 232 | t.Errorf("%v #%d %v", test.f, i, err) |
| 233 | continue |
| 234 | } |
| 235 | buf.Write(b) |
| 236 | |
| 237 | case fCSPrintln: |
| 238 | b, err := redirStdout(func() { test.cs.Println(test.in) }) |
| 239 | if err != nil { |
| 240 | t.Errorf("%v #%d %v", test.f, i, err) |
| 241 | continue |
| 242 | } |
| 243 | buf.Write(b) |
| 244 | |
| 245 | case fCSSdump: |
| 246 | str := test.cs.Sdump(test.in) |
| 247 | buf.WriteString(str) |
| 248 | |
| 249 | case fCSSprint: |
| 250 | str := test.cs.Sprint(test.in) |
| 251 | buf.WriteString(str) |
| 252 | |
| 253 | case fCSSprintf: |
| 254 | str := test.cs.Sprintf(test.format, test.in) |
| 255 | buf.WriteString(str) |
| 256 | |
| 257 | case fCSSprintln: |
| 258 | str := test.cs.Sprintln(test.in) |
| 259 | buf.WriteString(str) |
| 260 | |
| 261 | case fCSErrorf: |
| 262 | err := test.cs.Errorf(test.format, test.in) |
| 263 | buf.WriteString(err.Error()) |
| 264 | |
| 265 | case fCSNewFormatter: |
| 266 | fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in)) |
| 267 |
nothing calls this directly
no test coverage detected
searching dependent graphs…