Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
test/string_memmem,string_strchr,string_strcspn,string_strstr,strtod_…
Browse files Browse the repository at this point in the history
…long,strtod_simple,strtold
  • Loading branch information
xushiwei committed Aug 5, 2022
1 parent 5bfbab6 commit bec78be
Show file tree
Hide file tree
Showing 16 changed files with 1,188 additions and 4 deletions.
29 changes: 26 additions & 3 deletions test/c2go.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,40 @@
"dlopen_dso",
"dlopen",
"env",
"fcntl"
"fcntl",
"fdopen",
"fnmatch",
"fscanf",
"fwscanf",
"iconv_open",
"inet_pton",
"ipc_msg",
"ipc_shm",
"mbc",
"memstream",
"popen",
"strptime",
"strtof",
"strtol",
"swprintf"
],
"for": [
"string_memmem",
"string_strchr",
"string_strcspn",
"string_strstr",
"strtod_long",
"strtod_simple",
"strtold",

"basename",
"dirname",
"qsort",
"random",
"strtod",
"string",
"string_memcpy",
"string_memset",
"string",
"strtod",
"snprintf"
],
"dir": "cmd/test_$(it)",
Expand Down
1 change: 1 addition & 0 deletions test/cmd/test/string_memmem/c2go_header.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package string_memmem
306 changes: 306 additions & 0 deletions test/cmd/test/string_memmem/string_memmem.c.i.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/cmd/test/string_strchr/c2go_header.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package string_strchr
332 changes: 332 additions & 0 deletions test/cmd/test/string_strchr/string_strchr.c.i.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/cmd/test/string_strcspn/c2go_header.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package string_strcspn
90 changes: 90 additions & 0 deletions test/cmd/test/string_strcspn/string_strcspn.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package string_strcspn

import (
unsafe "unsafe"
libc "github.com/goplus/libc"
common "github.com/goplus/libc/test/common"
testing "testing"
)

func _cgo_main() int32 {
var i int32
var a [128]int8
var s [256]int8
for i = int32(0); i < int32(128); i++ {
*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer((*int8)(unsafe.Pointer(&a)))) + uintptr(i))) = int8((i + int32(1)) & int32(127))
}
for i = int32(0); i < int32(256); i++ {
*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer((*uint8)(unsafe.Pointer((*int8)(unsafe.Pointer(&s)))))) + uintptr(i))) = uint8(i + int32(1))
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[1]int8{'\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&[1]int8{'\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(0) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '4', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[3]int8{'"', '"', '\x00'})), (*int8)(unsafe.Pointer(&[3]int8{'"', '"', '\x00'})), uint64(r), uint64(0))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[2]int8{'a', '\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&[1]int8{'\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(1) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '5', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[4]int8{'"', 'a', '"', '\x00'})), (*int8)(unsafe.Pointer(&[3]int8{'"', '"', '\x00'})), uint64(r), uint64(1))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[1]int8{'\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&[2]int8{'a', '\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(0) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '6', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[3]int8{'"', '"', '\x00'})), (*int8)(unsafe.Pointer(&[4]int8{'"', 'a', '"', '\x00'})), uint64(r), uint64(0))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[4]int8{'a', 'b', 'c', '\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&[4]int8{'c', 'd', 'e', '\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(2) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '7', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[6]int8{'"', 'a', 'b', 'c', '"', '\x00'})), (*int8)(unsafe.Pointer(&[6]int8{'"', 'c', 'd', 'e', '"', '\x00'})), uint64(r), uint64(2))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[4]int8{'a', 'b', 'c', '\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&[4]int8{'c', 'c', 'c', '\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(2) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '8', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[6]int8{'"', 'a', 'b', 'c', '"', '\x00'})), (*int8)(unsafe.Pointer(&[6]int8{'"', 'c', 'c', 'c', '"', '\x00'})), uint64(r), uint64(2))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[4]int8{'a', 'b', 'c', '\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&a))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(0) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '2', '9', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[6]int8{'"', 'a', 'b', 'c', '"', '\x00'})), (*int8)(unsafe.Pointer(&[2]int8{'a', '\x00'})), uint64(r), uint64(0))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&[7]int8{-1, -128, ' ', 'a', 'b', 'c', '\x00'}))
var q *int8 = (*int8)(unsafe.Pointer(&a))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(2) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '3', '0', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[15]int8{'"', '\\', 'x', 'f', 'f', '\\', 'x', '8', '0', ' ', 'a', 'b', 'c', '"', '\x00'})), (*int8)(unsafe.Pointer(&[2]int8{'a', '\x00'})), uint64(r), uint64(2))
}
}
{
var p *int8 = (*int8)(unsafe.Pointer(&s))
var q *int8 = (*int8)(unsafe.Pointer(&[2]int8{-1, '\x00'}))
var r uint64 = libc.Strcspn(p, q)
if r != uint64(254) {
common.T_printf((*int8)(unsafe.Pointer(&[108]int8{'/', 'U', 's', 'e', 'r', 's', '/', 'x', 'u', 's', 'h', 'i', 'w', 'e', 'i', '/', 'w', 'o', 'r', 'k', '/', 'l', 'i', 'b', 'c', '/', 't', 'e', 's', 't', '/', 's', 'r', 'c', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 'a', 'l', '/', 's', 't', 'r', 'i', 'n', 'g', '_', 's', 't', 'r', 'c', 's', 'p', 'n', '.', 'c', ':', '3', '1', ':', ' ', 's', 't', 'r', 'c', 's', 'p', 'n', '(', '%', 's', ',', '%', 's', ')', ' ', 'r', 'e', 't', 'u', 'r', 'n', 'e', 'd', ' ', '%', 'l', 'u', ',', ' ', 'w', 'a', 'n', 't', 'e', 'd', ' ', '%', 'l', 'u', '\n', '\x00'})), (*int8)(unsafe.Pointer(&[2]int8{'s', '\x00'})), (*int8)(unsafe.Pointer(&[7]int8{'"', '\\', 'x', 'f', 'f', '"', '\x00'})), uint64(r), uint64(254))
}
}
return common.T_status
}
func TestMain(t *testing.T) {
if _cgo_ret := _cgo_main(); _cgo_ret != 0 {
t.Fatal("exit status", _cgo_ret)
}
}
1 change: 1 addition & 0 deletions test/cmd/test/string_strstr/c2go_header.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package string_strstr
Loading

0 comments on commit bec78be

Please sign in to comment.