summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-12-23 04:57:48 -0600
committerGitHub <noreply@github.com>2020-12-23 11:57:48 +0100
commit417c2509c42367edc4130a8761fae80d529d8574 (patch)
tree7c2a0c7b62960574749f901e35d2177d5b8747da /tests
parent8d913a5921d7245ad80e92a040b5bc8ba6f97f44 (diff)
downloadNim-417c2509c42367edc4130a8761fae80d529d8574.tar.gz
strip minor improvement (#16444)
* strip minor improvement
* add more tests
* Update tests/stdlib/tstrutils.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tstrutils.nim13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/stdlib/tstrutils.nim b/tests/stdlib/tstrutils.nim
index b62c82ffb..8d6fe75ae 100644
--- a/tests/stdlib/tstrutils.nim
+++ b/tests/stdlib/tstrutils.nim
@@ -28,6 +28,19 @@ template main() =
     doAssert strip("sfoofoofoos", leading = false, chars = {'s'}) == "sfoofoofoo"
     doAssert strip("sfoofoofoos", trailing = false, chars = {'s'}) == "foofoofoos"
 
+    block:
+      let a = "xxxxxx"
+      doAssert a.strip(chars={'x'}).len == 0
+
+    doAssert "".strip(chars={'x'}).len == 0
+    doAssert "         ".strip(chars={'x'}) == "         "
+    doAssert "xxx xxx".strip(chars={'x'}) == " "
+    doAssert "xxx  wind".strip(chars={'x'}) == "  wind"
+    doAssert "xxx  iii".strip(chars={'i'}) == "xxx  "
+    doAssert "x".strip(leading = false, chars={'x'}).len == 0
+    doAssert "x".strip(trailing = false, chars={'x'}).len == 0
+    doAssert "x".strip(leading = false, trailing = false, chars={'x'}) == "x"
+
   block: # split
     var ret: seq[string] # or use `toSeq` or `collect`
     for p in split("/home/a1:xyz:/usr/bin", {':'}): ret.add p