"testing"
)
-func TestAlign(t *testing.T) {
+func testAlign(t *testing.T) {
var evt C.SDL_KeyboardEvent
C.makeEvent(&evt)
if C.same(&evt, evt.typ, evt.which, evt.state, evt.keysym.scancode, evt.keysym.sym, evt.keysym.mod, evt.keysym.unicode) == 0 {
return int(n)
}
-func TestConst(t *testing.T) {
+func testConst(t *testing.T) {
C.myConstFunc(nil, 0, nil)
}
-func TestEnum(t *testing.T) {
+func testEnum(t *testing.T) {
if C.Enum1 != 1 || C.Enum2 != 2 {
t.Error("bad enum", C.Enum1, C.Enum2)
}
}
-func TestAtol(t *testing.T) {
+func testAtol(t *testing.T) {
l := Atol("123")
if l != 123 {
t.Error("Atol 123: ", l)
}
}
-func TestErrno(t *testing.T) {
+func testErrno(t *testing.T) {
n, err := Strtol("asdf", 123)
if n != 0 || err != os.EINVAL {
t.Error("Strtol: ", n, err)
}
}
-func TestMultipleAssign(t *testing.T) {
+func testMultipleAssign(t *testing.T) {
p := C.CString("234")
n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
if n != 0 || m != 234 {
(*(*func())(unsafe.Pointer(&p)))()
}
-func TestCallback(t *testing.T) {
+func testCallback(t *testing.T) {
var x = false
nestedCall(func() { x = true })
if !x {
}
}
-func TestCallbackGC(t *testing.T) {
+func testCallbackGC(t *testing.T) {
nestedCall(runtime.GC)
}
func lockedOSThread() bool // in runtime.c
-func TestCallbackPanic(t *testing.T) {
+func testCallbackPanic(t *testing.T) {
// Make sure panic during callback unwinds properly.
if lockedOSThread() {
t.Fatal("locked OS thread on entry to TestCallbackPanic")
panic("nestedCall returned")
}
-func TestCallbackPanicLoop(t *testing.T) {
+func testCallbackPanicLoop(t *testing.T) {
// Make sure we don't blow out m->g0 stack.
for i := 0; i < 100000; i++ {
TestCallbackPanic(t)
}
}
-func TestCallbackPanicLocked(t *testing.T) {
+func testCallbackPanicLocked(t *testing.T) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
// Callback with zero arguments used to make the stack misaligned,
// which broke the garbage collector and other things.
-func TestZeroArgCallback(t *testing.T) {
+func testZeroArgCallback(t *testing.T) {
defer func() {
s := recover()
if s != nil {
func variadic(x ...interface{}) {}
-func TestBlocking(t *testing.T) {
+func testBlocking(t *testing.T) {
c := make(chan int)
go func() {
for i := 0; i < 10; i++ {
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package cgotest
-// dummy file so gotest thinks there are tests.
-// the actual tests are in the main go files, next
-// to the code they test.
+import "testing"
+
+// The actual test functions are in non-_test.go files
+// so that they can use cgo (import "C").
+// These wrappers are here for gotest to find.
+
+func TestAlign(t *testing.T) { testAlign(t) }
+func TestConst(t *testing.T) { testConst(t) }
+func TestEnum(t *testing.T) { testEnum(t) }
+func TestAtol(t *testing.T) { testAtol(t) }
+func TestErrno(t *testing.T) { testErrno(t) }
+func TestMultipleAssign(t *testing.T) { testMultipleAssign(t) }
+func TestCallback(t *testing.T) { testCallback(t) }
+func TestCallbackGC(t *testing.T) { testCallbackGC(t) }
+func TestCallbackPanic(t *testing.T) { testCallbackPanic(t) }
+func TestCallbackPanicLoop(t *testing.T) { testCallbackPanicLoop(t) }
+func TestCallbackPanicLocked(t *testing.T) { testCallbackPanicLocked(t) }
+func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
+func TestBlocking(t *testing.T) { testBlocking(t) }
+func Test1328(t *testing.T) { test1328(t) }
+func TestParallelSleep(t *testing.T) { testParallelSleep(t) }
func xvariadic(x ...interface{}) {
}
-func Test1328(t *testing.T) {
+func test1328(t *testing.T) {
C.IntoC()
}
}()
}
-func TestParallelSleep(t *testing.T) {
+func testParallelSleep(t *testing.T) {
dt := -time.Nanoseconds()
parallelSleep(1)
dt += time.Nanoseconds()