2020-02-17 12:11:16 -06:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCartisianProduct(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
input := map[string][]interface{}{
|
2020-02-25 18:58:26 -06:00
|
|
|
"foo": {1, 2, 3, 4},
|
|
|
|
"bar": {"a", "b", "c"},
|
|
|
|
"baz": {false, true},
|
2020-02-17 12:11:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
output := CartesianProduct(input)
|
|
|
|
assert.Len(output, 24)
|
|
|
|
|
|
|
|
for _, v := range output {
|
|
|
|
assert.Len(v, 3)
|
|
|
|
|
|
|
|
assert.Contains(v, "foo")
|
|
|
|
assert.Contains(v, "bar")
|
|
|
|
assert.Contains(v, "baz")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|