|
|
|
@ -531,11 +531,9 @@ func TestCompareOp(t *testing.T) {
|
|
|
|
|
testResult: true},
|
|
|
|
|
|
|
|
|
|
// Test Op "gt"
|
|
|
|
|
// TODO: test for non-numeric values.
|
|
|
|
|
// toNumeric function currently uses os.Exit, which stops tests.
|
|
|
|
|
// {label: "op=gt, both empty", op: "gt", flagVal: "",
|
|
|
|
|
// compareValue: "", expectedResultPattern: "'' is greater than ''",
|
|
|
|
|
// testResult: true},
|
|
|
|
|
{label: "op=gt, both empty", op: "gt", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 0 > 0", op: "gt", flagVal: "0",
|
|
|
|
|
compareValue: "0", expectedResultPattern: "0 is greater than 0",
|
|
|
|
|
testResult: false},
|
|
|
|
@ -548,109 +546,124 @@ func TestCompareOp(t *testing.T) {
|
|
|
|
|
{label: "op=gt, 5 > 5", op: "gt", flagVal: "5",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "5 is greater than 5",
|
|
|
|
|
testResult: false},
|
|
|
|
|
|
|
|
|
|
{label: "op=gt, Pikachu > 5", op: "gt", flagVal: "Pikachu",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 5 > Bulbasaur", op: "gt", flagVal: "5",
|
|
|
|
|
compareValue: "Bulbasaur", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
// Test Op "lt"
|
|
|
|
|
// TODO: test for non-numeric values.
|
|
|
|
|
// toNumeric function currently uses os.Exit, which stops tests.
|
|
|
|
|
// {label: "op=lt, both empty", op: "lt", flagVal: "",
|
|
|
|
|
// compareValue: "", expectedResultPattern: "'' is lower than ''",
|
|
|
|
|
// testResult: true},
|
|
|
|
|
{label: "op=gt, 0 < 0", op: "lt", flagVal: "0",
|
|
|
|
|
{label: "op=lt, both empty", op: "lt", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=lt, 0 < 0", op: "lt", flagVal: "0",
|
|
|
|
|
compareValue: "0", expectedResultPattern: "0 is lower than 0",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 4 < 5", op: "lt", flagVal: "4",
|
|
|
|
|
{label: "op=lt, 4 < 5", op: "lt", flagVal: "4",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "4 is lower than 5",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 5 < 4", op: "lt", flagVal: "5",
|
|
|
|
|
{label: "op=lt, 5 < 4", op: "lt", flagVal: "5",
|
|
|
|
|
compareValue: "4", expectedResultPattern: "5 is lower than 4",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 5 < 5", op: "lt", flagVal: "5",
|
|
|
|
|
{label: "op=lt, 5 < 5", op: "lt", flagVal: "5",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "5 is lower than 5",
|
|
|
|
|
testResult: false},
|
|
|
|
|
|
|
|
|
|
{label: "op=lt, Charmander < 5", op: "lt", flagVal: "Charmander",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=lt, 5 < Charmeleon", op: "lt", flagVal: "5",
|
|
|
|
|
compareValue: "Charmeleon", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
// Test Op "gte"
|
|
|
|
|
// TODO: test for non-numeric values.
|
|
|
|
|
// toNumeric function currently uses os.Exit, which stops tests.
|
|
|
|
|
// {label: "op=gt, both empty", op: "gte", flagVal: "",
|
|
|
|
|
// compareValue: "", expectedResultPattern: "'' is greater or equal to ''",
|
|
|
|
|
// testResult: true},
|
|
|
|
|
{label: "op=gt, 0 >= 0", op: "gte", flagVal: "0",
|
|
|
|
|
{label: "op=gte, both empty", op: "gte", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gte, 0 >= 0", op: "gte", flagVal: "0",
|
|
|
|
|
compareValue: "0", expectedResultPattern: "0 is greater or equal to 0",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 4 >= 5", op: "gte", flagVal: "4",
|
|
|
|
|
{label: "op=gte, 4 >= 5", op: "gte", flagVal: "4",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "4 is greater or equal to 5",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 5 >= 4", op: "gte", flagVal: "5",
|
|
|
|
|
{label: "op=gte, 5 >= 4", op: "gte", flagVal: "5",
|
|
|
|
|
compareValue: "4", expectedResultPattern: "5 is greater or equal to 4",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 5 >= 5", op: "gte", flagVal: "5",
|
|
|
|
|
{label: "op=gte, 5 >= 5", op: "gte", flagVal: "5",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "5 is greater or equal to 5",
|
|
|
|
|
testResult: true},
|
|
|
|
|
|
|
|
|
|
{label: "op=gte, Ekans >= 5", op: "gte", flagVal: "Ekans",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gte, 4 >= Zubat", op: "gte", flagVal: "4",
|
|
|
|
|
compareValue: "Zubat", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
// Test Op "lte"
|
|
|
|
|
// TODO: test for non-numeric values.
|
|
|
|
|
// toNumeric function currently uses os.Exit, which stops tests.
|
|
|
|
|
// {label: "op=gt, both empty", op: "lte", flagVal: "",
|
|
|
|
|
// compareValue: "", expectedResultPattern: "'' is lower or equal to ''",
|
|
|
|
|
// testResult: true},
|
|
|
|
|
{label: "op=gt, 0 <= 0", op: "lte", flagVal: "0",
|
|
|
|
|
{label: "op=lte, both empty", op: "lte", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=lte, 0 <= 0", op: "lte", flagVal: "0",
|
|
|
|
|
compareValue: "0", expectedResultPattern: "0 is lower or equal to 0",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 4 <= 5", op: "lte", flagVal: "4",
|
|
|
|
|
{label: "op=lte, 4 <= 5", op: "lte", flagVal: "4",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "4 is lower or equal to 5",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 5 <= 4", op: "lte", flagVal: "5",
|
|
|
|
|
{label: "op=lte, 5 <= 4", op: "lte", flagVal: "5",
|
|
|
|
|
compareValue: "4", expectedResultPattern: "5 is lower or equal to 4",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 5 <= 5", op: "lte", flagVal: "5",
|
|
|
|
|
{label: "op=lte, 5 <= 5", op: "lte", flagVal: "5",
|
|
|
|
|
compareValue: "5", expectedResultPattern: "5 is lower or equal to 5",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=lte, Venomoth <= 4", op: "lte", flagVal: "Venomoth",
|
|
|
|
|
compareValue: "4", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=lte, 5 <= Meowth", op: "lte", flagVal: "5",
|
|
|
|
|
compareValue: "Meowth", expectedResultPattern: "Invalid Number(s) used for comparison",
|
|
|
|
|
testResult: false},
|
|
|
|
|
|
|
|
|
|
// Test Op "has"
|
|
|
|
|
{label: "op=gt, both empty", op: "has", flagVal: "",
|
|
|
|
|
{label: "op=has, both empty", op: "has", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: "'' has ''",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, flagVal=empty", op: "has", flagVal: "",
|
|
|
|
|
{label: "op=has, flagVal=empty", op: "has", flagVal: "",
|
|
|
|
|
compareValue: "blah", expectedResultPattern: "'' has 'blah'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, compareValue=empty", op: "has", flagVal: "blah",
|
|
|
|
|
{label: "op=has, compareValue=empty", op: "has", flagVal: "blah",
|
|
|
|
|
compareValue: "", expectedResultPattern: "'blah' has ''",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 'blah' has 'la'", op: "has", flagVal: "blah",
|
|
|
|
|
{label: "op=has, 'blah' has 'la'", op: "has", flagVal: "blah",
|
|
|
|
|
compareValue: "la", expectedResultPattern: "'blah' has 'la'",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 'blah' has 'LA'", op: "has", flagVal: "blah",
|
|
|
|
|
{label: "op=has, 'blah' has 'LA'", op: "has", flagVal: "blah",
|
|
|
|
|
compareValue: "LA", expectedResultPattern: "'blah' has 'LA'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 'blah' has 'lo'", op: "has", flagVal: "blah",
|
|
|
|
|
{label: "op=has, 'blah' has 'lo'", op: "has", flagVal: "blah",
|
|
|
|
|
compareValue: "lo", expectedResultPattern: "'blah' has 'lo'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
|
|
|
|
|
// Test Op "nothave"
|
|
|
|
|
{label: "op=gt, both empty", op: "nothave", flagVal: "",
|
|
|
|
|
{label: "op=nothave, both empty", op: "nothave", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: " '' not have ''",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, flagVal=empty", op: "nothave", flagVal: "",
|
|
|
|
|
{label: "op=nothave, flagVal=empty", op: "nothave", flagVal: "",
|
|
|
|
|
compareValue: "blah", expectedResultPattern: " '' not have 'blah'",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, compareValue=empty", op: "nothave", flagVal: "blah",
|
|
|
|
|
{label: "op=nothave, compareValue=empty", op: "nothave", flagVal: "blah",
|
|
|
|
|
compareValue: "", expectedResultPattern: " 'blah' not have ''",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 'blah' not have 'la'", op: "nothave", flagVal: "blah",
|
|
|
|
|
{label: "op=nothave, 'blah' not have 'la'", op: "nothave", flagVal: "blah",
|
|
|
|
|
compareValue: "la", expectedResultPattern: " 'blah' not have 'la'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=gt, 'blah' not have 'LA'", op: "nothave", flagVal: "blah",
|
|
|
|
|
{label: "op=nothave, 'blah' not have 'LA'", op: "nothave", flagVal: "blah",
|
|
|
|
|
compareValue: "LA", expectedResultPattern: " 'blah' not have 'LA'",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, 'blah' not have 'lo'", op: "nothave", flagVal: "blah",
|
|
|
|
|
{label: "op=nothave, 'blah' not have 'lo'", op: "nothave", flagVal: "blah",
|
|
|
|
|
compareValue: "lo", expectedResultPattern: " 'blah' not have 'lo'",
|
|
|
|
|
testResult: true},
|
|
|
|
|
|
|
|
|
|
// Test Op "regex"
|
|
|
|
|
{label: "op=gt, both empty", op: "regex", flagVal: "",
|
|
|
|
|
{label: "op=regex, both empty", op: "regex", flagVal: "",
|
|
|
|
|
compareValue: "", expectedResultPattern: " '' matched by ''",
|
|
|
|
|
testResult: true},
|
|
|
|
|
{label: "op=gt, flagVal=empty", op: "regex", flagVal: "",
|
|
|
|
|
{label: "op=regex, flagVal=empty", op: "regex", flagVal: "",
|
|
|
|
|
compareValue: "blah", expectedResultPattern: " '' matched by 'blah'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
|
|
|
|
@ -679,6 +692,12 @@ func TestCompareOp(t *testing.T) {
|
|
|
|
|
{label: "op=bitmask, 644 AND 211", op: "bitmask", flagVal: "211",
|
|
|
|
|
compareValue: "644", expectedResultPattern: "bitmask '211' AND '644'",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=bitmask, Harry AND 211", op: "bitmask", flagVal: "Harry",
|
|
|
|
|
compareValue: "644", expectedResultPattern: "Not numeric value - flag: Harry",
|
|
|
|
|
testResult: false},
|
|
|
|
|
{label: "op=bitmask, 644 AND Potter", op: "bitmask", flagVal: "211",
|
|
|
|
|
compareValue: "Potter", expectedResultPattern: "Not numeric value - flag: Potter",
|
|
|
|
|
testResult: false},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, c := range cases {
|
|
|
|
|