Example #1
0
func (s *HelpersS) TestAssertWithNilChecker(c *gocheck.C) {
	log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
		"\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
		"\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
	testHelperFailure(c, "Assert(obtained, nil)", nil, true, log,
		func() interface{} {
			c.Assert(1, nil)
			return nil
		})
}
Example #2
0
func (s *HelpersS) TestAssertFailWithoutExpected(c *gocheck.C) {
	checker := &MyChecker{failCheck: true, noExpectedValue: true}
	log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
		"\\.+ Assert\\(myobtained, MyChecker\\):\n" +
		"\\.+ Myobtained \\(int\\): 1\n\n"
	testHelperFailure(c, "Assert(1, checker)", nil, true, log,
		func() interface{} {
			c.Assert(1, checker)
			return nil
		})
}
Example #3
0
func (s *HelpersS) TestAssertSucceedWithoutExpected(c *gocheck.C) {
	checker := &MyChecker{noExpectedValue: true}
	testHelperSuccess(c, "Assert(1, checker)", nil, func() interface{} {
		c.Assert(1, checker)
		return nil
	})
	if checker.obtained != 1 || checker.expected != nil {
		c.Fatalf("Bad (obtained, expected) values for check (%d, %d)",
			checker.obtained, checker.expected)
	}
}
Example #4
0
func (s *HelpersS) TestAssertWithMissingExpected(c *gocheck.C) {
	checker := &MyChecker{failCheck: true}
	log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
		"\\.+ Assert\\(myobtained, MyChecker, >myexpected<\\):\n" +
		"\\.+ Wrong number of myexpected args for MyChecker: " +
		"want 1, got 0\n\n"
	testHelperFailure(c, "Assert(1, checker, !?)", nil, true, log,
		func() interface{} {
			c.Assert(1, checker)
			return nil
		})
}
Example #5
0
func (s *HelpersS) TestAssertWithError(c *gocheck.C) {
	checker := &MyChecker{checkError: "Some not so cool data provided!"}
	log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
		"\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
		"\\.+ Myobtained \\(int\\): 1\n" +
		"\\.+ Myexpected \\(int\\): 2\n" +
		"\\.+ Some not so cool data provided!\n\n"
	testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log,
		func() interface{} {
			c.Assert(1, checker, 2)
			return nil
		})
}
Example #6
0
func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *gocheck.C) {
	checker := &MyChecker{failCheck: true}
	log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
		"\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
		"\\.+ Myobtained \\(int\\): 1\n" +
		"\\.+ Myexpected \\(int\\): 2\n" +
		"\\.+ Hello world!\n\n"
	testHelperFailure(c, "Assert(1, checker, 2, msg)", nil, true, log,
		func() interface{} {
			c.Assert(1, checker, 2, myBug("Hello world!"))
			return nil
		})
}
Example #7
0
func (s *HelpersS) TestMkDir(c *gocheck.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),
		helper.path2)
	c.Check(isDir(helper.path1), gocheck.Equals, false)
	c.Check(isDir(helper.path2), gocheck.Equals, false)
}