MCPcopy Create free account
hub / github.com/bcicen/jstream / TestDecoderNested

Function TestDecoderNested

decoder_test.go:29–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestDecoderNested(t *testing.T) {
30 var (
31 counter int
32 mv *MetaValue
33 body = `{
34 "1": {
35 "bio": "bada bing bada boom",
36 "id": 0,
37 "name": "Roberto",
38 "nested1": {
39 "bio": "utf16 surrogate (\ud834\udcb2)\n\u201cutf 8\u201d",
40 "id": 1.5,
41 "name": "Roberto*Maestro",
42 "nested2": { "nested2arr": [0,1,2], "nested3": {
43 "nested4": { "depth": "recursion" }}
44 }
45 }
46 },
47 "2": {
48 "nullfield": null,
49 "id": -2
50 }
51}`
52 )
53
54 decoder := NewDecoder(mkReader(body), 2)
55
56 for mv = range decoder.Stream() {
57 counter++
58 t.Logf("depth=%d offset=%d len=%d (%v)", mv.Depth, mv.Offset, mv.Length, mv.Value)
59 }
60
61 if err := decoder.Err(); err != nil {
62 t.Fatalf("decoder error: %s", err)
63 }
64}
65
66func TestDecoderFlat(t *testing.T) {
67 var (

Callers

nothing calls this directly

Calls 4

StreamMethod · 0.95
ErrMethod · 0.95
NewDecoderFunction · 0.85
mkReaderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…