One of the few ways reflectValues will return an error is if a custom encoder returns an error. Test all of the various ways that can happen.
(t *testing.T)
| 487 | // One of the few ways reflectValues will return an error is if a custom |
| 488 | // encoder returns an error. Test all of the various ways that can happen. |
| 489 | func TestValues_CustomEncoding_Error(t *testing.T) { |
| 490 | type st struct { |
| 491 | V customEncodedStrings |
| 492 | } |
| 493 | tests := []struct { |
| 494 | input interface{} |
| 495 | }{ |
| 496 | { |
| 497 | st{[]string{"err"}}, |
| 498 | }, |
| 499 | { // struct field |
| 500 | struct{ S st }{st{[]string{"err"}}}, |
| 501 | }, |
| 502 | { // embedded struct |
| 503 | struct{ st }{st{[]string{"err"}}}, |
| 504 | }, |
| 505 | } |
| 506 | for _, tt := range tests { |
| 507 | _, err := Values(tt.input) |
| 508 | if err == nil { |
| 509 | t.Errorf("Values(%q) did not return expected encoding error", tt.input) |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | // customEncodedInt is an int with a custom URL encoding |
| 515 | type customEncodedInt int |
nothing calls this directly
no test coverage detected
searching dependent graphs…