Beispiel #1
0
func (s *CheckersS) TestBug(c *gocheck.C) {
	bug := gocheck.Bug("a %d bc", 42)
	info := bug.GetBugInfo()
	if info != "a 42 bc" {
		c.Fatalf("Bug() returned %#v", info)
	}
}
Beispiel #2
0
func (s *HelpersS) TestCheckSucceedWithoutExpected(c *gocheck.C) {
	checker := &MyChecker{noExpectedValue: true}
	testHelperSuccess(c, "Check(1, checker)", true, func() interface{} {
		return c.Check(1, checker)
	})
	if checker.obtained != 1 || checker.expected != nil {
		c.Fatalf("Bad (obtained, expected) values for check (%d, %d)",
			checker.obtained, checker.expected)
	}
}
Beispiel #3
0
func (s *HelpersS) TestAssertSucceedWithExpected(c *gocheck.C) {
	checker := &MyChecker{}
	testHelperSuccess(c, "Assert(1, checker, 2)", nil, func() interface{} {
		c.Assert(1, checker, 2)
		return nil
	})
	if checker.obtained != 1 || checker.expected != 2 {
		c.Fatalf("Bad (obtained, expected) values for check (%d, %d)",
			checker.obtained, checker.expected)
	}
}
Beispiel #4
0
func testCheck(c *gocheck.C, checker gocheck.Checker,
	obtained, expected interface{},
	wantedResult bool, wantedError string) {
	result, error := checker.Check(obtained, expected)
	if result != wantedResult || error != wantedError {
		c.Fatalf("%s.Check(%#v, %#v) returned "+
			"(%#v, %#v) rather than (%#v, %#v)",
			checker.Name(), obtained, expected,
			result, error, wantedResult, wantedError)
	}
}
Beispiel #5
0
func testInfo(c *gocheck.C, checker gocheck.Checker,
	name, obtainedVarName, expectedVarName string) {
	if checker.Name() != name {
		c.Fatalf("Got name %s, expected %s", checker.Name(), name)
	}
	obtainedName, expectedName := checker.VarNames()
	if obtainedName != obtainedVarName {
		c.Fatalf("Got obtained label %#v, expected %#v",
			obtainedName, obtainedVarName)
	}
	if expectedName != expectedVarName {
		c.Fatalf("Got expected label %#v, expected %#v",
			expectedName, expectedVarName)
	}
}