yq/pkg/yqlib/treeops/operator_multiply_test.go

78 lines
1.8 KiB
Go
Raw Normal View History

2020-10-19 05:14:29 +00:00
package treeops
import (
"testing"
)
var multiplyOperatorScenarios = []expressionScenario{
{
2020-10-19 05:36:46 +00:00
document: `{a: {also: [1]}, b: {also: me}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n",
},
}, {
document: `{a: {also: me}, b: {also: [1]}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: [1]}, b: {also: [1]}}\n",
},
}, {
document: `{a: {also: me}, b: {also: {g: wizz}}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: {g: wizz}}, b: {also: {g: wizz}}}\n",
},
}, {
document: `{a: {also: {g: wizz}}, b: {also: me}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n",
},
}, {
document: `{a: {also: {g: wizz}}, b: {also: [1]}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: [1]}, b: {also: [1]}}\n",
},
}, {
document: `{a: {also: [1]}, b: {also: {g: wizz}}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {also: {g: wizz}}, b: {also: {g: wizz}}}\n",
},
}, {
2020-10-19 05:14:29 +00:00
document: `{a: {things: great}, b: {also: me}}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: {things: great, also: me}, b: {also: me}}\n",
},
2020-10-19 05:36:46 +00:00
}, {
document: `a: {things: great}
b:
also: "me"
`,
expression: `.a * .b`,
expected: []string{
`D0, P[], (!!map)::a:
things: great
also: "me"
b:
also: "me"
`,
},
2020-10-19 09:05:38 +00:00
}, {
document: `{a: [1,2,3], b: [3,4,5]}`,
expression: `.a * .b`,
expected: []string{
"D0, P[], (!!map)::{a: [3, 4, 5], b: [3, 4, 5]}\n",
},
2020-10-19 05:14:29 +00:00
},
}
func TestMultiplyOperatorScenarios(t *testing.T) {
for _, tt := range multiplyOperatorScenarios {
testScenario(t, &tt)
}
}