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

Function TestDecoderFlat

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

Source from the content-addressed store, hash-verified

64}
65
66func TestDecoderFlat(t *testing.T) {
67 var (
68 counter int
69 mv *MetaValue
70 body = `[
71 "1st test string",
72 "Roberto*Maestro", "Charles",
73 0, null, false,
74 1, 2.5
75]`
76 expected = []struct {
77 Value interface{}
78 ValueType ValueType
79 }{
80 {
81 "1st test string",
82 String,
83 },
84 {
85 "Roberto*Maestro",
86 String,
87 },
88 {
89 "Charles",
90 String,
91 },
92 {
93 0.0,
94 Number,
95 },
96 {
97 nil,
98 Null,
99 },
100 {
101 false,
102 Boolean,
103 },
104 {
105 1.0,
106 Number,
107 },
108 {
109 2.5,
110 Number,
111 },
112 }
113 )
114
115 decoder := NewDecoder(mkReader(body), 1)
116
117 for mv = range decoder.Stream() {
118 if mv.Value != expected[counter].Value {
119 t.Fatalf("got %v, expected: %v", mv.Value, expected[counter])
120 }
121 if mv.ValueType != expected[counter].ValueType {
122 t.Fatalf("got %v value type, expected: %v value type", mv.ValueType, expected[counter].ValueType)
123 }

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…