v2ray-core/context_test.go

35 lines
629 B
Go
Raw Normal View History

2018-10-21 20:33:08 +02:00
package core_test
import (
"context"
"testing"
2021-02-17 04:31:50 +08:00
. "github.com/v2fly/v2ray-core/v4"
2021-04-05 18:13:24 +01:00
_ "unsafe"
2018-10-21 20:33:08 +02:00
)
func TestFromContextPanic(t *testing.T) {
2018-10-21 20:33:08 +02:00
defer func() {
r := recover()
if r == nil {
t.Error("expect panic, but nil")
}
}()
MustFromContext(context.Background())
}
2021-04-05 18:13:24 +01:00
//go:linkname mustToContextForced github.com/v2fly/v2ray-core/v4.mustToContext
func mustToContextForced(ctx context.Context, v *Instance) context.Context
func TestToContextPanic(t *testing.T) {
defer func() {
r := recover()
if r == nil {
t.Error("expect panic, but nil")
}
}()
2021-04-05 18:13:24 +01:00
mustToContextForced(context.Background(), &Instance{})
}