(t *testing.T)
| 205 | } |
| 206 | |
| 207 | func TestStringToSliceHookFunc(t *testing.T) { |
| 208 | f := StringToSliceHookFunc(",") |
| 209 | |
| 210 | strValue := reflect.ValueOf("42") |
| 211 | sliceValue := reflect.ValueOf([]byte("42")) |
| 212 | cases := []struct { |
| 213 | f, t reflect.Value |
| 214 | result interface{} |
| 215 | err bool |
| 216 | }{ |
| 217 | {sliceValue, sliceValue, []byte("42"), false}, |
| 218 | {strValue, strValue, "42", false}, |
| 219 | { |
| 220 | reflect.ValueOf("foo,bar,baz"), |
| 221 | sliceValue, |
| 222 | []string{"foo", "bar", "baz"}, |
| 223 | false, |
| 224 | }, |
| 225 | { |
| 226 | reflect.ValueOf(""), |
| 227 | sliceValue, |
| 228 | []string{}, |
| 229 | false, |
| 230 | }, |
| 231 | } |
| 232 | |
| 233 | for i, tc := range cases { |
| 234 | actual, err := DecodeHookExec(f, tc.f, tc.t) |
| 235 | if tc.err != (err != nil) { |
| 236 | t.Fatalf("case %d: expected err %#v", i, tc.err) |
| 237 | } |
| 238 | if !reflect.DeepEqual(actual, tc.result) { |
| 239 | t.Fatalf( |
| 240 | "case %d: expected %#v, got %#v", |
| 241 | i, tc.result, actual) |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | func TestStringToTimeDurationHookFunc(t *testing.T) { |
| 247 | f := StringToTimeDurationHookFunc() |
nothing calls this directly
no test coverage detected
searching dependent graphs…