Exemple #1
0
func TestMapMaybeGet(t *testing.T) {
	assert := assert.New(t)

	m := gen.NewMapOfStringToValue()
	k1 := "key1"
	k2 := "key2"
	v1 := types.NewString("SomeValue")
	m = m.Set(k1, v1)
	v, ok := m.MaybeGet(k1)
	assert.True(ok)
	assert.Equal(v1, v)
	v, ok = m.MaybeGet(k2)
	assert.False(ok)
}
Exemple #2
0
func TestValueMapDef(t *testing.T) {
	assert := assert.New(t)

	def := gen.MapOfStringToValueDef{"s": types.NewString("s"), "i": types.Int32(42)}
	m := def.New()

	assert.Equal(uint64(2), m.Len())
	assert.True(types.NewString("s").Equals(m.Get("s")))
	assert.True(types.Int32(42).Equals(m.Get("i")))

	def2 := m.Def()
	assert.Equal(def, def2)

	m2 := gen.NewMapOfStringToValue().Set("s", types.NewString("s")).Set("i", types.Int32(42))
	assert.True(m.Equals(m2))
}