diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-17 10:43:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-17 10:43:19 -0700 |
commit | 972d095787d6107141004a66f8e5c86b89f446c6 (patch) | |
tree | aa552db14da3a8fabf0f265181667011656a2afa /tests | |
parent | fd22fbc29fc0ee1a726880fa3bab64e187433854 (diff) | |
download | txr-972d095787d6107141004a66f8e5c86b89f446c6.tar.gz txr-972d095787d6107141004a66f8e5c86b89f446c6.tar.bz2 txr-972d095787d6107141004a66f8e5c86b89f446c6.zip |
Adding tests for split-str.
* Makefile (TXR_DBG_OPTS): Disable for tst/tests/015.
* tests/common.tl (mtest): New macro.
* tests/015/split.tl: New file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/015/split.tl | 123 | ||||
-rw-r--r-- | tests/common.tl | 3 |
2 files changed, 126 insertions, 0 deletions
diff --git a/tests/015/split.tl b/tests/015/split.tl new file mode 100644 index 00000000..df496170 --- /dev/null +++ b/tests/015/split.tl @@ -0,0 +1,123 @@ +(load "../common") + +(mtest + (split-str "" "") ("") + (split-str "a" "") ("a") + (split-str "" "a") ("") + (split-str "a" "a") ("" "")) + +(mtest + (split-str "" "" t) ("") + (split-str "a" "" t) ("a") + (split-str "" "a" t) ("") + (split-str "a" "a" t) ("" "a" "")) + +(mtest + (split-str "" #//) ("") + (split-str "a" #//) ("a") + (split-str "" #/a/) ("") + (split-str "a" #/a/) ("" "")) + +(mtest + (split-str "" #// t) ("") + (split-str "a" #// t) ("a") + (split-str "" #/a/ t) ("") + (split-str "a" #/a/ t) ("" "a" "")) + +(mtest + (split-str "ab" "") ("a" "b") + (split-str "ab" "a") ("" "b") + (split-str "ab" "b") ("a" "") + (split-str "ab" "ab") ("" "") + (split-str "ab" "abc") ("ab")) + +(mtest + (split-str "ab" "" t) ("a" "" "b") + (split-str "ab" "a" t) ("" "a" "b") + (split-str "ab" "b" t) ("a" "b" "") + (split-str "ab" "ab" t) ("" "ab" "") + (split-str "ab" "abc" t) ("ab")) + +(mtest + (split-str "ab" #//) ("a" "b") + (split-str "ab" #/a/) ("" "b") + (split-str "ab" #/b/) ("a" "") + (split-str "ab" #/ab/) ("" "") + (split-str "ab" #/abc/) ("ab")) + +(mtest + (split-str "ab" #// t) ("a" "" "b") + (split-str "ab" #/a/ t) ("" "a" "b") + (split-str "ab" #/b/ t) ("a" "b" "") + (split-str "ab" #/ab/ t) ("" "ab" "") + (split-str "ab" #/abc/ t) ("ab")) + +(mtest + (split-str "abc" "") ("a" "b" "c") + (split-str "abc" "" t) ("a" "" "b" "" "c") + (split-str "abc" #//) ("a" "b" "c") + (split-str "abc" #// t) ("a" "" "b" "" "c")) + +(mtest + (split-str "abc" "a") ("" "bc") + (split-str "abc" "b") ("a" "c") + (split-str "abc" "c") ("ab" "") + (split-str "abc" "a" t) ("" "a" "bc") + (split-str "abc" "b" t) ("a" "b" "c") + (split-str "abc" "c" t) ("ab" "c" "") + (split-str "abc" #/a/) ("" "bc") + (split-str "abc" #/b/) ("a" "c") + (split-str "abc" #/c/) ("ab" "") + (split-str "abc" #/a/ t) ("" "a" "bc") + (split-str "abc" #/b/ t) ("a" "b" "c") + (split-str "abc" #/c/ t) ("ab" "c" "")) + +(mtest + (split-str "abc" "ab") ("" "c") + (split-str "abc" "bc") ("a" "") + (split-str "abc" "abc") ("" "") + (split-str "abc" "ab" t) ("" "ab" "c") + (split-str "abc" "bc" t) ("a" "bc" "") + (split-str "abc" "abc" t) ("" "abc" "") + (split-str "abc" #/ab/) ("" "c") + (split-str "abc" #/bc/) ("a" "") + (split-str "abc" #/abc/) ("" "") + (split-str "abc" #/ab/ t) ("" "ab" "c") + (split-str "abc" #/bc/ t) ("a" "bc" "") + (split-str "abc" #/abc/ t) ("" "abc" "")) + +(mtest + (split-str "a,b,c" ",") ("a" "b" "c") + (split-str ",b,c" ",") ("" "b" "c") + (split-str "a,,c" ",") ("a" "" "c") + (split-str "a,b," ",") ("a" "b" "") + (split-str ",,c" ",") ("" "" "c") + (split-str "a,," ",") ("a" "" "") + (split-str ",," ",") ("" "" "")) + +(mtest + (split-str "a,b,c" #/,/ t) ("a" "," "b" "," "c") + (split-str ",b,c" #/,/ t) ("" "," "b" "," "c") + (split-str "a,,c" #/,/ t) ("a" "," "" "," "c") + (split-str "a,b," #/,/ t) ("a" "," "b" "," "") + (split-str ",,c" #/,/ t) ("" "," "" "," "c") + (split-str "a,," #/,/ t) ("a" "," "" "," "") + (split-str ",," #/,/ t) ("" "," "" "," "")) + +(mtest + (split-str "a,b,c" #/[^,]/) ("" "," "," "") + (split-str "a,b,c" #/[^,]/ t) ("" "a" "," "b" "," "c" "") + (split-str "a,b,c" #/[^a-c]/) #"a b c" + (split-str "a,b,c" #/[^a-c]/ t) #"a , b , c") + +(mtest + (split-str "abc" #/./) ("" "" "" "") + (split-str "abc" #/./ t) ("" "a" "" "b" "" "c" "") + (split-str "abc" #/../) ("" "c") + (split-str "abc" #/../ t) ("" "ab" "c") + (split-str "abc" #/.../) ("" "") + (split-str "abc" #/.../ t) ("" "abc" "")) + +(mtest + (split-str "abcacabcac" #/ab?/) ("" "c" "c" "c" "c") + (split-str "abcacabcac" #/ab?/ t) ("" "ab" "c" "a" "c" "ab" "c" "a" "c")) diff --git a/tests/common.tl b/tests/common.tl index ea2be1d5..c0dda285 100644 --- a/tests/common.tl +++ b/tests/common.tl @@ -20,6 +20,9 @@ (defmacro stest (expr expected) ^(vtest ,^(tostring ,expr) ,expected)) +(defmacro mtest (. pairs) + ^(progn ,*(mapcar (op cons 'test) (tuples 2 pairs)))) + (defun osname () (with-stream (u (open-command "(uname -o || uname) 2> /dev/null")) (get-line u))) |