()
| 2581 | } |
| 2582 | |
| 2583 | func ExampleValueAssertionFunc() { |
| 2584 | t := &testing.T{} // provided by test |
| 2585 | |
| 2586 | dumbParse := func(input string) interface{} { |
| 2587 | var x interface{} |
| 2588 | _ = json.Unmarshal([]byte(input), &x) |
| 2589 | return x |
| 2590 | } |
| 2591 | |
| 2592 | tests := []struct { |
| 2593 | name string |
| 2594 | arg string |
| 2595 | assertion ValueAssertionFunc |
| 2596 | }{ |
| 2597 | {"true is not nil", "true", NotNil}, |
| 2598 | {"empty string is nil", "", Nil}, |
| 2599 | {"zero is not nil", "0", NotNil}, |
| 2600 | {"zero is zero", "0", Zero}, |
| 2601 | {"false is zero", "false", Zero}, |
| 2602 | } |
| 2603 | |
| 2604 | for _, tt := range tests { |
| 2605 | t.Run(tt.name, func(t *testing.T) { |
| 2606 | tt.assertion(t, dumbParse(tt.arg)) |
| 2607 | }) |
| 2608 | } |
| 2609 | } |
| 2610 | |
| 2611 | func TestValueAssertionFunc(t *testing.T) { |
| 2612 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…