summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Haguenauer <ml@kurokatta.org>2019-01-21 20:33:55 -0500
committerNico Williams <nico@cryptonector.com>2019-01-22 11:00:08 -0600
commit63ba2b163712e397ba59c86d3ca95b0a112c48cb (patch)
tree9a556a77c8b2b4d613c008e03d5ea773694ec72d /tests
parent61cd6dbb3b7f3423d49a1a9beb2b82ad16a34755 (diff)
Add tests for built-in function `contains`
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test23
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/jq.test b/tests/jq.test
index 041ca1ea..6ee657b6 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -1092,9 +1092,26 @@ null
[true, true, false]
# containment operator (embedded NULs!)
-[contains("foo"), contains("\u0000b"), contains("\u0000z"), contains("bar"), contains("baz")]
-"foo\u0000bar"
-[true, true, false, true, false]
+[contains(""), contains("\u0000")]
+"\u0000"
+[true, true]
+
+[contains(""), contains("a"), contains("ab"), contains("c"), contains("d")]
+"ab\u0000cd"
+[true, true, true, true, true]
+
+[contains("cd"), contains("b\u0000"), contains("ab\u0000")]
+"ab\u0000cd"
+[true, true, true]
+
+[contains("b\u0000c"), contains("b\u0000cd"), contains("b\u0000cd")]
+"ab\u0000cd"
+[true, true, true]
+
+[contains("@"), contains("\u0000@"), contains("\u0000what")]
+"ab\u0000cd"
+[false, false, false]
+
# Try/catch and general `?` operator
[.[]|try if . == 0 then error("foo") elif . == 1 then .a elif . == 2 then empty else . end catch .]