2020-11-03 23:48:43 +00:00
|
|
|
package yqlib
|
2020-10-20 05:27:30 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var notOperatorScenarios = []expressionScenario{
|
2020-10-27 05:45:16 +00:00
|
|
|
// {
|
|
|
|
// document: `cat`,
|
|
|
|
// expression: `. | not`,
|
|
|
|
// expected: []string{
|
|
|
|
// "D0, P[], (!!bool)::false\n",
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// document: `1`,
|
|
|
|
// expression: `. | not`,
|
|
|
|
// expected: []string{
|
|
|
|
// "D0, P[], (!!bool)::false\n",
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// document: `0`,
|
|
|
|
// expression: `. | not`,
|
|
|
|
// expected: []string{
|
|
|
|
// "D0, P[], (!!bool)::false\n",
|
|
|
|
// },
|
|
|
|
// },
|
2020-10-20 05:27:30 +00:00
|
|
|
{
|
|
|
|
document: `~`,
|
|
|
|
expression: `. | not`,
|
|
|
|
expected: []string{
|
|
|
|
"D0, P[], (!!bool)::true\n",
|
|
|
|
},
|
|
|
|
},
|
2020-10-27 05:45:16 +00:00
|
|
|
// {
|
|
|
|
// document: `false`,
|
|
|
|
// expression: `. | not`,
|
|
|
|
// expected: []string{
|
|
|
|
// "D0, P[], (!!bool)::true\n",
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// document: `true`,
|
|
|
|
// expression: `. | not`,
|
|
|
|
// expected: []string{
|
|
|
|
// "D0, P[], (!!bool)::false\n",
|
|
|
|
// },
|
|
|
|
// },
|
2020-10-20 05:27:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestNotOperatorScenarios(t *testing.T) {
|
|
|
|
for _, tt := range notOperatorScenarios {
|
|
|
|
testScenario(t, &tt)
|
|
|
|
}
|
|
|
|
}
|