diff options
author | Bo Lingen <lingenbw@gmail.com> | 2017-10-30 16:45:13 -0500 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-30 22:45:13 +0100 |
commit | c182d37f4505e6b5acab5b7d1aecaa5ddc8b0044 (patch) | |
tree | 11225e1b9009d895894aa3c936ba15e5d5d2f2fa /tests/stdlib/tstrutil.nim | |
parent | badba83d38371726bafba5870d5fb927eb453e41 (diff) | |
download | Nim-c182d37f4505e6b5acab5b7d1aecaa5ddc8b0044.tar.gz |
Update `removeSuffix` implementations to match `removePrefix` (#6636)
Diffstat (limited to 'tests/stdlib/tstrutil.nim')
-rw-r--r-- | tests/stdlib/tstrutil.nim | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim index 2fb0c371f..071dae5a7 100644 --- a/tests/stdlib/tstrutil.nim +++ b/tests/stdlib/tstrutil.nim @@ -13,15 +13,13 @@ proc testStrip() = proc testRemoveSuffix = var s = "hello\n\r" s.removeSuffix - assert s == "hello\n" - s.removeSuffix assert s == "hello" s.removeSuffix assert s == "hello" s = "hello\n\n" s.removeSuffix - assert s == "hello\n" + assert s == "hello" s = "hello\r" s.removeSuffix @@ -41,7 +39,31 @@ proc testRemoveSuffix = s.removeSuffix({'s','z'}) assert s == "hello" s.removeSuffix({'l','o'}) - assert s == "hell" + assert s == "he" + + s = "aeiou" + s.removeSuffix("") + assert s == "aeiou" + + s = "" + s.removeSuffix("") + assert s == "" + + s = " " + s.removeSuffix + assert s == " " + + s = " " + s.removeSuffix("") + assert s == " " + + s = " " + s.removeSuffix(" ") + assert s == " " + + s = " " + s.removeSuffix(' ') + assert s == "" # Contrary to Chomp in other languages # empty string does not change behaviour |