tstrmiscs.nim 1.0 KB

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