mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
26 lines
469 B
Go
26 lines
469 B
Go
package xerror
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/duke-git/lancet/v2/internal"
|
|
)
|
|
|
|
func TestUnwrap(t *testing.T) {
|
|
assert := internal.NewAssert(t, "TestUnwrap")
|
|
assert.Equal(42, Unwrap(strconv.Atoi("42")))
|
|
}
|
|
|
|
func TestUnwrapFail(t *testing.T) {
|
|
assert := internal.NewAssert(t, "TestUnwrapFail")
|
|
|
|
_, err := strconv.Atoi("4o2")
|
|
defer func() {
|
|
v := recover()
|
|
assert.Equal(err.Error(), v.(*strconv.NumError).Error())
|
|
}()
|
|
|
|
Unwrap(strconv.Atoi("4o2"))
|
|
}
|