Skip to content

Commit

Permalink
🟢 add missing tests for typecasts (#3464)
Browse files Browse the repository at this point in the history
It was late when I pushed this, but I promised to add the missing tests, so here we are. Related to #3463

Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus authored Mar 2, 2024
1 parent 49857bb commit 2f1c166
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions mql/mql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,67 @@ func TestResourceAliases(t *testing.T) {
})
}

func TestTypeCasts(t *testing.T) {
x := testutils.InitTester(testutils.LinuxMock())
x.TestSimple(t, []testutils.SimpleTest{
{
Code: "/regex2string/",
ResultIndex: 0,
Expectation: "regex2string",
},
{
Code: "regex('s.*g') == 'string'",
ResultIndex: 1,
Expectation: true,
},
{
Code: "int(1.23)",
ResultIndex: 0,
Expectation: int64(1),
},
{
Code: "int('12')",
ResultIndex: 0,
Expectation: int64(12),
},
{
Code: "float(123)",
ResultIndex: 0,
Expectation: float64(123),
},
{
Code: "float('123')",
ResultIndex: 0,
Expectation: float64(123),
},
{
Code: "int(float('1.23'))",
ResultIndex: 0,
Expectation: int64(1),
},
{
Code: "bool(1.23)",
ResultIndex: 0,
Expectation: true,
},
{
Code: "bool(0)",
ResultIndex: 0,
Expectation: false,
},
{
Code: "bool('true')",
ResultIndex: 0,
Expectation: true,
},
{
Code: "bool('false')",
ResultIndex: 0,
Expectation: false,
},
})
}

func TestNullResources(t *testing.T) {
x := testutils.InitTester(testutils.LinuxMock())
x.TestSimple(t, []testutils.SimpleTest{
Expand Down

0 comments on commit 2f1c166

Please sign in to comment.