Ejemplo n.º 1
0
func TestListIterAllP(t *testing.T) {
	assert := assert.New(t)

	l := gen.ListOfInt64Def{0, 1, 2, 3, 4}
	mu := sync.Mutex{}
	visited := map[int64]bool{}
	l.New().IterAllP(2, func(v int64, index uint64) {
		assert.EqualValues(v, index)
		mu.Lock()
		defer mu.Unlock()
		visited[v] = true
	})

	if assert.Len(visited, len(l)) {
		for _, e := range l {
			assert.True(visited[e])
		}
	}
}
Ejemplo n.º 2
0
func TestListInt64Def(t *testing.T) {
	assert := assert.New(t)

	def := gen.ListOfInt64Def{}
	l := def.New()

	def2 := l.Def()
	l2 := def.New()

	assert.Equal(def, def2)
	assert.True(l.Equals(l2))

	l3 := gen.NewListOfInt64()
	assert.True(l.Equals(l3))

	def3 := gen.ListOfInt64Def{0, 1, 2, 3, 4}
	l4 := def3.New()
	assert.Equal(uint64(5), l4.Len())
	assert.Equal(int64(0), l4.Get(0))
	assert.Equal(int64(2), l4.Get(2))
	assert.Equal(int64(4), l4.Get(4))

	l4 = l4.Set(4, 44).Slice(3, 5)
	assert.Equal(gen.ListOfInt64Def{3, 44}, l4.Def())
}