TestUnsafeString
This commit is contained in:
@@ -23,9 +23,25 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/goplus/gogen/packages"
|
||||||
"github.com/goplus/llvm"
|
"github.com/goplus/llvm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestUnsafeString(t *testing.T) {
|
||||||
|
prog := NewProgram(nil)
|
||||||
|
prog.SetRuntime(func() *types.Package {
|
||||||
|
fset := token.NewFileSet()
|
||||||
|
imp := packages.NewImporter(fset)
|
||||||
|
pkg, _ := imp.Import(PkgRuntime)
|
||||||
|
return pkg
|
||||||
|
})
|
||||||
|
pkg := prog.NewPackage("foo", "foo")
|
||||||
|
sigMain := types.NewSignatureType(nil, nil, nil, nil, nil, false)
|
||||||
|
b := pkg.NewFunc("main", sigMain, InC).MakeBody(1)
|
||||||
|
b.Println(b.BuiltinCall("String", b.CStr("hello"), prog.Val(5)))
|
||||||
|
b.Return()
|
||||||
|
}
|
||||||
|
|
||||||
func TestPointerSize(t *testing.T) {
|
func TestPointerSize(t *testing.T) {
|
||||||
expected := unsafe.Sizeof(uintptr(0))
|
expected := unsafe.Sizeof(uintptr(0))
|
||||||
if size := NewProgram(nil).PointerSize(); size != int(expected) {
|
if size := NewProgram(nil).PointerSize(); size != int(expected) {
|
||||||
|
|||||||
Reference in New Issue
Block a user