summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2014-04-01 00:15:10 -0300
committerGustavo Niemeyer <gustavo@niemeyer.net>2014-04-01 00:15:10 -0300
commit30a6840d0976b3e92543ec4b597185c488c59451 (patch)
treefc12c2c051073ac23a3284a01148e0fcec2afddd
parent7001e3a65c8aa37ef1f78f3395b425e5bbf8c507 (diff)
downloadcheck-30a6840d0976b3e92543ec4b597185c488c59451.tar.xz
launchpad.net/gocheck => gopkg.in/check.v1
-rw-r--r--benchmark.go2
-rw-r--r--benchmark_test.go14
-rw-r--r--bootstrap_test.go24
-rw-r--r--check.go (renamed from gocheck.go)10
-rw-r--r--check_test.go (renamed from gocheck_test.go)36
-rw-r--r--checkers.go2
-rw-r--r--checkers_test.go258
-rw-r--r--export_test.go2
-rw-r--r--fixture_test.go50
-rw-r--r--foundation_test.go88
-rw-r--r--helpers.go2
-rw-r--r--helpers_test.go112
-rw-r--r--printer.go2
-rw-r--r--printer_test.go4
-rw-r--r--run.go44
-rw-r--r--run_test.go10
16 files changed, 336 insertions, 324 deletions
diff --git a/benchmark.go b/benchmark.go
index dcd426f..ee1cfe6 100644
--- a/benchmark.go
+++ b/benchmark.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package gocheck
+package check
import (
"fmt"
diff --git a/benchmark_test.go b/benchmark_test.go
index 336243f..b7f7b44 100644
--- a/benchmark_test.go
+++ b/benchmark_test.go
@@ -1,9 +1,9 @@
// These tests verify the test running logic.
-package gocheck_test
+package check_test
import (
- . "launchpad.net/gocheck"
+ . "gopkg.in/check.v1"
"time"
)
@@ -21,8 +21,8 @@ func (s *BenchmarkS) TestBasicTestTiming(c *C) {
runConf := RunConf{Output: &output, Verbose: true}
Run(&helper, &runConf)
- expected := "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" +
- "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n"
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" +
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n"
c.Assert(output.value, Matches, expected)
}
@@ -32,7 +32,7 @@ func (s *BenchmarkS) TestStreamTestTiming(c *C) {
runConf := RunConf{Output: &output, Stream: true}
Run(&helper, &runConf)
- expected := "(?s).*\nPASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*"
+ expected := "(?s).*\nPASS: check_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*"
c.Assert(output.value, Matches, expected)
}
@@ -55,7 +55,7 @@ func (s *BenchmarkS) TestBenchmark(c *C) {
c.Check(helper.calls[6], Equals, "TearDownTest")
// ... and more.
- expected := "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n"
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n"
c.Assert(output.value, Matches, expected)
}
@@ -70,6 +70,6 @@ func (s *BenchmarkS) TestBenchmarkBytes(c *C) {
}
Run(&helper, &runConf)
- expected := "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n"
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n"
c.Assert(output.value, Matches, expected)
}
diff --git a/bootstrap_test.go b/bootstrap_test.go
index a3bc28c..e55f327 100644
--- a/bootstrap_test.go
+++ b/bootstrap_test.go
@@ -10,23 +10,23 @@
// Do not assume *any* internal functionality works as expected besides
// what's actually tested here.
-package gocheck_test
+package check_test
import (
"fmt"
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
"strings"
)
type BootstrapS struct{}
-var boostrapS = gocheck.Suite(&BootstrapS{})
+var boostrapS = check.Suite(&BootstrapS{})
-func (s *BootstrapS) TestCountSuite(c *gocheck.C) {
+func (s *BootstrapS) TestCountSuite(c *check.C) {
suitesRun += 1
}
-func (s *BootstrapS) TestFailedAndFail(c *gocheck.C) {
+func (s *BootstrapS) TestFailedAndFail(c *check.C) {
if c.Failed() {
critical("c.Failed() must be false first!")
}
@@ -37,7 +37,7 @@ func (s *BootstrapS) TestFailedAndFail(c *gocheck.C) {
c.Succeed()
}
-func (s *BootstrapS) TestFailedAndSucceed(c *gocheck.C) {
+func (s *BootstrapS) TestFailedAndSucceed(c *check.C) {
c.Fail()
c.Succeed()
if c.Failed() {
@@ -45,7 +45,7 @@ func (s *BootstrapS) TestFailedAndSucceed(c *gocheck.C) {
}
}
-func (s *BootstrapS) TestLogAndGetTestLog(c *gocheck.C) {
+func (s *BootstrapS) TestLogAndGetTestLog(c *check.C) {
c.Log("Hello there!")
log := c.GetTestLog()
if log != "Hello there!\n" {
@@ -53,7 +53,7 @@ func (s *BootstrapS) TestLogAndGetTestLog(c *gocheck.C) {
}
}
-func (s *BootstrapS) TestLogfAndGetTestLog(c *gocheck.C) {
+func (s *BootstrapS) TestLogfAndGetTestLog(c *check.C) {
c.Logf("Hello %v", "there!")
log := c.GetTestLog()
if log != "Hello there!\n" {
@@ -61,9 +61,9 @@ func (s *BootstrapS) TestLogfAndGetTestLog(c *gocheck.C) {
}
}
-func (s *BootstrapS) TestRunShowsErrors(c *gocheck.C) {
+func (s *BootstrapS) TestRunShowsErrors(c *check.C) {
output := String{}
- gocheck.Run(&FailHelper{}, &gocheck.RunConf{Output: &output})
+ check.Run(&FailHelper{}, &check.RunConf{Output: &output})
if strings.Index(output.value, "Expected failure!") == -1 {
critical(fmt.Sprintf("RunWithWriter() output did not contain the "+
"expected failure! Got: %#v",
@@ -71,9 +71,9 @@ func (s *BootstrapS) TestRunShowsErrors(c *gocheck.C) {
}
}
-func (s *BootstrapS) TestRunDoesntShowSuccesses(c *gocheck.C) {
+func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) {
output := String{}
- gocheck.Run(&SuccessHelper{}, &gocheck.RunConf{Output: &output})
+ check.Run(&SuccessHelper{}, &check.RunConf{Output: &output})
if strings.Index(output.value, "Expected success!") != -1 {
critical(fmt.Sprintf("RunWithWriter() output contained a successful "+
"test! Got: %#v",
diff --git a/gocheck.go b/check.go
index 21977db..5239f6a 100644
--- a/gocheck.go
+++ b/check.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
import (
"bytes"
@@ -128,7 +128,7 @@ func (td *tempDir) newPath() string {
if td.path == "" {
var err error
for i := 0; i != 100; i++ {
- path := fmt.Sprintf("%s/gocheck-%d", os.TempDir(), rand.Int())
+ path := fmt.Sprintf("%s/check-%d", os.TempDir(), rand.Int())
if err = os.Mkdir(path, 0700); err == nil {
td.path = path
break
@@ -738,7 +738,7 @@ func (runner *suiteRunner) forkTest(method *methodType) *C {
// Rather than a plain panic, provide a more helpful message when
// the argument type is incorrect.
c.status = panickedSt
- c.logArgPanic(c.method, "*gocheck.C")
+ c.logArgPanic(c.method, "*check.C")
return
}
if strings.HasPrefix(c.method.Info.Name, "Test") {
@@ -797,7 +797,7 @@ func (runner *suiteRunner) skipTests(status funcStatus, methods []*methodType) {
}
}
-// Verify if the fixture arguments are *gocheck.C. In case of errors,
+// Verify if the fixture arguments are *check.C. In case of errors,
// log the error as a panic in the fixture method call, and return false.
func (runner *suiteRunner) checkFixtureArgs() bool {
succeeded := true
@@ -808,7 +808,7 @@ func (runner *suiteRunner) checkFixtureArgs() bool {
if mt.NumIn() != 1 || mt.In(0) != argType {
succeeded = false
runner.runFunc(method, fixtureKd, nil, func(c *C) {
- c.logArgPanic(method, "*gocheck.C")
+ c.logArgPanic(method, "*check.C")
c.status = panickedSt
})
}
diff --git a/gocheck_test.go b/check_test.go
index e4acda9..19c0c5b 100644
--- a/gocheck_test.go
+++ b/check_test.go
@@ -1,12 +1,12 @@
// This file contains just a few generic helpers which are used by the
// other test files.
-package gocheck_test
+package check_test
import (
"flag"
"fmt"
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
"os"
"regexp"
"runtime"
@@ -22,8 +22,8 @@ const suitesRunExpected = 8
var suitesRun int = 0
func Test(t *testing.T) {
- gocheck.TestingT(t)
- if suitesRun != suitesRunExpected && flag.Lookup("gocheck.f").Value.String() == "" {
+ check.TestingT(t)
+ if suitesRun != suitesRunExpected && flag.Lookup("check.f").Value.String() == "" {
critical(fmt.Sprintf("Expected %d suites to run rather than %d",
suitesRunExpected, suitesRun))
}
@@ -64,8 +64,8 @@ func (s *String) Write(p []byte) (n int, err error) {
// Trivial wrapper to test errors happening on a different file
// than the test itself.
-func checkEqualWrapper(c *gocheck.C, obtained, expected interface{}) (result bool, line int) {
- return c.Check(obtained, gocheck.Equals, expected), getMyLine()
+func checkEqualWrapper(c *check.C, obtained, expected interface{}) (result bool, line int) {
+ return c.Check(obtained, check.Equals, expected), getMyLine()
}
// -----------------------------------------------------------------------
@@ -75,7 +75,7 @@ type FailHelper struct {
testLine int
}
-func (s *FailHelper) TestLogAndFail(c *gocheck.C) {
+func (s *FailHelper) TestLogAndFail(c *check.C) {
s.testLine = getMyLine() - 1
c.Log("Expected failure!")
c.Fail()
@@ -86,7 +86,7 @@ func (s *FailHelper) TestLogAndFail(c *gocheck.C) {
type SuccessHelper struct{}
-func (s *SuccessHelper) TestLogAndSucceed(c *gocheck.C) {
+func (s *SuccessHelper) TestLogAndSucceed(c *check.C) {
c.Log("Expected success!")
}
@@ -103,7 +103,7 @@ type FixtureHelper struct {
bytes int64
}
-func (s *FixtureHelper) trace(name string, c *gocheck.C) {
+func (s *FixtureHelper) trace(name string, c *check.C) {
s.calls = append(s.calls, name)
if name == s.panicOn {
panic(name)
@@ -116,38 +116,38 @@ func (s *FixtureHelper) trace(name string, c *gocheck.C) {
}
}
-func (s *FixtureHelper) SetUpSuite(c *gocheck.C) {
+func (s *FixtureHelper) SetUpSuite(c *check.C) {
s.trace("SetUpSuite", c)
}
-func (s *FixtureHelper) TearDownSuite(c *gocheck.C) {
+func (s *FixtureHelper) TearDownSuite(c *check.C) {
s.trace("TearDownSuite", c)
}
-func (s *FixtureHelper) SetUpTest(c *gocheck.C) {
+func (s *FixtureHelper) SetUpTest(c *check.C) {
s.trace("SetUpTest", c)
}
-func (s *FixtureHelper) TearDownTest(c *gocheck.C) {
+func (s *FixtureHelper) TearDownTest(c *check.C) {
s.trace("TearDownTest", c)
}
-func (s *FixtureHelper) Test1(c *gocheck.C) {
+func (s *FixtureHelper) Test1(c *check.C) {
s.trace("Test1", c)
}
-func (s *FixtureHelper) Test2(c *gocheck.C) {
+func (s *FixtureHelper) Test2(c *check.C) {
s.trace("Test2", c)
}
-func (s *FixtureHelper) Benchmark1(c *gocheck.C) {
+func (s *FixtureHelper) Benchmark1(c *check.C) {
s.trace("Benchmark1", c)
for i := 0; i < c.N; i++ {
time.Sleep(s.sleep)
}
}
-func (s *FixtureHelper) Benchmark2(c *gocheck.C) {
+func (s *FixtureHelper) Benchmark2(c *check.C) {
s.trace("Benchmark2", c)
c.SetBytes(1024)
for i := 0; i < c.N; i++ {
@@ -170,7 +170,7 @@ type expectedState struct {
// Verify the state of the test. Note that since this also verifies if
// the test is supposed to be in a failed state, no other checks should
// be done in addition to what is being tested.
-func checkState(c *gocheck.C, result interface{}, expected *expectedState) {
+func checkState(c *check.C, result interface{}, expected *expectedState) {
failed := c.Failed()
c.Succeed()
log := c.GetTestLog()
diff --git a/checkers.go b/checkers.go
index 5c91200..bac3387 100644
--- a/checkers.go
+++ b/checkers.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
import (
"fmt"
diff --git a/checkers_test.go b/checkers_test.go
index 0945491..5c69747 100644
--- a/checkers_test.go
+++ b/checkers_test.go
@@ -1,17 +1,17 @@
-package gocheck_test
+package check_test
import (
"errors"
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
"reflect"
"runtime"
)
type CheckersS struct{}
-var _ = gocheck.Suite(&CheckersS{})
+var _ = check.Suite(&CheckersS{})
-func testInfo(c *gocheck.C, checker gocheck.Checker, name string, paramNames []string) {
+func testInfo(c *check.C, checker check.Checker, name string, paramNames []string) {
info := checker.Info()
if info.Name != name {
c.Fatalf("Got name %s, expected %s", info.Name, name)
@@ -21,7 +21,7 @@ func testInfo(c *gocheck.C, checker gocheck.Checker, name string, paramNames []s
}
}
-func testCheck(c *gocheck.C, checker gocheck.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) {
+func testCheck(c *check.C, checker check.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) {
info := checker.Info()
if len(params) != len(info.Params) {
c.Fatalf("unexpected param count in test; expected %d got %d", len(info.Params), len(params))
@@ -35,238 +35,238 @@ func testCheck(c *gocheck.C, checker gocheck.Checker, result bool, error string,
return params, names
}
-func (s *CheckersS) TestComment(c *gocheck.C) {
- bug := gocheck.Commentf("a %d bc", 42)
+func (s *CheckersS) TestComment(c *check.C) {
+ bug := check.Commentf("a %d bc", 42)
comment := bug.CheckCommentString()
if comment != "a 42 bc" {
c.Fatalf("Commentf returned %#v", comment)
}
}
-func (s *CheckersS) TestIsNil(c *gocheck.C) {
- testInfo(c, gocheck.IsNil, "IsNil", []string{"value"})
+func (s *CheckersS) TestIsNil(c *check.C) {
+ testInfo(c, check.IsNil, "IsNil", []string{"value"})
- testCheck(c, gocheck.IsNil, true, "", nil)
- testCheck(c, gocheck.IsNil, false, "", "a")
+ testCheck(c, check.IsNil, true, "", nil)
+ testCheck(c, check.IsNil, false, "", "a")
- testCheck(c, gocheck.IsNil, true, "", (chan int)(nil))
- testCheck(c, gocheck.IsNil, false, "", make(chan int))
- testCheck(c, gocheck.IsNil, true, "", (error)(nil))
- testCheck(c, gocheck.IsNil, false, "", errors.New(""))
- testCheck(c, gocheck.IsNil, true, "", ([]int)(nil))
- testCheck(c, gocheck.IsNil, false, "", make([]int, 1))
- testCheck(c, gocheck.IsNil, false, "", int(0))
+ testCheck(c, check.IsNil, true, "", (chan int)(nil))
+ testCheck(c, check.IsNil, false, "", make(chan int))
+ testCheck(c, check.IsNil, true, "", (error)(nil))
+ testCheck(c, check.IsNil, false, "", errors.New(""))
+ testCheck(c, check.IsNil, true, "", ([]int)(nil))
+ testCheck(c, check.IsNil, false, "", make([]int, 1))
+ testCheck(c, check.IsNil, false, "", int(0))
}
-func (s *CheckersS) TestNotNil(c *gocheck.C) {
- testInfo(c, gocheck.NotNil, "NotNil", []string{"value"})
+func (s *CheckersS) TestNotNil(c *check.C) {
+ testInfo(c, check.NotNil, "NotNil", []string{"value"})
- testCheck(c, gocheck.NotNil, false, "", nil)
- testCheck(c, gocheck.NotNil, true, "", "a")
+ testCheck(c, check.NotNil, false, "", nil)
+ testCheck(c, check.NotNil, true, "", "a")
- testCheck(c, gocheck.NotNil, false, "", (chan int)(nil))
- testCheck(c, gocheck.NotNil, true, "", make(chan int))
- testCheck(c, gocheck.NotNil, false, "", (error)(nil))
- testCheck(c, gocheck.NotNil, true, "", errors.New(""))
- testCheck(c, gocheck.NotNil, false, "", ([]int)(nil))
- testCheck(c, gocheck.NotNil, true, "", make([]int, 1))
+ testCheck(c, check.NotNil, false, "", (chan int)(nil))
+ testCheck(c, check.NotNil, true, "", make(chan int))
+ testCheck(c, check.NotNil, false, "", (error)(nil))
+ testCheck(c, check.NotNil, true, "", errors.New(""))
+ testCheck(c, check.NotNil, false, "", ([]int)(nil))
+ testCheck(c, check.NotNil, true, "", make([]int, 1))
}
-func (s *CheckersS) TestNot(c *gocheck.C) {
- testInfo(c, gocheck.Not(gocheck.IsNil), "Not(IsNil)", []string{"value"})
+func (s *CheckersS) TestNot(c *check.C) {
+ testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"})
- testCheck(c, gocheck.Not(gocheck.IsNil), false, "", nil)
- testCheck(c, gocheck.Not(gocheck.IsNil), true, "", "a")
+ testCheck(c, check.Not(check.IsNil), false, "", nil)
+ testCheck(c, check.Not(check.IsNil), true, "", "a")
}
type simpleStruct struct {
i int
}
-func (s *CheckersS) TestEquals(c *gocheck.C) {
- testInfo(c, gocheck.Equals, "Equals", []string{"obtained", "expected"})
+func (s *CheckersS) TestEquals(c *check.C) {
+ testInfo(c, check.Equals, "Equals", []string{"obtained", "expected"})
// The simplest.
- testCheck(c, gocheck.Equals, true, "", 42, 42)
- testCheck(c, gocheck.Equals, false, "", 42, 43)
+ testCheck(c, check.Equals, true, "", 42, 42)
+ testCheck(c, check.Equals, false, "", 42, 43)
// Different native types.
- testCheck(c, gocheck.Equals, false, "", int32(42), int64(42))
+ testCheck(c, check.Equals, false, "", int32(42), int64(42))
// With nil.
- testCheck(c, gocheck.Equals, false, "", 42, nil)
+ testCheck(c, check.Equals, false, "", 42, nil)
// Slices
- testCheck(c, gocheck.Equals, false, "runtime error: comparing uncomparable type []uint8", []byte{1, 2}, []byte{1, 2})
+ testCheck(c, check.Equals, false, "runtime error: comparing uncomparable type []uint8", []byte{1, 2}, []byte{1, 2})
// Struct values
- testCheck(c, gocheck.Equals, true, "", simpleStruct{1}, simpleStruct{1})
- testCheck(c, gocheck.Equals, false, "", simpleStruct{1}, simpleStruct{2})
+ testCheck(c, check.Equals, true, "", simpleStruct{1}, simpleStruct{1})
+ testCheck(c, check.Equals, false, "", simpleStruct{1}, simpleStruct{2})
// Struct pointers
- testCheck(c, gocheck.Equals, false, "", &simpleStruct{1}, &simpleStruct{1})
- testCheck(c, gocheck.Equals, false, "", &simpleStruct{1}, &simpleStruct{2})
+ testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{1})
+ testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{2})
}
-func (s *CheckersS) TestDeepEquals(c *gocheck.C) {
- testInfo(c, gocheck.DeepEquals, "DeepEquals", []string{"obtained", "expected"})
+func (s *CheckersS) TestDeepEquals(c *check.C) {
+ testInfo(c, check.DeepEquals, "DeepEquals", []string{"obtained", "expected"})
// The simplest.
- testCheck(c, gocheck.DeepEquals, true, "", 42, 42)
- testCheck(c, gocheck.DeepEquals, false, "", 42, 43)
+ testCheck(c, check.DeepEquals, true, "", 42, 42)
+ testCheck(c, check.DeepEquals, false, "", 42, 43)
// Different native types.
- testCheck(c, gocheck.DeepEquals, false, "", int32(42), int64(42))
+ testCheck(c, check.DeepEquals, false, "", int32(42), int64(42))
// With nil.
- testCheck(c, gocheck.DeepEquals, false, "", 42, nil)
+ testCheck(c, check.DeepEquals, false, "", 42, nil)
// Slices
- testCheck(c, gocheck.DeepEquals, true, "", []byte{1, 2}, []byte{1, 2})
- testCheck(c, gocheck.DeepEquals, false, "", []byte{1, 2}, []byte{1, 3})
+ testCheck(c, check.DeepEquals, true, "", []byte{1, 2}, []byte{1, 2})
+ testCheck(c, check.DeepEquals, false, "", []byte{1, 2}, []byte{1, 3})
// Struct values
- testCheck(c, gocheck.DeepEquals, true, "", simpleStruct{1}, simpleStruct{1})
- testCheck(c, gocheck.DeepEquals, false, "", simpleStruct{1}, simpleStruct{2})
+ testCheck(c, check.DeepEquals, true, "", simpleStruct{1}, simpleStruct{1})
+ testCheck(c, check.DeepEquals, false, "", simpleStruct{1}, simpleStruct{2})
// Struct pointers
- testCheck(c, gocheck.DeepEquals, true, "", &simpleStruct{1}, &simpleStruct{1})
- testCheck(c, gocheck.DeepEquals, false, "", &simpleStruct{1}, &simpleStruct{2})
+ testCheck(c, check.DeepEquals, true, "", &simpleStruct{1}, &simpleStruct{1})
+ testCheck(c, check.DeepEquals, false, "", &simpleStruct{1}, &simpleStruct{2})
}
-func (s *CheckersS) TestHasLen(c *gocheck.C) {
- testInfo(c, gocheck.HasLen, "HasLen", []string{"obtained", "n"})
+func (s *CheckersS) TestHasLen(c *check.C) {
+ testInfo(c, check.HasLen, "HasLen", []string{"obtained", "n"})
- testCheck(c, gocheck.HasLen, true, "", "abcd", 4)
- testCheck(c, gocheck.HasLen, true, "", []int{1, 2}, 2)
- testCheck(c, gocheck.HasLen, false, "", []int{1, 2}, 3)
+ testCheck(c, check.HasLen, true, "", "abcd", 4)
+ testCheck(c, check.HasLen, true, "", []int{1, 2}, 2)
+ testCheck(c, check.HasLen, false, "", []int{1, 2}, 3)
- testCheck(c, gocheck.HasLen, false, "n must be an int", []int{1, 2}, "2")
- testCheck(c, gocheck.HasLen, false, "obtained value type has no length", nil, 2)
+ testCheck(c, check.HasLen, false, "n must be an int", []int{1, 2}, "2")
+ testCheck(c, check.HasLen, false, "obtained value type has no length", nil, 2)
}
-func (s *CheckersS) TestErrorMatches(c *gocheck.C) {
- testInfo(c, gocheck.ErrorMatches, "ErrorMatches", []string{"value", "regex"})
+func (s *CheckersS) TestErrorMatches(c *check.C) {
+ testInfo(c, check.ErrorMatches, "ErrorMatches", []string{"value", "regex"})
- testCheck(c, gocheck.ErrorMatches, false, "Error value is nil", nil, "some error")
- testCheck(c, gocheck.ErrorMatches, false, "Value is not an error", 1, "some error")
- testCheck(c, gocheck.ErrorMatches, true, "", errors.New("some error"), "some error")
- testCheck(c, gocheck.ErrorMatches, true, "", errors.New("some error"), "so.*or")
+ testCheck(c, check.ErrorMatches, false, "Error value is nil", nil, "some error")
+ testCheck(c, check.ErrorMatches, false, "Value is not an error", 1, "some error")
+ testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "some error")
+ testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "so.*or")
// Verify params mutation
- params, names := testCheck(c, gocheck.ErrorMatches, false, "", errors.New("some error"), "other error")
- c.Assert(params[0], gocheck.Equals, "some error")
- c.Assert(names[0], gocheck.Equals, "error")
+ params, names := testCheck(c, check.ErrorMatches, false, "", errors.New("some error"), "other error")
+ c.Assert(params[0], check.Equals, "some error")
+ c.Assert(names[0], check.Equals, "error")
}
-func (s *CheckersS) TestMatches(c *gocheck.C) {
- testInfo(c, gocheck.Matches, "Matches", []string{"value", "regex"})
+func (s *CheckersS) TestMatches(c *check.C) {
+ testInfo(c, check.Matches, "Matches", []string{"value", "regex"})
// Simple matching
- testCheck(c, gocheck.Matches, true, "", "abc", "abc")
- testCheck(c, gocheck.Matches, true, "", "abc", "a.c")
+ testCheck(c, check.Matches, true, "", "abc", "abc")
+ testCheck(c, check.Matches, true, "", "abc", "a.c")
// Must match fully
- testCheck(c, gocheck.Matches, false, "", "abc", "ab")
- testCheck(c, gocheck.Matches, false, "", "abc", "bc")
+ testCheck(c, check.Matches, false, "", "abc", "ab")
+ testCheck(c, check.Matches, false, "", "abc", "bc")
// String()-enabled values accepted
- testCheck(c, gocheck.Matches, true, "", reflect.ValueOf("abc"), "a.c")
- testCheck(c, gocheck.Matches, false, "", reflect.ValueOf("abc"), "a.d")
+ testCheck(c, check.Matches, true, "", reflect.ValueOf("abc"), "a.c")
+ testCheck(c, check.Matches, false, "", reflect.ValueOf("abc"), "a.d")
// Some error conditions.
- testCheck(c, gocheck.Matches, false, "Obtained value is not a string and has no .String()", 1, "a.c")
- testCheck(c, gocheck.Matches, false, "Can't compile regex: error parsing regexp: missing closing ]: `[c$`", "abc", "a[c")
+ testCheck(c, check.Matches, false, "Obtained value is not a string and has no .String()", 1, "a.c")
+ testCheck(c, check.Matches, false, "Can't compile regex: error parsing regexp: missing closing ]: `[c$`", "abc", "a[c")
}
-func (s *CheckersS) TestPanics(c *gocheck.C) {
- testInfo(c, gocheck.Panics, "Panics", []string{"function", "expected"})
+func (s *CheckersS) TestPanics(c *check.C) {
+ testInfo(c, check.Panics, "Panics", []string{"function", "expected"})
// Some errors.
- testCheck(c, gocheck.Panics, false, "Function has not panicked", func() bool { return false }, "BOOM")
- testCheck(c, gocheck.Panics, false, "Function must take zero arguments", 1, "BOOM")
+ testCheck(c, check.Panics, false, "Function has not panicked", func() bool { return false }, "BOOM")
+ testCheck(c, check.Panics, false, "Function must take zero arguments", 1, "BOOM")
// Plain strings.
- testCheck(c, gocheck.Panics, true, "", func() { panic("BOOM") }, "BOOM")
- testCheck(c, gocheck.Panics, false, "", func() { panic("KABOOM") }, "BOOM")
- testCheck(c, gocheck.Panics, true, "", func() bool { panic("BOOM") }, "BOOM")
+ testCheck(c, check.Panics, true, "", func() { panic("BOOM") }, "BOOM")
+ testCheck(c, check.Panics, false, "", func() { panic("KABOOM") }, "BOOM")
+ testCheck(c, check.Panics, true, "", func() bool { panic("BOOM") }, "BOOM")
// Error values.
- testCheck(c, gocheck.Panics, true, "", func() { panic(errors.New("BOOM")) }, errors.New("BOOM"))
- testCheck(c, gocheck.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
+ testCheck(c, check.Panics, true, "", func() { panic(errors.New("BOOM")) }, errors.New("BOOM"))
+ testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
type deep struct{ i int }
// Deep value
- testCheck(c, gocheck.Panics, true, "", func() { panic(&deep{99}) }, &deep{99})
+ testCheck(c, check.Panics, true, "", func() { panic(&deep{99}) }, &deep{99})
// Verify params/names mutation
- params, names := testCheck(c, gocheck.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
- c.Assert(params[0], gocheck.ErrorMatches, "KABOOM")
- c.Assert(names[0], gocheck.Equals, "panic")
+ params, names := testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
+ c.Assert(params[0], check.ErrorMatches, "KABOOM")
+ c.Assert(names[0], check.Equals, "panic")
// Verify a nil panic
- testCheck(c, gocheck.Panics, true, "", func() { panic(nil) }, nil)
- testCheck(c, gocheck.Panics, false, "", func() { panic(nil) }, "NOPE")
+ testCheck(c, check.Panics, true, "", func() { panic(nil) }, nil)
+ testCheck(c, check.Panics, false, "", func() { panic(nil) }, "NOPE")
}
-func (s *CheckersS) TestPanicMatches(c *gocheck.C) {
- testInfo(c, gocheck.PanicMatches, "PanicMatches", []string{"function", "expected"})
+func (s *CheckersS) TestPanicMatches(c *check.C) {
+ testInfo(c, check.PanicMatches, "PanicMatches", []string{"function", "expected"})
// Error matching.
- testCheck(c, gocheck.PanicMatches, true, "", func() { panic(errors.New("BOOM")) }, "BO.M")
- testCheck(c, gocheck.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BO.M")
+ testCheck(c, check.PanicMatches, true, "", func() { panic(errors.New("BOOM")) }, "BO.M")
+ testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BO.M")
// Some errors.
- testCheck(c, gocheck.PanicMatches, false, "Function has not panicked", func() bool { return false }, "BOOM")
- testCheck(c, gocheck.PanicMatches, false, "Function must take zero arguments", 1, "BOOM")
+ testCheck(c, check.PanicMatches, false, "Function has not panicked", func() bool { return false }, "BOOM")
+ testCheck(c, check.PanicMatches, false, "Function must take zero arguments", 1, "BOOM")
// Plain strings.
- testCheck(c, gocheck.PanicMatches, true, "", func() { panic("BOOM") }, "BO.M")
- testCheck(c, gocheck.PanicMatches, false, "", func() { panic("KABOOM") }, "BOOM")
- testCheck(c, gocheck.PanicMatches, true, "", func() bool { panic("BOOM") }, "BO.M")
+ testCheck(c, check.PanicMatches, true, "", func() { panic("BOOM") }, "BO.M")
+ testCheck(c, check.PanicMatches, false, "", func() { panic("KABOOM") }, "BOOM")
+ testCheck(c, check.PanicMatches, true, "", func() bool { panic("BOOM") }, "BO.M")
// Verify params/names mutation
- params, names := testCheck(c, gocheck.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BOOM")
- c.Assert(params[0], gocheck.Equals, "KABOOM")
- c.Assert(names[0], gocheck.Equals, "panic")
+ params, names := testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BOOM")
+ c.Assert(params[0], check.Equals, "KABOOM")
+ c.Assert(names[0], check.Equals, "panic")
// Verify a nil panic
- testCheck(c, gocheck.PanicMatches, false, "Panic value is not a string or an error", func() { panic(nil) }, "")
+ testCheck(c, check.PanicMatches, false, "Panic value is not a string or an error", func() { panic(nil) }, "")
}
-func (s *CheckersS) TestFitsTypeOf(c *gocheck.C) {
- testInfo(c, gocheck.FitsTypeOf, "FitsTypeOf", []string{"obtained", "sample"})
+func (s *CheckersS) TestFitsTypeOf(c *check.C) {
+ testInfo(c, check.FitsTypeOf, "FitsTypeOf", []string{"obtained", "sample"})
// Basic types
- testCheck(c, gocheck.FitsTypeOf, true, "", 1, 0)
- testCheck(c, gocheck.FitsTypeOf, false, "", 1, int64(0))
+ testCheck(c, check.FitsTypeOf, true, "", 1, 0)
+ testCheck(c, check.FitsTypeOf, false, "", 1, int64(0))
// Aliases
- testCheck(c, gocheck.FitsTypeOf, false, "", 1, errors.New(""))
- testCheck(c, gocheck.FitsTypeOf, false, "", "error", errors.New(""))
- testCheck(c, gocheck.FitsTypeOf, true, "", errors.New("error"), errors.New(""))
+ testCheck(c, check.FitsTypeOf, false, "", 1, errors.New(""))
+ testCheck(c, check.FitsTypeOf, false, "", "error", errors.New(""))
+ testCheck(c, check.FitsTypeOf, true, "", errors.New("error"), errors.New(""))
// Structures
- testCheck(c, gocheck.FitsTypeOf, false, "", 1, simpleStruct{})
- testCheck(c, gocheck.FitsTypeOf, false, "", simpleStruct{42}, &simpleStruct{})
- testCheck(c, gocheck.FitsTypeOf, true, "", simpleStruct{42}, simpleStruct{})
- testCheck(c, gocheck.FitsTypeOf, true, "", &simpleStruct{42}, &simpleStruct{})
+ testCheck(c, check.FitsTypeOf, false, "", 1, simpleStruct{})
+ testCheck(c, check.FitsTypeOf, false, "", simpleStruct{42}, &simpleStruct{})
+ testCheck(c, check.FitsTypeOf, true, "", simpleStruct{42}, simpleStruct{})
+ testCheck(c, check.FitsTypeOf, true, "", &simpleStruct{42}, &simpleStruct{})
// Some bad values
- testCheck(c, gocheck.FitsTypeOf, false, "Invalid sample value", 1, interface{}(nil))
- testCheck(c, gocheck.FitsTypeOf, false, "", interface{}(nil), 0)
+ testCheck(c, check.FitsTypeOf, false, "Invalid sample value", 1, interface{}(nil))
+ testCheck(c, check.FitsTypeOf, false, "", interface{}(nil), 0)
}
-func (s *CheckersS) TestImplements(c *gocheck.C) {
- testInfo(c, gocheck.Implements, "Implements", []string{"obtained", "ifaceptr"})
+func (s *CheckersS) TestImplements(c *check.C) {
+ testInfo(c, check.Implements, "Implements", []string{"obtained", "ifaceptr"})
var e error
var re runtime.Error
- testCheck(c, gocheck.Implements, true, "", errors.New(""), &e)
- testCheck(c, gocheck.Implements, false, "", errors.New(""), &re)
+ testCheck(c, check.Implements, true, "", errors.New(""), &e)
+ testCheck(c, check.Implements, false, "", errors.New(""), &re)
// Some bad values
- testCheck(c, gocheck.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, errors.New(""))
- testCheck(c, gocheck.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, interface{}(nil))
- testCheck(c, gocheck.Implements, false, "", interface{}(nil), &e)
+ testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, errors.New(""))
+ testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, interface{}(nil))
+ testCheck(c, check.Implements, false, "", interface{}(nil), &e)
}
diff --git a/export_test.go b/export_test.go
index ad29621..0e6cfe0 100644
--- a/export_test.go
+++ b/export_test.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
func PrintLine(filename string, line int) (string, error) {
return printLine(filename, line)
diff --git a/fixture_test.go b/fixture_test.go
index 63f392e..07cf83f 100644
--- a/fixture_test.go
+++ b/fixture_test.go
@@ -1,9 +1,9 @@
// Tests for the behavior of the test fixture system.
-package gocheck_test
+package check_test
import (
- . "launchpad.net/gocheck"
+ . "gopkg.in/check.v1"
)
// -----------------------------------------------------------------------
@@ -52,13 +52,13 @@ func (s *FixtureS) TestPanicOnTest(c *C) {
c.Check(len(helper.calls), Equals, 8)
expected := "^\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: FixtureHelper.Test1\n\n" +
+ "PANIC: check_test\\.go:[0-9]+: FixtureHelper.Test1\n\n" +
"\\.\\.\\. Panic: Test1 \\(PC=[xA-F0-9]+\\)\n\n" +
".+:[0-9]+\n" +
" in panic\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.trace\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.Test1\n$"
c.Check(output.value, Matches, expected)
@@ -75,17 +75,17 @@ func (s *FixtureS) TestPanicOnSetUpTest(c *C) {
c.Check(len(helper.calls), Equals, 4)
expected := "^\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper\\.SetUpTest\n\n" +
"\\.\\.\\. Panic: SetUpTest \\(PC=[xA-F0-9]+\\)\n\n" +
".+:[0-9]+\n" +
" in panic\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.trace\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.SetUpTest\n" +
"\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper\\.Test1\n\n" +
"\\.\\.\\. Panic: Fixture has panicked " +
"\\(see related PANIC\\)\n$"
@@ -105,17 +105,17 @@ func (s *FixtureS) TestPanicOnTearDownTest(c *C) {
c.Check(len(helper.calls), Equals, 5)
expected := "^\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper.TearDownTest\n\n" +
"\\.\\.\\. Panic: TearDownTest \\(PC=[xA-F0-9]+\\)\n\n" +
".+:[0-9]+\n" +
" in panic\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.trace\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.TearDownTest\n" +
"\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper\\.Test1\n\n" +
"\\.\\.\\. Panic: Fixture has panicked " +
"\\(see related PANIC\\)\n$"
@@ -132,14 +132,14 @@ func (s *FixtureS) TestPanicOnSetUpSuite(c *C) {
c.Check(len(helper.calls), Equals, 2)
expected := "^\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper.SetUpSuite\n\n" +
"\\.\\.\\. Panic: SetUpSuite \\(PC=[xA-F0-9]+\\)\n\n" +
".+:[0-9]+\n" +
" in panic\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.trace\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.SetUpSuite\n$"
c.Check(output.value, Matches, expected)
@@ -160,14 +160,14 @@ func (s *FixtureS) TestPanicOnTearDownSuite(c *C) {
c.Check(len(helper.calls), Equals, 8)
expected := "^\n-+\n" +
- "PANIC: gocheck_test\\.go:[0-9]+: " +
+ "PANIC: check_test\\.go:[0-9]+: " +
"FixtureHelper.TearDownSuite\n\n" +
"\\.\\.\\. Panic: TearDownSuite \\(PC=[xA-F0-9]+\\)\n\n" +
".+:[0-9]+\n" +
" in panic\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.trace\n" +
- ".*gocheck_test.go:[0-9]+\n" +
+ ".*check_test.go:[0-9]+\n" +
" in FixtureHelper.TearDownSuite\n$"
c.Check(output.value, Matches, expected)
@@ -193,7 +193,7 @@ func (s *FixtureS) TestPanicOnWrongTestArg(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongTestArgHelper\\.Test1\n\n" +
"\\.\\.\\. Panic: WrongTestArgHelper\\.Test1 argument " +
- "should be \\*gocheck\\.C\n"
+ "should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
@@ -209,7 +209,7 @@ func (s *FixtureS) TestPanicOnWrongSetUpTestArg(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongSetUpTestArgHelper\\.SetUpTest\n\n" +
"\\.\\.\\. Panic: WrongSetUpTestArgHelper\\.SetUpTest argument " +
- "should be \\*gocheck\\.C\n"
+ "should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
@@ -225,7 +225,7 @@ func (s *FixtureS) TestPanicOnWrongSetUpSuiteArg(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongSetUpSuiteArgHelper\\.SetUpSuite\n\n" +
"\\.\\.\\. Panic: WrongSetUpSuiteArgHelper\\.SetUpSuite argument " +
- "should be \\*gocheck\\.C\n"
+ "should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
@@ -250,7 +250,7 @@ func (s *FixtureS) TestPanicOnWrongTestArgCount(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongTestArgCountHelper\\.Test1\n\n" +
"\\.\\.\\. Panic: WrongTestArgCountHelper\\.Test1 argument " +
- "should be \\*gocheck\\.C\n"
+ "should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
@@ -266,7 +266,7 @@ func (s *FixtureS) TestPanicOnWrongSetUpTestArgCount(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongSetUpTestArgCountHelper\\.SetUpTest\n\n" +
"\\.\\.\\. Panic: WrongSetUpTestArgCountHelper\\.SetUpTest argument " +
- "should be \\*gocheck\\.C\n"
+ "should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
@@ -282,7 +282,7 @@ func (s *FixtureS) TestPanicOnWrongSetUpSuiteArgCount(c *C) {
"PANIC: fixture_test\\.go:[0-9]+: " +
"WrongSetUpSuiteArgCountHelper\\.SetUpSuite\n\n" +
"\\.\\.\\. Panic: WrongSetUpSuiteArgCountHelper" +
- "\\.SetUpSuite argument should be \\*gocheck\\.C\n"
+ "\\.SetUpSuite argument should be \\*check\\.C\n"
c.Check(output.value, Matches, expected)
}
diff --git a/foundation_test.go b/foundation_test.go
index 12dfd36..8ecf791 100644
--- a/foundation_test.go
+++ b/foundation_test.go
@@ -4,11 +4,11 @@
// still have to be taken when using external functions, since they should
// of course not rely on functionality tested here.
-package gocheck_test
+package check_test
import (
"fmt"
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
"log"
"os"
"regexp"
@@ -20,13 +20,13 @@ import (
type FoundationS struct{}
-var foundationS = gocheck.Suite(&FoundationS{})
+var foundationS = check.Suite(&FoundationS{})
-func (s *FoundationS) TestCountSuite(c *gocheck.C) {
+func (s *FoundationS) TestCountSuite(c *check.C) {
suitesRun += 1
}
-func (s *FoundationS) TestErrorf(c *gocheck.C) {
+func (s *FoundationS) TestErrorf(c *check.C) {
// Do not use checkState() here. It depends on Errorf() working.
expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
" c.Errorf(\"Error %%v!\", \"message\")\n"+
@@ -45,7 +45,7 @@ func (s *FoundationS) TestErrorf(c *gocheck.C) {
}
}
-func (s *FoundationS) TestError(c *gocheck.C) {
+func (s *FoundationS) TestError(c *check.C) {
expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
" c\\.Error\\(\"Error \", \"message!\"\\)\n"+
"\\.\\.\\. Error: Error message!\n\n",
@@ -59,7 +59,7 @@ func (s *FoundationS) TestError(c *gocheck.C) {
})
}
-func (s *FoundationS) TestFailNow(c *gocheck.C) {
+func (s *FoundationS) TestFailNow(c *check.C) {
defer (func() {
if !c.Failed() {
c.Error("FailNow() didn't fail the test")
@@ -75,7 +75,7 @@ func (s *FoundationS) TestFailNow(c *gocheck.C) {
c.Log("FailNow() didn't stop the test")
}
-func (s *FoundationS) TestSucceedNow(c *gocheck.C) {
+func (s *FoundationS) TestSucceedNow(c *check.C) {
defer (func() {
if c.Failed() {
c.Error("SucceedNow() didn't succeed the test")
@@ -90,14 +90,14 @@ func (s *FoundationS) TestSucceedNow(c *gocheck.C) {
c.Log("SucceedNow() didn't stop the test")
}
-func (s *FoundationS) TestFailureHeader(c *gocheck.C) {
+func (s *FoundationS) TestFailureHeader(c *check.C) {
output := String{}
failHelper := FailHelper{}
- gocheck.Run(&failHelper, &gocheck.RunConf{Output: &output})
+ check.Run(&failHelper, &check.RunConf{Output: &output})
header := fmt.Sprintf(""+
"\n-----------------------------------"+
"-----------------------------------\n"+
- "FAIL: gocheck_test.go:%d: FailHelper.TestLogAndFail\n",
+ "FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n",
failHelper.testLine)
if strings.Index(output.value, header) == -1 {
c.Errorf(""+
@@ -107,7 +107,7 @@ func (s *FoundationS) TestFailureHeader(c *gocheck.C) {
}
}
-func (s *FoundationS) TestFatal(c *gocheck.C) {
+func (s *FoundationS) TestFatal(c *check.C) {
var line int
defer (func() {
if !c.Failed() {
@@ -129,7 +129,7 @@ func (s *FoundationS) TestFatal(c *gocheck.C) {
c.Log("Fatal() didn't stop the test")
}
-func (s *FoundationS) TestFatalf(c *gocheck.C) {
+func (s *FoundationS) TestFatalf(c *check.C) {
var line int
defer (func() {
if !c.Failed() {
@@ -151,14 +151,14 @@ func (s *FoundationS) TestFatalf(c *gocheck.C) {
c.Log("Fatalf() didn't stop the test")
}
-func (s *FoundationS) TestCallerLoggingInsideTest(c *gocheck.C) {
+func (s *FoundationS) TestCallerLoggingInsideTest(c *check.C) {
log := fmt.Sprintf(""+
"foundation_test.go:%d:\n"+
- " result := c.Check\\(10, gocheck.Equals, 20\\)\n"+
+ " result := c.Check\\(10, check.Equals, 20\\)\n"+
"\\.\\.\\. obtained int = 10\n"+
"\\.\\.\\. expected int = 20\n\n",
getMyLine()+1)
- result := c.Check(10, gocheck.Equals, 20)
+ result := c.Check(10, check.Equals, 20)
checkState(c, result,
&expectedState{
name: "Check(10, Equals, 20)",
@@ -168,14 +168,14 @@ func (s *FoundationS) TestCallerLoggingInsideTest(c *gocheck.C) {
})
}
-func (s *FoundationS) TestCallerLoggingInDifferentFile(c *gocheck.C) {
+func (s *FoundationS) TestCallerLoggingInDifferentFile(c *check.C) {
result, line := checkEqualWrapper(c, 10, 20)
testLine := getMyLine() - 1
log := fmt.Sprintf(""+
"foundation_test.go:%d:\n"+
" result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+
- "gocheck_test.go:%d:\n"+
- " return c.Check\\(obtained, gocheck.Equals, expected\\), getMyLine\\(\\)\n"+
+ "check_test.go:%d:\n"+
+ " return c.Check\\(obtained, check.Equals, expected\\), getMyLine\\(\\)\n"+
"\\.\\.\\. obtained int = 10\n"+
"\\.\\.\\. expected int = 20\n\n",
testLine, line)
@@ -193,21 +193,21 @@ func (s *FoundationS) TestCallerLoggingInDifferentFile(c *gocheck.C) {
type ExpectFailureSucceedHelper struct{}
-func (s *ExpectFailureSucceedHelper) TestSucceed(c *gocheck.C) {
+func (s *ExpectFailureSucceedHelper) TestSucceed(c *check.C) {
c.ExpectFailure("It booms!")
c.Error("Boom!")
}
type ExpectFailureFailHelper struct{}
-func (s *ExpectFailureFailHelper) TestFail(c *gocheck.C) {
+func (s *ExpectFailureFailHelper) TestFail(c *check.C) {
c.ExpectFailure("Bug #XYZ")
}
-func (s *FoundationS) TestExpectFailureFail(c *gocheck.C) {
+func (s *FoundationS) TestExpectFailureFail(c *check.C) {
helper := ExpectFailureFailHelper{}
output := String{}
- result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
+ result := check.Run(&helper, &check.RunConf{Output: &output})
expected := "" +
"^\n-+\n" +
@@ -223,22 +223,22 @@ func (s *FoundationS) TestExpectFailureFail(c *gocheck.C) {
c.Error("ExpectFailure() didn't log properly:\n", output.value)
}
- c.Assert(result.ExpectedFailures, gocheck.Equals, 0)
+ c.Assert(result.ExpectedFailures, check.Equals, 0)
}
-func (s *FoundationS) TestExpectFailureSucceed(c *gocheck.C) {
+func (s *FoundationS) TestExpectFailureSucceed(c *check.C) {
helper := ExpectFailureSucceedHelper{}
output := String{}
- result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
+ result := check.Run(&helper, &check.RunConf{Output: &output})
- c.Assert(output.value, gocheck.Equals, "")
- c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
+ c.Assert(output.value, check.Equals, "")
+ c.Assert(result.ExpectedFailures, check.Equals, 1)
}
-func (s *FoundationS) TestExpectFailureSucceedVerbose(c *gocheck.C) {
+func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) {
helper := ExpectFailureSucceedHelper{}
output := String{}
- result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})
+ result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})
expected := "" +
"FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
@@ -251,7 +251,7 @@ func (s *FoundationS) TestExpectFailureSucceedVerbose(c *gocheck.C) {
c.Error("ExpectFailure() didn't log properly:\n", output.value)
}
- c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
+ c.Assert(result.ExpectedFailures, check.Equals, 1)
}
// -----------------------------------------------------------------------
@@ -259,25 +259,25 @@ func (s *FoundationS) TestExpectFailureSucceedVerbose(c *gocheck.C) {
type SkipTestHelper struct{}
-func (s *SkipTestHelper) TestFail(c *gocheck.C) {
+func (s *SkipTestHelper) TestFail(c *check.C) {
c.Skip("Wrong platform or whatever")
c.Error("Boom!")
}
-func (s *FoundationS) TestSkip(c *gocheck.C) {
+func (s *FoundationS) TestSkip(c *check.C) {
helper := SkipTestHelper{}
output := String{}
- gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
+ check.Run(&helper, &check.RunConf{Output: &output})
if output.value != "" {
c.Error("Skip() logged something:\n", output.value)
}
}
-func (s *FoundationS) TestSkipVerbose(c *gocheck.C) {
+func (s *FoundationS) TestSkipVerbose(c *check.C) {
helper := SkipTestHelper{}
output := String{}
- gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})
+ check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})
expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
" \\(Wrong platform or whatever\\)"
@@ -290,20 +290,20 @@ func (s *FoundationS) TestSkipVerbose(c *gocheck.C) {
}
// -----------------------------------------------------------------------
-// Check minimum *log.Logger interface provided by *gocheck.C.
+// Check minimum *log.Logger interface provided by *check.C.
type minLogger interface {
Output(calldepth int, s string) error
}
-func (s *BootstrapS) TestMinLogger(c *gocheck.C) {
+func (s *BootstrapS) TestMinLogger(c *check.C) {
var logger minLogger
logger = log.New(os.Stderr, "", 0)
logger = c
logger.Output(0, "Hello there")
expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n`
output := c.GetTestLog()
- c.Assert(output, gocheck.Matches, expected)
+ c.Assert(output, check.Matches, expected)
}
// -----------------------------------------------------------------------
@@ -318,18 +318,18 @@ type EmbeddedS struct {
EmbeddedInternalS
}
-var embeddedS = gocheck.Suite(&EmbeddedS{})
+var embeddedS = check.Suite(&EmbeddedS{})
-func (s *EmbeddedS) TestCountSuite(c *gocheck.C) {
+func (s *EmbeddedS) TestCountSuite(c *check.C) {
suitesRun += 1
}
-func (s *EmbeddedInternalS) TestMethod(c *gocheck.C) {
+func (s *EmbeddedInternalS) TestMethod(c *check.C) {
c.Error("TestMethod() of the embedded type was called!?")
}
-func (s *EmbeddedS) TestMethod(c *gocheck.C) {
+func (s *EmbeddedS) TestMethod(c *check.C) {
// http://code.google.com/p/go/issues/detail?id=906
- c.Check(s.called, gocheck.Equals, false) // Go issue 906 is affecting the runner?
+ c.Check(s.called, check.Equals, false) // Go issue 906 is affecting the runner?
s.called = true
}
diff --git a/helpers.go b/helpers.go
index 5b8b3fd..5576d47 100644
--- a/helpers.go
+++ b/helpers.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
import (
"fmt"
diff --git a/helpers_test.go b/helpers_test.go
index fb9ef8e..0c81d6d 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -1,21 +1,21 @@
// These tests verify the inner workings of the helper methods associated
-// with gocheck.T.
+// with check.T.
-package gocheck_test
+package check_test
import (
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
"os"
"reflect"
"runtime"
"sync"
)
-var helpersS = gocheck.Suite(&HelpersS{})
+var helpersS = check.Suite(&HelpersS{})
type HelpersS struct{}
-func (s *HelpersS) TestCountSuite(c *gocheck.C) {
+func (s *HelpersS) TestCountSuite(c *check.C) {
suitesRun += 1
}
@@ -23,16 +23,16 @@ func (s *HelpersS) TestCountSuite(c *gocheck.C) {
// Fake checker and bug info to verify the behavior of Assert() and Check().
type MyChecker struct {
- info *gocheck.CheckerInfo
+ info *check.CheckerInfo
params []interface{}
names []string
result bool
error string
}
-func (checker *MyChecker) Info() *gocheck.CheckerInfo {
+func (checker *MyChecker) Info() *check.CheckerInfo {
if checker.info == nil {
- return &gocheck.CheckerInfo{Name: "MyChecker", Params: []string{"myobtained", "myexpected"}}
+ return &check.CheckerInfo{Name: "MyChecker", Params: []string{"myobtained", "myexpected"}}
}
return checker.info
}
@@ -64,16 +64,16 @@ func myComment(s string) myCommentType {
// -----------------------------------------------------------------------
// Ensure a real checker actually works fine.
-func (s *HelpersS) TestCheckerInterface(c *gocheck.C) {
+func (s *HelpersS) TestCheckerInterface(c *check.C) {
testHelperSuccess(c, "Check(1, Equals, 1)", true, func() interface{} {
- return c.Check(1, gocheck.Equals, 1)
+ return c.Check(1, check.Equals, 1)
})
}
// -----------------------------------------------------------------------
// Tests for Check(), mostly the same as for Assert() following these.
-func (s *HelpersS) TestCheckSucceedWithExpected(c *gocheck.C) {
+func (s *HelpersS) TestCheckSucceedWithExpected(c *check.C) {
checker := &MyChecker{result: true}
testHelperSuccess(c, "Check(1, checker, 2)", true, func() interface{} {
return c.Check(1, checker, 2)
@@ -83,8 +83,8 @@ func (s *HelpersS) TestCheckSucceedWithExpected(c *gocheck.C) {
}
}
-func (s *HelpersS) TestCheckSucceedWithoutExpected(c *gocheck.C) {
- checker := &MyChecker{result: true, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestCheckSucceedWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
testHelperSuccess(c, "Check(1, checker)", true, func() interface{} {
return c.Check(1, checker)
})
@@ -93,7 +93,7 @@ func (s *HelpersS) TestCheckSucceedWithoutExpected(c *gocheck.C) {
}
}
-func (s *HelpersS) TestCheckFailWithExpected(c *gocheck.C) {
+func (s *HelpersS) TestCheckFailWithExpected(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, 2\\)\n" +
@@ -105,7 +105,7 @@ func (s *HelpersS) TestCheckFailWithExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *gocheck.C) {
+func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" +
@@ -118,7 +118,7 @@ func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *gocheck.C) {
+func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" // Nice leading comment\\.\n" +
@@ -132,8 +132,8 @@ func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckFailWithoutExpected(c *gocheck.C) {
- checker := &MyChecker{result: false, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestCheckFailWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker\\)\n" +
"\\.+ myvalue int = 1\n\n"
@@ -143,8 +143,8 @@ func (s *HelpersS) TestCheckFailWithoutExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *gocheck.C) {
- checker := &MyChecker{result: false, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" +
"\\.+ myvalue int = 1\n" +
@@ -155,7 +155,7 @@ func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckWithMissingExpected(c *gocheck.C) {
+func (s *HelpersS) TestCheckWithMissingExpected(c *check.C) {
checker := &MyChecker{result: true}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker\\)\n" +
@@ -168,7 +168,7 @@ func (s *HelpersS) TestCheckWithMissingExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckWithTooManyExpected(c *gocheck.C) {
+func (s *HelpersS) TestCheckWithTooManyExpected(c *check.C) {
checker := &MyChecker{result: true}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, 2, 3\\)\n" +
@@ -181,7 +181,7 @@ func (s *HelpersS) TestCheckWithTooManyExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckWithError(c *gocheck.C) {
+func (s *HelpersS) TestCheckWithError(c *check.C) {
checker := &MyChecker{result: false, error: "Some not so cool data provided!"}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, 2\\)\n" +
@@ -194,7 +194,7 @@ func (s *HelpersS) TestCheckWithError(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckWithNilChecker(c *gocheck.C) {
+func (s *HelpersS) TestCheckWithNilChecker(c *check.C) {
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, nil\\)\n" +
"\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
@@ -205,7 +205,7 @@ func (s *HelpersS) TestCheckWithNilChecker(c *gocheck.C) {
})
}
-func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *gocheck.C) {
+func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *check.C) {
checker := &MyChecker{result: false, params: []interface{}{3, 4}, names: []string{"newobtained", "newexpected"}}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, checker, 2\\)\n" +
@@ -220,7 +220,7 @@ func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *gocheck.C) {
// -----------------------------------------------------------------------
// Tests for Assert(), mostly the same as for Check() above.
-func (s *HelpersS) TestAssertSucceedWithExpected(c *gocheck.C) {
+func (s *HelpersS) TestAssertSucceedWithExpected(c *check.C) {
checker := &MyChecker{result: true}
testHelperSuccess(c, "Assert(1, checker, 2)", nil, func() interface{} {
c.Assert(1, checker, 2)
@@ -231,8 +231,8 @@ func (s *HelpersS) TestAssertSucceedWithExpected(c *gocheck.C) {
}
}
-func (s *HelpersS) TestAssertSucceedWithoutExpected(c *gocheck.C) {
- checker := &MyChecker{result: true, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestAssertSucceedWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
testHelperSuccess(c, "Assert(1, checker)", nil, func() interface{} {
c.Assert(1, checker)
return nil
@@ -242,7 +242,7 @@ func (s *HelpersS) TestAssertSucceedWithoutExpected(c *gocheck.C) {
}
}
-func (s *HelpersS) TestAssertFailWithExpected(c *gocheck.C) {
+func (s *HelpersS) TestAssertFailWithExpected(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker, 2\\)\n" +
@@ -255,7 +255,7 @@ func (s *HelpersS) TestAssertFailWithExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *gocheck.C) {
+func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" +
@@ -269,8 +269,8 @@ func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertFailWithoutExpected(c *gocheck.C) {
- checker := &MyChecker{result: false, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestAssertFailWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker\\)\n" +
"\\.+ myvalue int = 1\n\n"
@@ -281,8 +281,8 @@ func (s *HelpersS) TestAssertFailWithoutExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *gocheck.C) {
- checker := &MyChecker{result: false, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
+func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" +
"\\.+ myvalue int = 1\n" +
@@ -294,7 +294,7 @@ func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertWithMissingExpected(c *gocheck.C) {
+func (s *HelpersS) TestAssertWithMissingExpected(c *check.C) {
checker := &MyChecker{result: true}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker\\)\n" +
@@ -308,7 +308,7 @@ func (s *HelpersS) TestAssertWithMissingExpected(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertWithError(c *gocheck.C) {
+func (s *HelpersS) TestAssertWithError(c *check.C) {
checker := &MyChecker{result: false, error: "Some not so cool data provided!"}
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, checker, 2\\)\n" +
@@ -322,7 +322,7 @@ func (s *HelpersS) TestAssertWithError(c *gocheck.C) {
})
}
-func (s *HelpersS) TestAssertWithNilChecker(c *gocheck.C) {
+func (s *HelpersS) TestAssertWithNilChecker(c *check.C) {
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, nil\\)\n" +
"\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
@@ -337,7 +337,7 @@ func (s *HelpersS) TestAssertWithNilChecker(c *gocheck.C) {
// -----------------------------------------------------------------------
// Ensure that values logged work properly in some interesting cases.
-func (s *HelpersS) TestValueLoggingWithArrays(c *gocheck.C) {
+func (s *HelpersS) TestValueLoggingWithArrays(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
" return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" +
@@ -349,7 +349,7 @@ func (s *HelpersS) TestValueLoggingWithArrays(c *gocheck.C) {
})
}
-func (s *HelpersS) TestValueLoggingWithMultiLine(c *gocheck.C) {
+func (s *HelpersS) TestValueLoggingWithMultiLine(c *check.C) {
checker := &MyChecker{result: false}
log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
" return c\\.Check\\(\"a\\\\nb\\\\n\", checker, \"a\\\\nb\\\\nc\"\\)\n" +
@@ -366,7 +366,7 @@ func (s *HelpersS) TestValueLoggingWithMultiLine(c *gocheck.C) {
})
}
-func (s *HelpersS) TestValueLoggingWithMultiLineException(c *gocheck.C) {
+func (s *HelpersS) TestValueLoggingWithMultiLineException(c *check.C) {
// If the newline is at the end of the string, don't log as multi-line.
checker := &MyChecker{result: false}
log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
@@ -393,34 +393,34 @@ type MkDirHelper struct {
isDir4 bool
}
-func (s *MkDirHelper) SetUpSuite(c *gocheck.C) {
+func (s *MkDirHelper) SetUpSuite(c *check.C) {
s.path1 = c.MkDir()
s.isDir1 = isDir(s.path1)
}
-func (s *MkDirHelper) Test(c *gocheck.C) {
+func (s *MkDirHelper) Test(c *check.C) {
s.path2 = c.MkDir()
s.isDir2 = isDir(s.path2)
}
-func (s *MkDirHelper) TearDownSuite(c *gocheck.C) {
+func (s *MkDirHelper) TearDownSuite(c *check.C) {
s.isDir3 = isDir(s.path1)
s.isDir4 = isDir(s.path2)
}
-func (s *HelpersS) TestMkDir(c *gocheck.C) {
+func (s *HelpersS) TestMkDir(c *check.C) {
helper := MkDirHelper{}
output := String{}
- gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
- c.Assert(output.value, gocheck.Equals, "")
- c.Check(helper.isDir1, gocheck.Equals, true)
- c.Check(helper.isDir2, gocheck.Equals, true)
- c.Check(helper.isDir3, gocheck.Equals, true)
- c.Check(helper.isDir4, gocheck.Equals, true)
- c.Check(helper.path1, gocheck.Not(gocheck.Equals),
+ check.Run(&helper, &check.RunConf{Output: &output})
+ c.Assert(output.value, check.Equals, "")
+ c.Check(helper.isDir1, check.Equals, true)
+ c.Check(helper.isDir2, check.Equals, true)
+ c.Check(helper.isDir3, check.Equals, true)
+ c.Check(helper.isDir4, check.Equals, true)
+ c.Check(helper.path1, check.Not(check.Equals),
helper.path2)
- c.Check(isDir(helper.path1), gocheck.Equals, false)
- c.Check(isDir(helper.path2), gocheck.Equals, false)
+ c.Check(isDir(helper.path1), check.Equals, false)
+ c.Check(isDir(helper.path2), check.Equals, false)
}
func isDir(path string) bool {
@@ -432,7 +432,7 @@ func isDir(path string) bool {
// Concurrent logging should not corrupt the underling buffer.
// Use go test -race to detect the race in this test.
-func (s *HelpersS) TestConcurrentLogging(c *gocheck.C) {
+func (s *HelpersS) TestConcurrentLogging(c *check.C) {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU()))
var start, stop sync.WaitGroup
start.Add(1)
@@ -453,7 +453,7 @@ func (s *HelpersS) TestConcurrentLogging(c *gocheck.C) {
// -----------------------------------------------------------------------
// A couple of helper functions to test helper functions. :-)
-func testHelperSuccess(c *gocheck.C, name string, expectedResult interface{}, closure func() interface{}) {
+func testHelperSuccess(c *check.C, name string, expectedResult interface{}, closure func() interface{}) {
var result interface{}
defer (func() {
if err := recover(); err != nil {
@@ -470,7 +470,7 @@ func testHelperSuccess(c *gocheck.C, name string, expectedResult interface{}, cl
result = closure()
}
-func testHelperFailure(c *gocheck.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) {
+func testHelperFailure(c *check.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) {
var result interface{}
defer (func() {
if err := recover(); err != nil {
diff --git a/printer.go b/printer.go
index 103ab14..e0f7557 100644
--- a/printer.go
+++ b/printer.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
import (
"bytes"
diff --git a/printer_test.go b/printer_test.go
index 547a92d..538b2d5 100644
--- a/printer_test.go
+++ b/printer_test.go
@@ -1,7 +1,7 @@
-package gocheck_test
+package check_test
import (
- . "launchpad.net/gocheck"
+ . "gopkg.in/check.v1"
)
var _ = Suite(&PrinterS{})
diff --git a/run.go b/run.go
index 642ca80..2dbd8c3 100644
--- a/run.go
+++ b/run.go
@@ -1,4 +1,4 @@
-package gocheck
+package check
import (
"bufio"
@@ -26,28 +26,40 @@ func Suite(suite interface{}) interface{} {
// Public running interface.
var (
- filterFlag = flag.String("gocheck.f", "", "Regular expression selecting which tests and/or suites to run")
- verboseFlag = flag.Bool("gocheck.v", false, "Verbose mode")
- streamFlag = flag.Bool("gocheck.vv", false, "Super verbose mode (disables output caching)")
- benchFlag = flag.Bool("gocheck.b", false, "Run benchmarks")
- benchTime = flag.Duration("gocheck.btime", 1*time.Second, "approximate run time for each benchmark")
- listFlag = flag.Bool("gocheck.list", false, "List the names of all tests that will be run")
- workFlag = flag.Bool("gocheck.work", false, "Display and do not remove the test working directory")
+ oldFilterFlag = flag.String("gocheck.f", "", "Regular expression selecting which tests and/or suites to run")
+ oldVerboseFlag = flag.Bool("gocheck.v", false, "Verbose mode")
+ oldStreamFlag = flag.Bool("gocheck.vv", false, "Super verbose mode (disables output caching)")
+ oldBenchFlag = flag.Bool("gocheck.b", false, "Run benchmarks")
+ oldBenchTime = flag.Duration("gocheck.btime", 1*time.Second, "approximate run time for each benchmark")
+ oldListFlag = flag.Bool("gocheck.list", false, "List the names of all tests that will be run")
+ oldWorkFlag = flag.Bool("gocheck.work", false, "Display and do not remove the test working directory")
+
+ newFilterFlag = flag.String("check.f", "", "Regular expression selecting which tests and/or suites to run")
+ newVerboseFlag = flag.Bool("check.v", false, "Verbose mode")
+ newStreamFlag = flag.Bool("check.vv", false, "Super verbose mode (disables output caching)")
+ newBenchFlag = flag.Bool("check.b", false, "Run benchmarks")
+ newBenchTime = flag.Duration("check.btime", 1*time.Second, "approximate run time for each benchmark")
+ newListFlag = flag.Bool("check.list", false, "List the names of all tests that will be run")
+ newWorkFlag = flag.Bool("check.work", false, "Display and do not remove the test working directory")
)
// Run all test suites registered with the Suite() function, printing
// results to stdout, and reporting any failures back to the 'testing'
// module.
func TestingT(testingT *testing.T) {
+ benchTime := *newBenchTime
+ if benchTime == 1*time.Second {
+ benchTime = *oldBenchTime
+ }
conf := &RunConf{
- Filter: *filterFlag,
- Verbose: *verboseFlag,
- Stream: *streamFlag,
- Benchmark: *benchFlag,
- BenchmarkTime: *benchTime,
- KeepWorkDir: *workFlag,
- }
- if *listFlag {
+ Filter: *oldFilterFlag + *newFilterFlag,
+ Verbose: *oldVerboseFlag || *newVerboseFlag,
+ Stream: *oldStreamFlag || *newStreamFlag,
+ Benchmark: *oldBenchFlag || *newBenchFlag,
+ BenchmarkTime: benchTime,
+ KeepWorkDir: *oldWorkFlag || *newWorkFlag,
+ }
+ if *oldListFlag || *newListFlag {
w := bufio.NewWriter(os.Stdout)
for _, name := range ListAll(conf) {
fmt.Fprintln(w, name)
diff --git a/run_test.go b/run_test.go
index d59bd1c..f41fffc 100644
--- a/run_test.go
+++ b/run_test.go
@@ -1,10 +1,10 @@
// These tests verify the test running logic.
-package gocheck_test
+package check_test
import (
"errors"
- . "launchpad.net/gocheck"
+ . "gopkg.in/check.v1"
"os"
"sync"
)
@@ -307,8 +307,8 @@ func (s *RunS) TestVerboseMode(c *C) {
runConf := RunConf{Output: &output, Verbose: true}
Run(&helper, &runConf)
- expected := "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Test1\t *[.0-9]+s\n" +
- "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t *[.0-9]+s\n" +
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
c.Assert(output.value, Matches, expected)
}
@@ -320,7 +320,7 @@ func (s *RunS) TestVerboseModeWithFailBeforePass(c *C) {
Run(&helper, &runConf)
expected := "(?s).*PANIC.*\n-+\n" + // Should have an extra line.
- "PASS: gocheck_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
c.Assert(output.value, Matches, expected)
}