()
| 444 | } |
| 445 | |
| 446 | func ExampleValueAssertionFunc() { |
| 447 | t := &testing.T{} // provided by test |
| 448 | |
| 449 | dumbParse := func(input string) interface{} { |
| 450 | var x interface{} |
| 451 | json.Unmarshal([]byte(input), &x) |
| 452 | return x |
| 453 | } |
| 454 | |
| 455 | tests := []struct { |
| 456 | name string |
| 457 | arg string |
| 458 | assertion ValueAssertionFunc |
| 459 | }{ |
| 460 | {"true is not nil", "true", NotNil}, |
| 461 | {"empty string is nil", "", Nil}, |
| 462 | {"zero is not nil", "0", NotNil}, |
| 463 | {"zero is zero", "0", Zero}, |
| 464 | {"false is zero", "false", Zero}, |
| 465 | } |
| 466 | |
| 467 | for _, tt := range tests { |
| 468 | t.Run(tt.name, func(t *testing.T) { |
| 469 | tt.assertion(t, dumbParse(tt.arg)) |
| 470 | }) |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | func TestValueAssertionFunc(t *testing.T) { |
| 475 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…