summary refs log tree commit diff stats
path: root/tests/stdlib/tstrutil.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tstrutil.nim')
-rw-r--r--tests/stdlib/tstrutil.nim61
1 files changed, 37 insertions, 24 deletions
diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim
index 80c2f3870..3db484faa 100644
--- a/tests/stdlib/tstrutil.nim
+++ b/tests/stdlib/tstrutil.nim
@@ -2,18 +2,18 @@ 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)

+# 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"
@@ -25,21 +25,34 @@ proc testDelete =
   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

 
+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)
+
+assert "/1/2/3".rfind('/') == 4
+assert "/1/2/3".rfind('/', 1) == 0
+assert "/1/2/3".rfind('0') == -1
+
+assert(toHex(100i16, 32) == "00000000000000000000000000000064")
+assert(toHex(-100i16, 32) == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9C")
+
+assert(' '.repeat(8)== "        ")
+assert(" ".repeat(8) == "        ")
+assert(spaces(8) == "        ")
+
+assert(' '.repeat(0) == "")
+assert(" ".repeat(0) == "")
+assert(spaces(0) == "")
 
+main()
+#OUT ha/home/a1xyz/usr/bin
id='n233' href='#n233'>233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301