github.com/searKing/golang/go@v1.2.74/error/multi/multi_test.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package multi_test 6 7 import ( 8 "fmt" 9 "testing" 10 11 "github.com/searKing/golang/go/error/multi" 12 ) 13 14 func TestNew(t *testing.T) { 15 tests := []struct { 16 errs []error 17 want error 18 }{ 19 {nil, nil}, 20 {[]error{}, nil}, 21 {[]error{fmt.Errorf("foo")}, fmt.Errorf("foo")}, 22 {[]error{fmt.Errorf("foo"), fmt.Errorf("fun")}, multi.New(fmt.Errorf("foo"), fmt.Errorf("fun"))}, 23 } 24 25 for _, tt := range tests { 26 got := multi.New(tt.errs...) 27 if got == tt.want { 28 continue 29 } 30 if got == nil || tt.want == nil || got.Error() != tt.want.Error() { 31 t.Errorf("New.Error(): got: %q, want %q", got, tt.want) 32 } 33 } 34 }