package taxerr

import (
	"errors"
	"testing"

	"github.com/go-rod/rod"
)

func TestU(t *testing.T) {
	var e1 error = nil
	r1 := U(e1)
	if r1 != nil {
		t.Errorf("Expected nil, but got %v", r1)
	}

	e2 := rod.Try(func() { panic("s") })
	r2 := U(e2)
	if r2 == nil || r2.Error() != "s" {
		t.Errorf("Expected try err, but got %v", r2)
	}

	e := errors.New("e")
	e3 := rod.Try(func() { panic(e) })
	r3 := U(e3)
	if r3 != e {
		t.Errorf("Expected e, but got %v", r3)
	}

	e4 := errors.New("normal error")
	r4 := U(e4)
	if r4 != e4 {
		t.Errorf("Expected normal error, but got %v", r4)
	}
}
