forked from ebitengine/purego
-
Notifications
You must be signed in to change notification settings - Fork 1
/
func_sysv_test.go
53 lines (41 loc) · 1.34 KB
/
func_sysv_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
//go:build darwin || freebsd || (linux && (amd64 || arm64))
package purego_test
import (
"testing"
"github.com/jwijenbergh/purego"
)
func TestUnrefCallback(t *testing.T) {
imp := func() bool {
return true
}
if err := purego.UnrefCallback(0); err == nil {
t.Errorf("unref of unknown callback produced nil but wanted error")
}
ref := purego.NewCallback(imp)
if err := purego.UnrefCallback(ref); err != nil {
t.Errorf("callback unref produced %v but wanted nil", err)
}
if err := purego.UnrefCallback(ref); err == nil {
t.Errorf("callback unref of already unref'd callback produced nil but wanted error")
}
}
func TestUnrefCallbackFnPtr(t *testing.T) {
imp := func() bool {
return true
}
if err := purego.UnrefCallbackFnPtr(&imp); err == nil {
t.Errorf("unref of unknown callback produced nil but wanted error")
}
ref := purego.NewCallbackFnPtr(&imp)
if err := purego.UnrefCallbackFnPtr(&imp); err != nil {
t.Errorf("unref produced %v but wanted nil", err)
}
if err := purego.UnrefCallbackFnPtr(&imp); err == nil {
t.Errorf("unref of already unref'd callback produced nil but wanted error")
}
if err := purego.UnrefCallback(ref); err == nil {
t.Errorf("unref of already unref'd callback ptr produced nil but wanted error")
}
}