tests: add test cases around empty values

pull/31220/head
Joshua Barton 4 years ago
parent c73c0ad63c
commit fd3798b276

@ -323,6 +323,36 @@ func TestFunctions(t *testing.T) {
`endswith("hello world", "hello")`,
cty.False,
},
{
`endswith("hello world", "")`,
cty.True,
// Completely empty suffix value ( "" )
// will always evaluate to true for all strings.
},
{
`endswith("hello world", " ")`,
cty.False,
},
{
`endswith("", "")`,
cty.True,
},
{
`endswith("", " ")`,
cty.False,
},
{
`endswith(" ", "")`,
cty.True,
},
{
`endswith("", "hello")`,
cty.False,
},
{
`endswith(" ", "hello")`,
cty.False,
},
},
"file": {
@ -836,6 +866,36 @@ func TestFunctions(t *testing.T) {
`startswith("hello world", "world")`,
cty.False,
},
{
`startswith("hello world", "")`,
cty.True,
// Completely empty prefix value ( "" )
// will always evaluate to true for all strings.
},
{
`startswith("hello world", " ")`,
cty.False,
},
{
`startswith("", "")`,
cty.True,
},
{
`startswith("", " ")`,
cty.False,
},
{
`startswith(" ", "")`,
cty.True,
},
{
`startswith("", "hello")`,
cty.False,
},
{
`startswith(" ", "hello")`,
cty.False,
},
},
"strrev": {

Loading…
Cancel
Save