fix img/sdl_image_test.go
@@ -2,7 +2,6 @@ package img
import (
"testing"
- "unsafe"
"github.com/veandco/go-sdl2/sdl"
)
@@ -188,8 +187,7 @@ func TestIsFormat(t *testing.T) {
}
for _, test := range tests {
- rwops := sdl.RWFromMem(unsafe.Pointer(&test.data[0]), len(test.data))
- defer rwops.RWclose()
+ rwops,_ := sdl.RWFromMem(test.data)
for fname, function := range functions {
got, want := function(rwops), fname == test.name
if got != want {
@@ -210,8 +208,7 @@ func TestLoad_RW(t *testing.T) {
defer Quit()
// test expected success
- rwops := sdl.RWFromMem(unsafe.Pointer(&testPNG[0]), len(testPNG))
- defer rwops.RWclose()
+ rwops,_ := sdl.RWFromMem(testPNG)
surf, err := LoadRW(rwops, false)
if surf != nil {
defer surf.Free()
@@ -221,8 +218,7 @@ func TestLoad_RW(t *testing.T) {
}
// test expected failure
- rwops = sdl.RWFromMem(unsafe.Pointer(&testBadData[0]), len(testBadData))
- defer rwops.RWclose()
+ rwops,_ = sdl.RWFromMem(testBadData)
surf, err = LoadRW(rwops, false)
if surf != nil {
defer surf.Free()
@@ -247,8 +243,7 @@ func TestLoadFormat(t *testing.T) {
for _, test := range tests {
// test expected success
- rwops := sdl.RWFromMem(unsafe.Pointer(&test.data[0]), len(test.data))
- defer rwops.RWclose()
+ rwops,_ := sdl.RWFromMem(test.data)
surf, err := test.function(rwops)
if surf != nil {
defer surf.Free()
@@ -264,8 +259,7 @@ func TestLoadFormat(t *testing.T) {
continue
}
- rwops = sdl.RWFromMem(unsafe.Pointer(&testBadData[0]), len(testBadData))
- defer rwops.RWclose()
+ rwops,_ = sdl.RWFromMem(testBadData)
surf, err = test.function(rwops)
if surf != nil {
defer surf.Free()
@@ -281,8 +275,7 @@ func TestLoadTyped_RW(t *testing.T) {
defer Quit()
// test expected success
- rwops := sdl.RWFromMem(unsafe.Pointer(&testPNG[0]), len(testPNG))
- defer rwops.RWclose()
+ rwops,_ := sdl.RWFromMem(testPNG)
surf, err := LoadTypedRW(rwops, false, "PNG")
if surf != nil {
defer surf.Free()
@@ -293,8 +286,7 @@ func TestLoadTyped_RW(t *testing.T) {
}
// test expected failure
- rwops = sdl.RWFromMem(unsafe.Pointer(&testBadData[0]), len(testBadData))
- defer rwops.RWclose()
+ rwops,_ = sdl.RWFromMem(testBadData)
surf, err = LoadTypedRW(rwops, false, "PNG")
if surf != nil {
defer surf.Free()
