Add tests for chomp
This commit is contained in:
parent
a291f2c271
commit
d28862422b
1 changed files with 21 additions and 4 deletions
|
|
@ -10,8 +10,25 @@ import
|
|||
proc testStrip() =
|
||||
write(stdout, strip(" ha "))
|
||||
|
||||
proc testChomp =
|
||||
assert "hello".chomp == "hello"
|
||||
assert "hello\n".chomp == "hello"
|
||||
assert "hello\r\n".chomp == "hello"
|
||||
assert "hello\n\r".chomp == "hello\n"
|
||||
assert "hello\n\n".chomp == "hello\n"
|
||||
assert "hello\r".chomp == "hello"
|
||||
assert "hello \n there".chomp == "hello \n there"
|
||||
assert "hello".chomp("llo") == "he"
|
||||
assert "hellos".chomp('s') == "hello"
|
||||
assert "hellos".chomp({'s','z'}) == "hello"
|
||||
assert "hellos".chomp({'o','s'}) == "hello"
|
||||
assert "hello\r\n\r\n".chomp("") == "hello"
|
||||
assert "hello\r\n\r\r\n".chomp("") == "hello\r\n\r"
|
||||
assert "hello\n\n\n\n\n".chomp("") == "hello"
|
||||
|
||||
proc main() =
|
||||
testStrip()
|
||||
testChomp()
|
||||
for p in split("/home/a1:xyz:/usr/bin", {':'}):
|
||||
write(stdout, p)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue