()
| 2518 | } |
| 2519 | |
| 2520 | func ExampleComparisonAssertionFunc() { |
| 2521 | t := &testing.T{} // provided by test |
| 2522 | |
| 2523 | adder := func(x, y int) int { |
| 2524 | return x + y |
| 2525 | } |
| 2526 | |
| 2527 | type args struct { |
| 2528 | x int |
| 2529 | y int |
| 2530 | } |
| 2531 | |
| 2532 | tests := []struct { |
| 2533 | name string |
| 2534 | args args |
| 2535 | expect int |
| 2536 | assertion ComparisonAssertionFunc |
| 2537 | }{ |
| 2538 | {"2+2=4", args{2, 2}, 4, Equal}, |
| 2539 | {"2+2!=5", args{2, 2}, 5, NotEqual}, |
| 2540 | {"2+3==5", args{2, 3}, 5, Exactly}, |
| 2541 | } |
| 2542 | |
| 2543 | for _, tt := range tests { |
| 2544 | t.Run(tt.name, func(t *testing.T) { |
| 2545 | tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y)) |
| 2546 | }) |
| 2547 | } |
| 2548 | } |
| 2549 | |
| 2550 | func TestComparisonAssertionFunc(t *testing.T) { |
| 2551 | type iface interface { |
nothing calls this directly
no test coverage detected
searching dependent graphs…