context_test.go 456 B

123456789101112131415161718192021222324252627282930
  1. package core_test
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/v2fly/v2ray-core/v4"
  6. )
  7. func TestFromContextPanic(t *testing.T) {
  8. defer func() {
  9. r := recover()
  10. if r == nil {
  11. t.Error("expect panic, but nil")
  12. }
  13. }()
  14. MustFromContext(context.Background())
  15. }
  16. func TestToContextPanic(t *testing.T) {
  17. defer func() {
  18. r := recover()
  19. if r == nil {
  20. t.Error("expect panic, but nil")
  21. }
  22. }()
  23. MustToContext(context.Background(), &Instance{})
  24. }