mirror of
https://github.com/golang/go.git
synced 2024-09-22 02:48:50 +00:00
misc/cgo/test: test C.enum_*
Allocate a C enum object, and test if it can be assigned a value
successfully.
For #39537
Change-Id: I7b5482112486440b9d99f2ee4051328d87f45dca
GitHub-Last-Rev: 81890f40ac
GitHub-Pull-Request: golang/go#39977
Reviewed-on: https://go-review.googlesource.com/c/go/+/240697
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
8fdc79e18a
commit
3f6b1a0d5e
@ -76,6 +76,8 @@ func TestCheckConst(t *testing.T) { testCheckConst(t) }
|
||||
func TestConst(t *testing.T) { testConst(t) }
|
||||
func TestCthread(t *testing.T) { testCthread(t) }
|
||||
func TestEnum(t *testing.T) { testEnum(t) }
|
||||
func TestNamedEnum(t *testing.T) { testNamedEnum(t) }
|
||||
func TestCastToEnum(t *testing.T) { testCastToEnum(t) }
|
||||
func TestErrno(t *testing.T) { testErrno(t) }
|
||||
func TestFpVar(t *testing.T) { testFpVar(t) }
|
||||
func TestHelpers(t *testing.T) { testHelpers(t) }
|
||||
|
@ -1000,6 +1000,32 @@ func testEnum(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testNamedEnum(t *testing.T) {
|
||||
e := new(C.enum_E)
|
||||
|
||||
*e = C.Enum1
|
||||
if *e != 1 {
|
||||
t.Error("bad enum", C.Enum1)
|
||||
}
|
||||
|
||||
*e = C.Enum2
|
||||
if *e != 2 {
|
||||
t.Error("bad enum", C.Enum2)
|
||||
}
|
||||
}
|
||||
|
||||
func testCastToEnum(t *testing.T) {
|
||||
e := C.enum_E(C.Enum1)
|
||||
if e != 1 {
|
||||
t.Error("bad enum", C.Enum1)
|
||||
}
|
||||
|
||||
e = C.enum_E(C.Enum2)
|
||||
if e != 2 {
|
||||
t.Error("bad enum", C.Enum2)
|
||||
}
|
||||
}
|
||||
|
||||
func testAtol(t *testing.T) {
|
||||
l := Atol("123")
|
||||
if l != 123 {
|
||||
|
Loading…
Reference in New Issue
Block a user