diff options
author | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
commit | 20b5f31c03fb556ec0aa2428a40adbac004d8987 (patch) | |
tree | 58086941e7d6bb8f480ca1173a95722ada9435b2 /tests/stdlib/tstrutil.nim | |
parent | 51ee524109cf7e3e86c676bc1676063a01bfd979 (diff) | |
download | Nim-20b5f31c03fb556ec0aa2428a40adbac004d8987.tar.gz |
new tester; all tests categorized
Diffstat (limited to 'tests/stdlib/tstrutil.nim')
-rw-r--r-- | tests/stdlib/tstrutil.nim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim new file mode 100644 index 000000000..80c2f3870 --- /dev/null +++ b/tests/stdlib/tstrutil.nim @@ -0,0 +1,45 @@ +discard """ + file: "tstrutil.nim" + output: "ha/home/a1xyz/usr/bin" +""" +# test the new strutils module + +import + strutils + +proc testStrip() = + write(stdout, strip(" ha ")) + +proc main() = + testStrip() + for p in split("/home/a1:xyz:/usr/bin", {':'}): + write(stdout, p) + +proc testDelete = + var s = "0123456789ABCDEFGH" + delete(s, 4, 5) + assert s == "01236789ABCDEFGH" + delete(s, s.len-1, s.len-1) + assert s == "01236789ABCDEFG" + delete(s, 0, 0) + assert s == "1236789ABCDEFG" + +testDelete() + +assert(insertSep($1000_000) == "1_000_000") +assert(insertSep($232) == "232") +assert(insertSep($12345, ',') == "12,345") +assert(insertSep($0) == "0") + +assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffix") == 0) +assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffi1") == 1) +assert(editDistance("prefix__hallo_suffix", "prefix__HALLO_suffix") == 5) +assert(editDistance("prefix__hallo_suffix", "prefix__ha_suffix") == 3) +assert(editDistance("prefix__hallo_suffix", "prefix") == 14) +assert(editDistance("prefix__hallo_suffix", "suffix") == 14) +assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2) + +main() +#OUT ha/home/a1xyz/usr/bin + + |