(t *testing.T)
| 572 | } |
| 573 | |
| 574 | func TestSkipArray(t *testing.T) { |
| 575 | testCases := []struct { |
| 576 | name string |
| 577 | json string |
| 578 | expectations func(*testing.T, int, error) |
| 579 | }{ |
| 580 | { |
| 581 | name: "basic", |
| 582 | json: `"testbasic"]`, |
| 583 | expectations: func(t *testing.T, i int, err error) { |
| 584 | assert.Equal(t, len(`"testbasic"]`), i) |
| 585 | assert.Nil(t, err) |
| 586 | }, |
| 587 | }, |
| 588 | { |
| 589 | name: "complex escape string", |
| 590 | json: `"test \\\\\" escape"]`, |
| 591 | expectations: func(t *testing.T, i int, err error) { |
| 592 | assert.Equal(t, len(`"test \\\\\" escape"]`), i) |
| 593 | assert.Nil(t, err) |
| 594 | }, |
| 595 | }, |
| 596 | { |
| 597 | name: "complex escape slash", |
| 598 | json: `"test \\\\\\"]`, |
| 599 | expectations: func(t *testing.T, i int, err error) { |
| 600 | assert.Equal(t, len(`"test \\\\\\"]`), i) |
| 601 | assert.Nil(t, err) |
| 602 | }, |
| 603 | }, |
| 604 | { |
| 605 | json: `"test \n"]`, |
| 606 | expectations: func(t *testing.T, i int, err error) { |
| 607 | assert.Equal(t, len(`"test \n"]`), i) |
| 608 | assert.Nil(t, err) |
| 609 | }, |
| 610 | }, |
| 611 | } |
| 612 | |
| 613 | for _, test := range testCases { |
| 614 | t.Run(test.name, func(t *testing.T) { |
| 615 | dec := NewDecoder(strings.NewReader(test.json)) |
| 616 | i, err := dec.skipArray() |
| 617 | test.expectations(t, i, err) |
| 618 | }) |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | func TestDecodeArrayEmpty(t *testing.T) { |
| 623 | v := new(testDecodeSlice) |
nothing calls this directly
no test coverage detected
searching dependent graphs…