mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* stdlib tests now check refc too * typo * fixes line numbers * disable cpp * do not touch
40 lines
1.0 KiB
Nim
40 lines
1.0 KiB
Nim
discard """
|
|
matrix: "--mm:refc; --mm:orc"
|
|
targets: "c cpp js"
|
|
"""
|
|
|
|
import std/cstrutils
|
|
import std/assertions
|
|
|
|
proc main() =
|
|
let s = cstring "abcdef"
|
|
doAssert s.startsWith("a")
|
|
doAssert not s.startsWith("b")
|
|
doAssert s.endsWith("f")
|
|
doAssert not s.endsWith("a")
|
|
doAssert s.startsWith("")
|
|
doAssert s.endsWith("")
|
|
|
|
let a = cstring "abracadabra"
|
|
doAssert a.startsWith("abra")
|
|
doAssert not a.startsWith("bra")
|
|
doAssert a.endsWith("abra")
|
|
doAssert not a.endsWith("dab")
|
|
doAssert a.startsWith("")
|
|
doAssert a.endsWith("")
|
|
|
|
doAssert cmpIgnoreCase(cstring "FooBar", "foobar") == 0
|
|
doAssert cmpIgnoreCase(cstring "bar", "Foo") < 0
|
|
doAssert cmpIgnoreCase(cstring "Foo5", "foo4") > 0
|
|
|
|
doAssert cmpIgnoreStyle(cstring "foo_bar", "FooBar") == 0
|
|
doAssert cmpIgnoreStyle(cstring "foo_bar_5", "FooBar4") > 0
|
|
|
|
doAssert cmpIgnoreCase(cstring "", cstring "") == 0
|
|
doAssert cmpIgnoreCase(cstring "", cstring "Hello") < 0
|
|
doAssert cmpIgnoreCase(cstring "wind", cstring "") > 0
|
|
|
|
|
|
static: main()
|
|
main()
|