Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Dec 13, 2023
1 parent 808fb6f commit 8ca2be7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
56 changes: 56 additions & 0 deletions join_go1.11_test.go
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")
}
}
14 changes: 14 additions & 0 deletions join_go1.13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package errors_test
import (
"errors"
"fmt"
"io"
"testing"

v3 "gopkg.in/hedzr/errors.v3"
Expand Down Expand Up @@ -54,3 +55,16 @@ func TestJoinErrorsStdFormat(t *testing.T) {
t.Fatal("FAILED: expecting err2 is err3")
}
}

func TestCauses2_errors(t *testing.T) {

Check failure on line 59 in join_go1.13_test.go

View workflow job for this annotation

GitHub Actions / coverage

other declaration of TestCauses2_errors

Check failure on line 59 in join_go1.13_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, ubuntu-latest)

previous declaration

Check failure on line 59 in join_go1.13_test.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

other declaration of TestCauses2_errors
err := io.EOF

if !errors.Is(err, io.EOF) {
t.Fail()
}

err = dummy(t)
err = fmt.Errorf("wrapped: %w", err)
t.Logf("divide: %v", err)
t.Logf("Unwrap: %v", errors.Unwrap(err))
}

0 comments on commit 8ca2be7

Please sign in to comment.