MCPcopy Index your code
hub / github.com/segmentio/encoding / TestGithubIssue18

Function TestGithubIssue18

json/json_test.go:1581–1606  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1579}
1580
1581func 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
1608func TestGithubIssue23(t *testing.T) {
1609 t.Run("marshal-1", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

DecodeMethod · 0.95
NewDecoderFunction · 0.70
NewReaderMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…