(t *testing.T)
| 1579 | } |
| 1580 | |
| 1581 | func TestGithubIssue18(t *testing.T) { |
| 1582 | // https://github.com/segmentio/encoding/issues/18 |
| 1583 | b := []byte(`{ |
| 1584 | "userId": "blah", |
| 1585 | }`) |
| 1586 | |
| 1587 | d := NewDecoder(bytes.NewReader(b)) |
| 1588 | |
| 1589 | var a struct { |
| 1590 | UserId string `json:"userId"` |
| 1591 | } |
| 1592 | switch err := d.Decode(&a).(type) { |
| 1593 | case *SyntaxError: |
| 1594 | default: |
| 1595 | t.Error("expected syntax error but found:", err) |
| 1596 | } |
| 1597 | |
| 1598 | for i := 1; i <= 18; i++ { // up to the invalid ',' character |
| 1599 | d := NewDecoder(bytes.NewReader(b[:i])) // cut somewhere in the middle |
| 1600 | switch err := d.Decode(&a); err { |
| 1601 | case io.ErrUnexpectedEOF: |
| 1602 | default: |
| 1603 | t.Error("expected 'unexpected EOF' error but found:", err) |
| 1604 | } |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | func TestGithubIssue23(t *testing.T) { |
| 1609 | t.Run("marshal-1", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…