common_test.go 429 B

1234567891011121314151617181920212223242526272829
  1. package common_test
  2. import (
  3. "errors"
  4. "testing"
  5. . "v2ray.com/core/common"
  6. . "v2ray.com/ext/assert"
  7. )
  8. func TestMust(t *testing.T) {
  9. assert := With(t)
  10. f := func() error {
  11. return errors.New("test error")
  12. }
  13. assert(func() { Must(f()) }, Panics)
  14. }
  15. func TestMust2(t *testing.T) {
  16. assert := With(t)
  17. f := func() (interface{}, error) {
  18. return nil, errors.New("test error")
  19. }
  20. assert(func() { Must2(f()) }, Panics)
  21. }