tcstrutils.nim 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c cpp js"
  4. """
  5. import std/cstrutils
  6. import std/assertions
  7. proc main() =
  8. let s = cstring "abcdef"
  9. doAssert s.startsWith("a")
  10. doAssert not s.startsWith("b")
  11. doAssert s.endsWith("f")
  12. doAssert not s.endsWith("a")
  13. doAssert s.startsWith("")
  14. doAssert s.endsWith("")
  15. let a = cstring "abracadabra"
  16. doAssert a.startsWith("abra")
  17. doAssert not a.startsWith("bra")
  18. doAssert a.endsWith("abra")
  19. doAssert not a.endsWith("dab")
  20. doAssert a.startsWith("")
  21. doAssert a.endsWith("")
  22. doAssert cmpIgnoreCase(cstring "FooBar", "foobar") == 0
  23. doAssert cmpIgnoreCase(cstring "bar", "Foo") < 0
  24. doAssert cmpIgnoreCase(cstring "Foo5", "foo4") > 0
  25. doAssert cmpIgnoreStyle(cstring "foo_bar", "FooBar") == 0
  26. doAssert cmpIgnoreStyle(cstring "foo_bar_5", "FooBar4") > 0
  27. doAssert cmpIgnoreCase(cstring "", cstring "") == 0
  28. doAssert cmpIgnoreCase(cstring "", cstring "Hello") < 0
  29. doAssert cmpIgnoreCase(cstring "wind", cstring "") > 0
  30. static: main()
  31. main()