| 2834 | } |
| 2835 | |
| 2836 | func ExampleBoolAssertionFunc() { |
| 2837 | t := &testing.T{} // provided by test |
| 2838 | |
| 2839 | isOkay := func(x int) bool { |
| 2840 | return x >= 42 |
| 2841 | } |
| 2842 | |
| 2843 | tests := []struct { |
| 2844 | name string |
| 2845 | arg int |
| 2846 | assertion BoolAssertionFunc |
| 2847 | }{ |
| 2848 | {"-1 is bad", -1, False}, |
| 2849 | {"42 is good", 42, True}, |
| 2850 | {"41 is bad", 41, False}, |
| 2851 | {"45 is cool", 45, True}, |
| 2852 | } |
| 2853 | |
| 2854 | for _, tt := range tests { |
| 2855 | t.Run(tt.name, func(t *testing.T) { |
| 2856 | tt.assertion(t, isOkay(tt.arg)) |
| 2857 | }) |
| 2858 | } |
| 2859 | } |
| 2860 | |
| 2861 | func TestBoolAssertionFunc(t *testing.T) { |
| 2862 | tests := []struct { |