本文整理汇总了Golang中github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad/net/gocheck.C.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Error方法的具体用法?Golang C.Error怎么用?Golang C.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad/net/gocheck.C
的用法示例。
在下文中一共展示了C.Error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSkip
func (s *FoundationS) TestSkip(c *gocheck.C) {
helper := SkipTestHelper{}
output := String{}
gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
if output.value != "" {
c.Error("Skip() logged something:\n", output.value)
}
}
示例2: TestError
func (s *FoundationS) TestError(c *gocheck.C) {
expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
" c\\.Error\\(\"Error \", \"message!\"\\)\n"+
"\\.\\.\\. Error: Error message!\n\n",
getMyLine()+1)
c.Error("Error ", "message!")
checkState(c, nil,
&expectedState{
name: "Error(`Error `, `message!`)",
failed: true,
log: expectedLog,
})
}
示例3: TestSucceedNow
func (s *FoundationS) TestSucceedNow(c *gocheck.C) {
defer (func() {
if c.Failed() {
c.Error("SucceedNow() didn't succeed the test")
}
if c.GetTestLog() != "" {
c.Error("Something got logged:\n" + c.GetTestLog())
}
})()
c.Fail()
c.SucceedNow()
c.Log("SucceedNow() didn't stop the test")
}
示例4: TestSkipVerbose
func (s *FoundationS) TestSkipVerbose(c *gocheck.C) {
helper := SkipTestHelper{}
output := String{}
gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})
expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
" \\(Wrong platform or whatever\\)"
matched, err := regexp.MatchString(expected, output.value)
if err != nil {
c.Error("Bad expression: ", expected)
} else if !matched {
c.Error("Skip() didn't log properly:\n", output.value)
}
}
示例5: TestExpectFailureSucceedVerbose
func (s *FoundationS) TestExpectFailureSucceedVerbose(c *gocheck.C) {
helper := ExpectFailureSucceedHelper{}
output := String{}
result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output, Verbose: true})
expected := "" +
"FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
" ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n"
matched, err := regexp.MatchString(expected, output.value)
if err != nil {
c.Error("Bad expression: ", expected)
} else if !matched {
c.Error("ExpectFailure() didn't log properly:\n", output.value)
}
c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
}
示例6: TestExpectFailureFail
func (s *FoundationS) TestExpectFailureFail(c *gocheck.C) {
helper := ExpectFailureFailHelper{}
output := String{}
result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
expected := "" +
"^\n-+\n" +
"FAIL: foundation_test\\.go:[0-9]+:" +
" ExpectFailureFailHelper\\.TestFail\n\n" +
"\\.\\.\\. Error: Test succeeded, but was expected to fail\n" +
"\\.\\.\\. Reason: Bug #XYZ\n$"
matched, err := regexp.MatchString(expected, output.value)
if err != nil {
c.Error("Bad expression: ", expected)
} else if !matched {
c.Error("ExpectFailure() didn't log properly:\n", output.value)
}
c.Assert(result.ExpectedFailures, gocheck.Equals, 0)
}
示例7: TestFatalf
func (s *FoundationS) TestFatalf(c *gocheck.C) {
var line int
defer (func() {
if !c.Failed() {
c.Error("Fatalf() didn't fail the test")
} else {
c.Succeed()
expected := fmt.Sprintf("foundation_test.go:%d:\n"+
" c.Fatalf(\"Die %%s!\", \"now\")\n"+
"... Error: Die now!\n\n",
line)
if c.GetTestLog() != expected {
c.Error("Incorrect log:", c.GetTestLog())
}
}
})()
line = getMyLine() + 1
c.Fatalf("Die %s!", "now")
c.Log("Fatalf() didn't stop the test")
}
示例8: TestMethod
func (s *EmbeddedInternalS) TestMethod(c *gocheck.C) {
c.Error("TestMethod() of the embedded type was called!?")
}
示例9: TestFail
func (s *SkipTestHelper) TestFail(c *gocheck.C) {
c.Skip("Wrong platform or whatever")
c.Error("Boom!")
}
示例10: TestSucceed
func (s *ExpectFailureSucceedHelper) TestSucceed(c *gocheck.C) {
c.ExpectFailure("It booms!")
c.Error("Boom!")
}