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

Function TestMapValue

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

Source from the content-addressed store, hash-verified

348 assert.Equal(t, 2, len(v.Values()))
349}
350func TestMapValue(t *testing.T) {
351 mv := map[string]interface{}{"k1": 10}
352 v := NewMapValue(mv)
353 _, ok := v.Get("k1")
354 assert.True(t, ok)
355 _, ok = v.Get("nope")
356 assert.Equal(t, false, ok)
357 assert.Equal(t, 1, v.MapValue().Len())
358 mi := v.MapInt()
359 assert.Equal(t, 1, len(mi))
360 assert.Equal(t, int64(10), mi["k1"])
361 mf := v.MapFloat()
362 assert.Equal(t, 1, len(mf))
363 assert.Equal(t, float64(10), mf["k1"])
364 ms := v.MapString()
365 assert.Equal(t, 1, len(mf))
366 assert.Equal(t, "10", ms["k1"])
367 v = NewMapValue(map[string]interface{}{"k1": "hello"})
368 mt := v.MapTime()
369 assert.Equal(t, 0, mt.Len())
370 v = NewMapValue(map[string]interface{}{"k1": "now-4d"})
371 mt = v.MapTime()
372 assert.Equal(t, 1, mt.Len())
373 assert.True(t, mt.Val()["k1"].Unix() > 10000)
374}
375
376func TestMapStringValue(t *testing.T) {
377 msv := map[string]string{"k1": "10"}

Callers

nothing calls this directly

Calls 10

GetMethod · 0.95
MapValueMethod · 0.95
MapIntMethod · 0.95
MapFloatMethod · 0.95
MapStringMethod · 0.95
MapTimeMethod · 0.95
NewMapValueFunction · 0.85
EqualMethod · 0.65
LenMethod · 0.65
ValMethod · 0.45

Tested by

no test coverage detected