summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMattias Wadman <mattias.wadman@gmail.com>2024-03-20 11:04:17 +0100
committerGitHub <noreply@github.com>2024-03-20 11:04:17 +0100
commitbe437ec049bb2300731522ca93f37cd2629b4cc8 (patch)
tree43b578a215508e105f632e923a47bff93c3eda6b /tests
parent81f4f883ac76de11ae9d99266554d31d3b7f0c0c (diff)
Add trim/0, ltrim/0 and rtrim/0 that trims leading and trailing whitespace (#3056)
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test20
-rw-r--r--tests/man.test6
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test
index 584ab2b6..eabf836f 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -1334,6 +1334,26 @@ split("")
"xababababax"
[1,7,[1,3,5,7]]
+# trim
+# \u000b is vertical tab (\v not supported by json)
+map(trim), map(ltrim), map(rtrim)
+[" \n\t\r\f\u000b", ""," ", "a", " a ", "abc", " abc ", " abc", "abc "]
+["", "", "", "a", "a", "abc", "abc", "abc", "abc"]
+["", "", "", "a", "a ", "abc", "abc ", "abc", "abc "]
+["", "", "", "a", " a", "abc", " abc", " abc", "abc"]
+
+trim, ltrim, rtrim
+"\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000abc\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000"
+"abc"
+"abc\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000"
+"\u0009\u000A\u000B\u000C\u000D\u0020\u0085\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000abc"
+
+try trim catch ., try ltrim catch ., try rtrim catch .
+123
+"trim input must be a string"
+"trim input must be a string"
+"trim input must be a string"
+
indices(1)
[0,1,1,2,3,4,1,5]
[1,2,6]
diff --git a/tests/man.test b/tests/man.test
index 07938cd5..31ae3bf2 100644
--- a/tests/man.test
+++ b/tests/man.test
@@ -602,6 +602,12 @@ combinations(2)
["fo", "foo", "barfoo", "foobar", "foob"]
["fo","","bar","foobar","foob"]
+trim, ltrim, rtrim
+" abc "
+"abc"
+"abc "
+" abc"
+
explode
"foobar"
[102,111,111,98,97,114]