tstrmiscs.nim 983 B

123456789101112131415161718192021222324
  1. import std/strmisc
  2. import std/assertions
  3. doAssert expandTabs("\t", 4) == " "
  4. doAssert expandTabs("\tfoo\t", 4) == " foo "
  5. doAssert expandTabs("\tfoo\tbar", 4) == " foo bar"
  6. doAssert expandTabs("\tfoo\tbar\t", 4) == " foo bar "
  7. doAssert expandTabs("", 4) == ""
  8. doAssert expandTabs("", 0) == ""
  9. doAssert expandTabs("\t\t\t", 0) == ""
  10. doAssert partition("foo:bar", ":") == ("foo", ":", "bar")
  11. doAssert partition("foobarbar", "bar") == ("foo", "bar", "bar")
  12. doAssert partition("foobarbar", "bank") == ("foobarbar", "", "")
  13. doAssert partition("foobarbar", "foo") == ("", "foo", "barbar")
  14. doAssert partition("foofoobar", "bar") == ("foofoo", "bar", "")
  15. doAssert rpartition("foo:bar", ":") == ("foo", ":", "bar")
  16. doAssert rpartition("foobarbar", "bar") == ("foobar", "bar", "")
  17. doAssert rpartition("foobarbar", "bank") == ("", "", "foobarbar")
  18. doAssert rpartition("foobarbar", "foo") == ("", "foo", "barbar")
  19. doAssert rpartition("foofoobar", "bar") == ("foofoo", "bar", "")