aboutsummaryrefslogtreecommitdiff
path: root/src/errors
diff options
context:
space:
mode:
authorfangguizhen <1297394526@qq.com>2022-10-17 18:32:36 +0000
committerGopher Robot <gobot@golang.org>2022-10-17 21:48:12 +0000
commit26b48442569102226baba1d9b4a83aaee3d06611 (patch)
treea7f922748c4f61b8f8f4d0b4296fe7b44a4117c2 /src/errors
parent834858fa5f6ecf980116c9ab7a2927931fe54c85 (diff)
downloadgo-26b48442569102226baba1d9b4a83aaee3d06611.tar.xz
errors: add test for Join
Change-Id: I77c61211a488c66f1d445c0bf01e35aaf4f83565 GitHub-Last-Rev: c411a56a3b5215e6dd093be7069affb176b48dfd GitHub-Pull-Request: golang/go#56279 Reviewed-on: https://go-review.googlesource.com/c/go/+/443316 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/errors')
-rw-r--r--src/errors/join_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/errors/join_test.go b/src/errors/join_test.go
index ee69314529..4828dc4d75 100644
--- a/src/errors/join_test.go
+++ b/src/errors/join_test.go
@@ -47,3 +47,26 @@ func TestJoin(t *testing.T) {
}
}
}
+
+func TestJoinErrorMethod(t *testing.T) {
+ err1 := errors.New("err1")
+ err2 := errors.New("err2")
+ for _, test := range []struct {
+ errs []error
+ want string
+ }{{
+ errs: []error{err1},
+ want: "err1",
+ }, {
+ errs: []error{err1, err2},
+ want: "err1\nerr2",
+ }, {
+ errs: []error{err1, nil, err2},
+ want: "err1\nerr2",
+ }} {
+ got := errors.Join(test.errs...).Error()
+ if got != test.want {
+ t.Errorf("Join(%v).Error() = %q; want %q", test.errs, got, test.want)
+ }
+ }
+}