Move benchmark functionality and remove caller function
diff --git a/diffmatchpatch/benchutil_test.go b/diffmatchpatch/benchutil_test.go new file mode 100644 index 0000000..85f273b --- /dev/null +++ b/diffmatchpatch/benchutil_test.go
@@ -0,0 +1,26 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +package diffmatchpatch + +import ( + "io/ioutil" +) + +func speedtestTexts() (s1 string, s2 string) { + d1, err := ioutil.ReadFile("../testdata/speedtest1.txt") + if err != nil { + panic(err) + } + d2, err := ioutil.ReadFile("../testdata/speedtest2.txt") + if err != nil { + panic(err) + } + + return string(d1), string(d2) +}
diff --git a/diffmatchpatch/diffmatchpatch_test.go b/diffmatchpatch/diffmatchpatch_test.go index 0d843ad..830e4bd 100644 --- a/diffmatchpatch/diffmatchpatch_test.go +++ b/diffmatchpatch/diffmatchpatch_test.go
@@ -10,38 +10,11 @@ import ( "fmt" - "io/ioutil" - "runtime" "testing" "github.com/stretchr/testify/assert" ) -func caller() string { - _, _, line, ok := runtime.Caller(2) - if !ok { - return "" - } - - return fmt.Sprintf("at line %d ", line) -} - -func readFile(filepath string) string { - data, err := ioutil.ReadFile(filepath) - if err != nil { - panic(err) - } - - return string(data) -} - -func speedtestTexts() (s1 string, s2 string) { - s1 = readFile("../testdata/speedtest1.txt") - s2 = readFile("../testdata/speedtest2.txt") - - return s1, s2 -} - func TestRunesIndexOf(t *testing.T) { type TestCase struct { Pattern string