MCPcopy Create free account
hub / github.com/araddon/qlbridge / TestMapStringValue

Function TestMapStringValue

value/value_test.go:376–398  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

374}
375
376func TestMapStringValue(t *testing.T) {
377 msv := map[string]string{"k1": "10"}
378 v := NewMapStringValue(msv)
379 _, ok := v.Get("k1")
380 assert.True(t, ok)
381 _, ok = v.Get("nope")
382 assert.Equal(t, false, ok)
383 assert.Equal(t, 1, v.MapValue().Len())
384 lv := v.SliceValue()
385 assert.Equal(t, 1, len(lv))
386 mi := v.MapInt()
387 assert.Equal(t, 1, mi.Len())
388 assert.Equal(t, int64(10), mi.Val()["k1"])
389 mf := v.MapNumber()
390 assert.Equal(t, 1, mf.Len())
391 assert.Equal(t, float64(10), mf.Val()["k1"])
392 mb := v.MapBool()
393 assert.Equal(t, 0, mb.Len())
394 v = NewMapStringValue(map[string]string{"k1": "true"})
395 mb = v.MapBool()
396 assert.Equal(t, 1, mb.Len())
397 assert.Equal(t, true, mb.Val()["k1"])
398}
399
400func TestMapIntValue(t *testing.T) {
401 miv := map[string]int64{"k1": 10}

Callers

nothing calls this directly

Calls 10

GetMethod · 0.95
MapValueMethod · 0.95
SliceValueMethod · 0.95
MapIntMethod · 0.95
MapNumberMethod · 0.95
MapBoolMethod · 0.95
NewMapStringValueFunction · 0.85
EqualMethod · 0.65
LenMethod · 0.65
ValMethod · 0.45

Tested by

no test coverage detected