github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/errors/set_test.go (about) 1 package errors 2 3 import "testing" 4 5 func TestUnwrapErrorSetNil(t *testing.T) { 6 var err error 7 errs := UnwrapErrorSet(err) 8 //assert(t, nil, errs) 9 assert(t, 0, len(errs)) 10 } 11 12 func TestUnwrapErrorSetWrongType(t *testing.T) { 13 var err error = ErrValueMalformed 14 errs := UnwrapErrorSet(err) 15 //assert(t, nil, errs) 16 assert(t, 0, len(errs)) 17 } 18 19 func TestErrorSetEmpty(t *testing.T) { 20 var err error = Set() 21 assert(t, "", err.Error()) 22 23 errs := UnwrapErrorSet(err) 24 assert(t, 0, len(errs)) 25 } 26 27 func TestErrorSetTwo(t *testing.T) { 28 var err error = Set(Msg("first"), Msg("second")) 29 assert(t, "first, second", err.Error()) 30 31 errs := UnwrapErrorSet(err) 32 assert(t, 2, len(errs)) 33 34 errSet, ok := err.(ErrorSet) 35 assert(t, true, ok) 36 assert(t, 2, len(errSet.Errors())) 37 }