make cstrutils work in VM (#16590)

* make cstrutils work in VM

* more
This commit is contained in:
flywind
2021-01-05 10:52:26 -06:00
committed by GitHub
parent 0c4bd65e8d
commit c04f305bf7
4 changed files with 132 additions and 104 deletions

View File

@@ -2,21 +2,25 @@ discard """
targets: "c cpp js"
"""
import cstrutils
import std/cstrutils
block tcstrutils:
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
@@ -28,3 +32,7 @@ block tcstrutils:
doAssert cmpIgnoreCase(cstring "", cstring "") == 0
doAssert cmpIgnoreCase(cstring "", cstring "Hello") < 0
doAssert cmpIgnoreCase(cstring "wind", cstring "") > 0
static: main()
main()