-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright © 2023 Hedzr Yeh. | ||
|
||
//go:build go1.11 | ||
// +build go1.11 | ||
|
||
package errors_test | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"testing" | ||
|
||
v3 "gopkg.in/hedzr/errors.v3" | ||
) | ||
|
||
func TestJoinErrorsStdFormatGo111(t *testing.T) { | ||
err1 := errors.New("err1") | ||
err2 := errors.New("err2") | ||
|
||
err := v3.Join(err1, err2) | ||
|
||
fmt.Printf("%T, %v\n", err, err) | ||
|
||
if v3.Is(err, err1) { | ||
t.Log("err is err1") | ||
} else { | ||
t.Fatal("FAILED: expecting err is err1") | ||
} | ||
|
||
if v3.Is(err, err2) { | ||
t.Log("err is err2") | ||
} else { | ||
t.Fatal("FAILED: expecting err is err2") | ||
} | ||
|
||
err3 := fmt.Errorf("error3: %w", err) | ||
fmt.Printf("%T, %v\n", err3, v3.Unwrap(err3)) | ||
|
||
if v3.Is(err3, err1) { | ||
t.Log("err3 is err1") | ||
} else { | ||
t.Fatal("FAILED: expecting err3 is err1") | ||
} | ||
|
||
if v3.Is(err3, err2) { | ||
t.Log("err3 is err2") | ||
} else { | ||
t.Fatal("FAILED: expecting err3 is err2") | ||
} | ||
|
||
if !v3.Is(err2, err3) { | ||
t.Log("err2 isn't err3") | ||
} else { | ||
t.Fatal("FAILED: expecting err2 is err3") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters