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

	m := gen.MapOfBoolToStringDef{true: "hi", false: "bye"}.New()
	acc := gen.NewMapOfBoolToString()
	m.IterAll(func(k bool, v string) {
		acc = acc.Set(k, v)
	})
	assert.True(m.Equals(acc))
}
Exemple #2
0
func TestMapFilter(t *testing.T) {
	assert := assert.New(t)

	m := gen.MapOfBoolToStringDef{true: "hi", false: "bye"}.New()
	m2 := m.Filter(func(k bool, v string) bool {
		return k
	})
	assert.True(gen.NewMapOfBoolToString().Set(true, "hi").Equals(m2))

	m3 := m.Filter(func(k bool, v string) bool {
		return v == "bye"
	})
	assert.True(gen.NewMapOfBoolToString().Set(false, "bye").Equals(m3))
}
Exemple #3
0
func TestMapDef(t *testing.T) {
	assert := assert.New(t)

	def := gen.MapOfBoolToStringDef{true: "hi", false: "bye"}
	m := def.New()

	assert.Equal(uint64(2), m.Len())
	assert.Equal("hi", m.Get(true))
	assert.Equal("bye", m.Get(false))

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

	m2 := gen.NewMapOfBoolToString().Set(true, "hi").Set(false, "bye")
	assert.True(m.Equals(m2))
}
Exemple #4
0
func TestMapIter(t *testing.T) {
	assert := assert.New(t)

	m := gen.MapOfBoolToStringDef{true: "hi", false: "bye"}.New()
	acc := gen.NewMapOfBoolToString()
	m.Iter(func(k bool, v string) bool {
		acc = acc.Set(k, v)
		return false
	})
	assert.True(m.Equals(acc))

	acc = gen.NewMapOfBoolToString()
	m.Iter(func(k bool, v string) bool {
		return true
	})
	assert.True(acc.Empty())
}