MCPcopy Create free account
hub / github.com/francoispqt/gojay / TestDecoderObjectDecoderAPIFuncReadCloser

Function TestDecoderObjectDecoderAPIFuncReadCloser

decode_object_test.go:1689–1712  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1687}
1688
1689func TestDecoderObjectDecoderAPIFuncReadCloser(t *testing.T) {
1690 readCloser := ReadCloser{
1691 json: []byte(`{
1692 "test": "string",
1693 "test2": "string",
1694 "test3": "string",
1695 "test4": "string",
1696 "test5": "string",
1697 }`),
1698 }
1699 m := myMap(make(map[string]string))
1700 dec := NewDecoder(&readCloser)
1701 err := dec.DecodeObject(DecodeObjectFunc(func(dec *Decoder, k string) error {
1702 str := ""
1703 err := dec.AddString(&str)
1704 if err != nil {
1705 return err
1706 }
1707 m[k] = str
1708 return nil
1709 }))
1710 assert.Nil(t, err, "err should be nil")
1711 assert.Len(t, m, 5, "len of m should be 5")
1712}
1713
1714func TestDecoderObjectDecoderInvalidJSONError(t *testing.T) {
1715 v := &TestObj{}

Callers

nothing calls this directly

Calls 5

DecodeObjectMethod · 0.95
AddStringMethod · 0.95
NewDecoderFunction · 0.85
DecodeObjectFuncFuncType · 0.85
myMapTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…