aboutsummaryrefslogtreecommitdiff
path: root/src/errors/wrap_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors/wrap_test.go')
-rw-r--r--src/errors/wrap_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go
index ca9dc0f111..0a7bc5d16a 100644
--- a/src/errors/wrap_test.go
+++ b/src/errors/wrap_test.go
@@ -238,6 +238,27 @@ func TestAsValidation(t *testing.T) {
}
}
+func BenchmarkIs(b *testing.B) {
+ err1 := errors.New("1")
+ err2 := multiErr{multiErr{multiErr{err1, errorT{"a"}}, errorT{"b"}}}
+
+ for i := 0; i < b.N; i++ {
+ if !errors.Is(err2, err1) {
+ b.Fatal("Is failed")
+ }
+ }
+}
+
+func BenchmarkAs(b *testing.B) {
+ err := multiErr{multiErr{multiErr{errors.New("a"), errorT{"a"}}, errorT{"b"}}}
+ for i := 0; i < b.N; i++ {
+ var target errorT
+ if !errors.As(err, &target) {
+ b.Fatal("As failed")
+ }
+ }
+}
+
func TestUnwrap(t *testing.T) {
err1 := errors.New("1")
erra := wrapped{"wrap 2", err1}