| 323 | } |
| 324 | |
| 325 | func TestValue_GetArray(t *testing.T) { |
| 326 | type myArray []interface{} |
| 327 | |
| 328 | cases := []struct { |
| 329 | name string |
| 330 | data interface{} |
| 331 | result chainResult |
| 332 | expectedArray []interface{} |
| 333 | }{ |
| 334 | { |
| 335 | name: "array", |
| 336 | data: []interface{}{"foo", 123.0}, |
| 337 | result: success, |
| 338 | expectedArray: []interface{}{"foo", 123.0}, |
| 339 | }, |
| 340 | { |
| 341 | name: "myArray", |
| 342 | data: myArray{"foo", 123.0}, |
| 343 | result: success, |
| 344 | expectedArray: []interface{}(myArray{"foo", 123.0}), |
| 345 | }, |
| 346 | } |
| 347 | |
| 348 | for _, tc := range cases { |
| 349 | t.Run(tc.name, func(t *testing.T) { |
| 350 | reporter := newMockReporter(t) |
| 351 | |
| 352 | value := NewValue(reporter, tc.data) |
| 353 | inner := value.Array() |
| 354 | |
| 355 | value.chain.assert(t, tc.result) |
| 356 | inner.chain.assert(t, tc.result) |
| 357 | |
| 358 | if tc.result { |
| 359 | assert.Equal(t, tc.expectedArray, inner.Raw()) |
| 360 | } |
| 361 | }) |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | func TestValue_GetString(t *testing.T) { |
| 366 | type myString string |