err_test.go 586 B

1234567891011121314151617181920212223242526272829303132333435
  1. package taxerr
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/go-rod/rod"
  6. )
  7. func TestU(t *testing.T) {
  8. var e1 error = nil
  9. r1 := U(e1)
  10. if r1 != nil {
  11. t.Errorf("Expected nil, but got %v", r1)
  12. }
  13. e2 := rod.Try(func() { panic("s") })
  14. r2 := U(e2)
  15. if r2 == nil || r2.Error() != "s" {
  16. t.Errorf("Expected try err, but got %v", r2)
  17. }
  18. e := errors.New("e")
  19. e3 := rod.Try(func() { panic(e) })
  20. r3 := U(e3)
  21. if r3 != e {
  22. t.Errorf("Expected e, but got %v", r3)
  23. }
  24. e4 := errors.New("normal error")
  25. r4 := U(e4)
  26. if r4 != e4 {
  27. t.Errorf("Expected normal error, but got %v", r4)
  28. }
  29. }