本文整理汇总了Golang中gocheck.C.Assert方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Assert方法的具体用法?Golang C.Assert怎么用?Golang C.Assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gocheck.C
的用法示例。
在下文中一共展示了C.Assert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAssertWithNilChecker
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
})
}
示例2: TestAssertFailWithoutExpected
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
})
}
示例3: TestAssertSucceedWithoutExpected
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)
}
}
示例4: TestAssertWithMissingExpected
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
})
}
示例5: TestAssertWithError
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
})
}
示例6: TestAssertFailWithExpectedAndMessage
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
})
}
示例7: TestMkDir
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)
}