()
| 535 | } |
| 536 | |
| 537 | func ExampleErrorAssertionFunc() { |
| 538 | t := &testing.T{} // provided by test |
| 539 | |
| 540 | dumbParseNum := func(input string, v interface{}) error { |
| 541 | return json.Unmarshal([]byte(input), v) |
| 542 | } |
| 543 | |
| 544 | tests := []struct { |
| 545 | name string |
| 546 | arg string |
| 547 | assertion ErrorAssertionFunc |
| 548 | }{ |
| 549 | {"1.2 is number", "1.2", NoError}, |
| 550 | {"1.2.3 not number", "1.2.3", Error}, |
| 551 | {"true is not number", "true", Error}, |
| 552 | {"3 is number", "3", NoError}, |
| 553 | } |
| 554 | |
| 555 | for _, tt := range tests { |
| 556 | t.Run(tt.name, func(t *testing.T) { |
| 557 | var x float64 |
| 558 | tt.assertion(t, dumbParseNum(tt.arg, &x)) |
| 559 | }) |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | func TestErrorAssertionFunc(t *testing.T) { |
| 564 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…