]> Cypherpunks.ru repositories - gostls13.git/commitdiff
errors: add test for Join
authorfangguizhen <1297394526@qq.com>
Mon, 17 Oct 2022 18:32:36 +0000 (18:32 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 17 Oct 2022 21:48:12 +0000 (21:48 +0000)
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>

src/errors/join_test.go

index ee69314529f68c1f769392b4b37c02944e9339e9..4828dc4d755fd678d0b3ca31f7fdebc5e1dcaeaf 100644 (file)
@@ -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)
+               }
+       }
+}