Skip to content

Commit 9f8e7fb

Browse files
authored
Merge pull request #139 from xushiwei/strm
test.Diff: remove dep of *testing.T
2 parents 0ac1e8a + 6c97d39 commit 9f8e7fb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

test/util.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package test
1919
import (
2020
"log"
2121
"os"
22-
"testing"
2322
)
2423

2524
// -----------------------------------------------------------------------------
@@ -36,9 +35,16 @@ func Fatalf(format string, v ...any) {
3635

3736
// -----------------------------------------------------------------------------
3837

38+
// testingT is an interface that abstracts *testing.T to decouple this package
39+
// from the testing package dependency.
40+
type testingT interface {
41+
// Errorf is equivalent to Logf followed by Fail.
42+
Errorf(format string, args ...any)
43+
}
44+
3945
// Diff compares the dst and src byte slices.
4046
// If they are different, it writes the dst to the outfile and logs the differences.
41-
func Diff(t *testing.T, outfile string, dst, src []byte) bool {
47+
func Diff(t testingT, outfile string, dst, src []byte) bool {
4248
line := 1
4349
offs := 0 // line offset
4450
for i := 0; i < len(dst) && i < len(src); i++ {

0 commit comments

Comments
 (0)