Skip to content

Commit

Permalink
Added additional unit tests for LIKE operator
Browse files Browse the repository at this point in the history
  • Loading branch information
ziflex committed Mar 5, 2021
1 parent 6295919 commit ae7b5ce
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/compiler/compiler_like_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,37 @@ func TestLikeOperator(t *testing.T) {
So(err, ShouldBeNil)
So(string(out1), ShouldEqual, `["bar","qaz"]`)
})

Convey("LIKE ternary", t, func() {
c := compiler.New()

out1, err := c.MustCompile(`
RETURN ("foo" NOT LIKE "b*") ? "foo" : "bar"
`).Run(context.Background())

So(err, ShouldBeNil)
So(string(out1), ShouldEqual, `"foo"`)
})

Convey("LIKE ternary 2", t, func() {
c := compiler.New()

out1, err := c.MustCompile(`
RETURN true ? ("foo" NOT LIKE "b*") : false
`).Run(context.Background())

So(err, ShouldBeNil)
So(string(out1), ShouldEqual, `true`)
})

Convey("LIKE ternary 3", t, func() {
c := compiler.New()

out1, err := c.MustCompile(`
RETURN true ? false : ("foo" NOT LIKE "b*")s
`).Run(context.Background())

So(err, ShouldBeNil)
So(string(out1), ShouldEqual, `false`)
})
}

0 comments on commit ae7b5ce

Please sign in to comment.