summaryrefslogtreecommitdiffstats
path: root/pkg/common/cartesian_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/common/cartesian_test.go')
-rw-r--r--pkg/common/cartesian_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/common/cartesian_test.go b/pkg/common/cartesian_test.go
new file mode 100644
index 0000000..c49de06
--- /dev/null
+++ b/pkg/common/cartesian_test.go
@@ -0,0 +1,39 @@
+package common
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestCartesianProduct(t *testing.T) {
+ assert := assert.New(t)
+ input := map[string][]interface{}{
+ "foo": {1, 2, 3, 4},
+ "bar": {"a", "b", "c"},
+ "baz": {false, true},
+ }
+
+ 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")
+ }
+
+ input = map[string][]interface{}{
+ "foo": {1, 2, 3, 4},
+ "bar": {},
+ "baz": {false, true},
+ }
+ output = CartesianProduct(input)
+ assert.Len(output, 0)
+
+ input = map[string][]interface{}{}
+ output = CartesianProduct(input)
+ assert.Len(output, 0)
+}