support scheduled transaction (#2)
This commit is contained in:
@@ -57,3 +57,15 @@ func ToUniqueInt64Slice(items []int64) []int64 {
|
||||
|
||||
return uniqueItems
|
||||
}
|
||||
|
||||
// ToSet returns a map where the keys are the items in the specified array
|
||||
func ToSet(items []int64) map[int64]bool {
|
||||
itemExistMap := make(map[int64]bool)
|
||||
|
||||
for i := 0; i < len(items); i++ {
|
||||
item := items[i]
|
||||
itemExistMap[item] = true
|
||||
}
|
||||
|
||||
return itemExistMap
|
||||
}
|
||||
|
||||
@@ -130,3 +130,25 @@ func TestToUniqueInt64Slice_NilOrEmpty(t *testing.T) {
|
||||
actualValue = ToUniqueInt64Slice(arr)
|
||||
assert.Equal(t, expectedValue, actualValue)
|
||||
}
|
||||
|
||||
func TestToSet(t *testing.T) {
|
||||
arr := []int64{0, 1, 2, 3, 2, 4, 0}
|
||||
actualValue := ToSet(arr)
|
||||
assert.Equal(t, 5, len(actualValue))
|
||||
assert.Equal(t, true, actualValue[0])
|
||||
assert.Equal(t, true, actualValue[1])
|
||||
assert.Equal(t, true, actualValue[2])
|
||||
assert.Equal(t, true, actualValue[3])
|
||||
assert.Equal(t, true, actualValue[4])
|
||||
assert.Equal(t, false, actualValue[5])
|
||||
}
|
||||
|
||||
func TestToSet_NilOrEmpty(t *testing.T) {
|
||||
var arr []int64 = nil
|
||||
actualValue := ToSet(arr)
|
||||
assert.Equal(t, 0, len(actualValue))
|
||||
|
||||
arr = []int64{}
|
||||
actualValue = ToSet(arr)
|
||||
assert.Equal(t, 0, len(actualValue))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user