mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package yqlib
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var notOperatorScenarios = []expressionScenario{
|
|
{
|
|
description: "Not true is false",
|
|
expression: `true | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::false\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Not false is true",
|
|
expression: `false | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::true\n",
|
|
},
|
|
},
|
|
{
|
|
description: "String values considered to be true",
|
|
expression: `"cat" | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::false\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Empty string value considered to be true",
|
|
expression: `"" | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::false\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Numbers are considered to be true",
|
|
expression: `1 | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::false\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Zero is considered to be true",
|
|
expression: `0 | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::false\n",
|
|
},
|
|
},
|
|
{
|
|
|
|
description: "Null is considered to be false",
|
|
expression: `~ | not`,
|
|
expected: []string{
|
|
"D0, P[], (!!bool)::true\n",
|
|
},
|
|
},
|
|
}
|
|
|
|
func TestNotOperatorScenarios(t *testing.T) {
|
|
for _, tt := range notOperatorScenarios {
|
|
testScenario(t, &tt)
|
|
}
|
|
documentScenarios(t, "Not Operator", notOperatorScenarios)
|
|
}
|