MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestParse

Function TestParse

IceFireDB-PubSub/test/proto/proto_test.go:150–200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestParse(t *testing.T) {
151 t.Run("int", func(t *testing.T) {
152 have, err := Parse(Int(42))
153 if err != nil {
154 t.Errorf("read: %s", err)
155 }
156 if want := 42; !reflect.DeepEqual(have, want) {
157 t.Errorf("have %q, want %q", have, want)
158 }
159 })
160
161 t.Run("inline", func(t *testing.T) {
162 have, err := Parse(Inline("foo"))
163 if err != nil {
164 t.Errorf("read: %s", err)
165 }
166 if want := "foo"; !reflect.DeepEqual(have, want) {
167 t.Errorf("have %q, want %q", have, want)
168 }
169 })
170
171 t.Run("string", func(t *testing.T) {
172 have, err := Parse(String("foo"))
173 if err != nil {
174 t.Errorf("read: %s", err)
175 }
176 if want := "foo"; !reflect.DeepEqual(have, want) {
177 t.Errorf("have %q, want %q", have, want)
178 }
179 })
180
181 t.Run("strings", func(t *testing.T) {
182 have, err := Parse(Strings("foo", "bar"))
183 if err != nil {
184 t.Errorf("read: %s", err)
185 }
186 if want := []any{"foo", "bar"}; !reflect.DeepEqual(have, want) {
187 t.Errorf("have %q, want %q", have, want)
188 }
189 })
190
191 t.Run("string map", func(t *testing.T) {
192 have, err := Parse(StringMap("foo", "bar", "aap", "noot"))
193 if err != nil {
194 t.Errorf("read: %s", err)
195 }
196 if want := map[any]any{"foo": "bar", "aap": "noot"}; !reflect.DeepEqual(have, want) {
197 t.Errorf("have %q, want %q", have, want)
198 }
199 })
200}

Callers

nothing calls this directly

Calls 7

ParseFunction · 0.70
IntFunction · 0.70
InlineFunction · 0.70
StringFunction · 0.70
StringsFunction · 0.70
StringMapFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected