(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestOrComposeDecodeHookFunc(t *testing.T) { |
| 88 | f1 := func( |
| 89 | f reflect.Kind, |
| 90 | t reflect.Kind, |
| 91 | data interface{}) (interface{}, error) { |
| 92 | return data.(string) + "foo", nil |
| 93 | } |
| 94 | |
| 95 | f2 := func( |
| 96 | f reflect.Kind, |
| 97 | t reflect.Kind, |
| 98 | data interface{}) (interface{}, error) { |
| 99 | return data.(string) + "bar", nil |
| 100 | } |
| 101 | |
| 102 | f := OrComposeDecodeHookFunc(f1, f2) |
| 103 | |
| 104 | result, err := DecodeHookExec( |
| 105 | f, reflect.ValueOf(""), reflect.ValueOf([]byte(""))) |
| 106 | if err != nil { |
| 107 | t.Fatalf("bad: %s", err) |
| 108 | } |
| 109 | if result.(string) != "foo" { |
| 110 | t.Fatalf("bad: %#v", result) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestOrComposeDecodeHookFunc_correctValueIsLast(t *testing.T) { |
| 115 | f1 := func( |
nothing calls this directly
no test coverage detected
searching dependent graphs…