Skip to content

Commit

Permalink
fix test because format '%w' cannot work for go1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Feb 12, 2023
1 parent e2ad370 commit acafe50
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
43 changes: 43 additions & 0 deletions join_go1.13_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright © 2023 Hedzr Yeh.

//go:build go1.13
// +build go1.13

package errors_test

import (
"fmt"
"testing"

"gopkg.in/hedzr/errors.v3"
)

func TestJoinErrorsStdFormat(t *testing.T) {
err1 := errors.New("err1")
err2 := errors.New("err2")
err := errors.Join(err1, err2)
fmt.Printf("%T, %v\n", err, err)
if errors.Is(err, err1) {
t.Log("err is err1")
} else {
t.Fatal("expecting err is err1")
}
if errors.Is(err, err2) {
t.Log("err is err2")
} else {
t.Fatal("expecting err is err2")
}

err3 := fmt.Errorf("error3: %w", err)
fmt.Printf("%T, %v\n", err3, errors.Unwrap(err3))
if errors.Is(err3, err1) {
t.Log("err3 is err1")
} else {
t.Fatal("expecting err3 is err1")
}
if errors.Is(err3, err2) {
t.Log("err3 is err2")
} else {
t.Fatal("expecting err3 is err1")
}
}
13 changes: 0 additions & 13 deletions join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,4 @@ func TestJoinErrors(t *testing.T) {
} else {
t.Fatal("expecting err is err2")
}

err3 := fmt.Errorf("error3: %w", err)
fmt.Printf("%T, %v\n", err3, errors.Unwrap(err3))
if errors.Is(err3, err1) {
t.Log("err3 is err1")
} else {
t.Fatal("expecting err3 is err1")
}
if errors.Is(err3, err2) {
t.Log("err3 is err2")
} else {
t.Fatal("expecting err3 is err1")
}
}

0 comments on commit acafe50

Please sign in to comment.