(t *testing.T)
| 1533 | } |
| 1534 | |
| 1535 | func TestDecoderInputOffset(t *testing.T) { |
| 1536 | checkOffset := func(o, expected int64) { |
| 1537 | if o != expected { |
| 1538 | t.Error("unexpected input offset", o, expected) |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | b := []byte(`{"userId": "blah"}{"userId": "blah"} |
| 1543 | {"userId": "blah"}{"num": 0}`) |
| 1544 | d := NewDecoder(bytes.NewReader(b)) |
| 1545 | |
| 1546 | var expected int64 |
| 1547 | checkOffset(d.InputOffset(), expected) |
| 1548 | |
| 1549 | var a struct { |
| 1550 | UserId string `json:"userId"` |
| 1551 | } |
| 1552 | |
| 1553 | if err := d.Decode(&a); err != nil { |
| 1554 | t.Error("unexpected decode error", err) |
| 1555 | } |
| 1556 | expected = int64(18) |
| 1557 | checkOffset(d.InputOffset(), expected) |
| 1558 | |
| 1559 | if err := d.Decode(&a); err != nil { |
| 1560 | t.Error("unexpected decode error", err) |
| 1561 | } |
| 1562 | expected = int64(38) |
| 1563 | checkOffset(d.InputOffset(), expected) |
| 1564 | |
| 1565 | if err := d.Decode(&a); err != nil { |
| 1566 | t.Error("unexpected decode error", err) |
| 1567 | } |
| 1568 | expected = int64(56) |
| 1569 | checkOffset(d.InputOffset(), expected) |
| 1570 | |
| 1571 | var z struct { |
| 1572 | Num int64 `json:"num"` |
| 1573 | } |
| 1574 | if err := d.Decode(&z); err != nil { |
| 1575 | t.Error("unexpected decode error", err) |
| 1576 | } |
| 1577 | expected = int64(66) |
| 1578 | checkOffset(d.InputOffset(), expected) |
| 1579 | } |
| 1580 | |
| 1581 | func TestGithubIssue18(t *testing.T) { |
| 1582 | // https://github.com/segmentio/encoding/issues/18 |
nothing calls this directly
no test coverage detected
searching dependent graphs…