Пример #1
0
func TestInt64SliceReduce(t *testing.T) {
	af := func(i int64) bool {
		return (i & 1) == 1
	}
	l := util.Int64Slice{2, 4, 30, 22}
	assert.EqualValues(t, []int64{}, l.Reduce(af).ToInt64())
	l.Append(3, 5)
	assert.EqualValues(t, []int64{3, 5}, l.Reduce(af).ToInt64())
}
Пример #2
0
func TestInt64SliceAll(t *testing.T) {
	af := func(i int64) bool {
		return (i & 1) == 0
	}
	l := util.Int64Slice{2, 4, 30, 22}
	assert.True(t, l.All(af))
	l.Append(11)
	assert.False(t, l.All(af))
}
Пример #3
0
// IDs returns an Int64Slice with all store ids
func (s GroupSlice) IDs() util.Int64Slice {
	if len(s) == 0 {
		return nil
	}
	var ids util.Int64Slice
	for _, g := range s {
		if g != nil {
			ids.Append(g.Data.GroupID)
		}
	}
	return ids
}
Пример #4
0
// IDs returns an Int64Slice with all store ids
func (ss StoreSlice) IDs() util.Int64Slice {
	if len(ss) == 0 {
		return nil
	}
	var ids util.Int64Slice
	for _, st := range ss {
		if st != nil {
			ids.Append(st.Data.StoreID)
		}
	}
	return ids
}
Пример #5
0
// IDs returns an Int64Slice with all website ids
func (ws WebsiteSlice) IDs() util.Int64Slice {
	if len(ws) == 0 {
		return nil
	}
	var ids util.Int64Slice
	for _, w := range ws {
		if w != nil {
			ids.Append(w.Data.WebsiteID)
		}
	}
	return ids
}
Пример #6
0
func TestInt64SliceAppend(t *testing.T) {
	is := util.Int64Slice{30, -1}
	is.Append(6)
	assert.EqualValues(t, []int64{30, -1, 6}, is.ToInt64())
}