本文整理汇总了Golang中github.com/jbenet/go-datastore/Godeps/_workspace/src/launchpad/net/gocheck.C类的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLogfAndGetTestLog
func (s *BootstrapS) TestLogfAndGetTestLog(c *gocheck.C) {
c.Logf("Hello %v", "there!")
log := c.GetTestLog()
if log != "Hello there!\n" {
critical(fmt.Sprintf("Logf() or GetTestLog() is not working! Got: %#v", log))
}
}
示例2: Benchmark2
func (s *FixtureHelper) Benchmark2(c *gocheck.C) {
s.trace("Benchmark2", c)
c.SetBytes(1024)
for i := 0; i < c.N; i++ {
time.Sleep(s.sleep)
}
}
示例3: TestPanics
func (s *CheckersS) TestPanics(c *gocheck.C) {
testInfo(c, gocheck.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")
// 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")
// 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"))
type deep struct{ i int }
// Deep value
testCheck(c, gocheck.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")
// Verify a nil panic
testCheck(c, gocheck.Panics, true, "", func() { panic(nil) }, nil)
testCheck(c, gocheck.Panics, false, "", func() { panic(nil) }, "NOPE")
}
示例4: TestComment
func (s *CheckersS) TestComment(c *gocheck.C) {
bug := gocheck.Commentf("a %d bc", 42)
comment := bug.CheckCommentString()
if comment != "a 42 bc" {
c.Fatalf("Commentf returned %#v", comment)
}
}
示例5: TestExpectFailureSucceed
func (s *FoundationS) TestExpectFailureSucceed(c *gocheck.C) {
helper := ExpectFailureSucceedHelper{}
output := String{}
result := gocheck.Run(&helper, &gocheck.RunConf{Output: &output})
c.Assert(output.value, gocheck.Equals, "")
c.Assert(result.ExpectedFailures, gocheck.Equals, 1)
}
示例6: TestCheckSucceedWithoutExpected
func (s *HelpersS) TestCheckSucceedWithoutExpected(c *gocheck.C) {
checker := &MyChecker{result: true, info: &gocheck.CheckerInfo{Params: []string{"myvalue"}}}
testHelperSuccess(c, "Check(1, checker)", true, func() interface{} {
return c.Check(1, checker)
})
if !reflect.DeepEqual(checker.params, []interface{}{1}) {
c.Fatalf("Bad params for check: %#v", checker.params)
}
}
示例7: TestMinLogger
func (s *BootstrapS) TestMinLogger(c *gocheck.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)
}
示例8: TestCheckSucceedWithExpected
func (s *HelpersS) TestCheckSucceedWithExpected(c *gocheck.C) {
checker := &MyChecker{result: true}
testHelperSuccess(c, "Check(1, checker, 2)", true, func() interface{} {
return c.Check(1, checker, 2)
})
if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) {
c.Fatalf("Bad params for check: %#v", checker.params)
}
}
示例9: testInfo
func testInfo(c *gocheck.C, checker gocheck.Checker, name string, paramNames []string) {
info := checker.Info()
if info.Name != name {
c.Fatalf("Got name %s, expected %s", info.Name, name)
}
if !reflect.DeepEqual(info.Params, paramNames) {
c.Fatalf("Got param names %#v, expected %#v", info.Params, paramNames)
}
}
示例10: 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)
}
}
示例11: TestCheckWithNilChecker
func (s *HelpersS) TestCheckWithNilChecker(c *gocheck.C) {
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" return c\\.Check\\(1, nil\\)\n" +
"\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
"\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
testHelperFailure(c, "Check(obtained, nil)", false, false, log,
func() interface{} {
return c.Check(1, nil)
})
}
示例12: TestCheckFailWithoutExpected
func (s *HelpersS) TestCheckFailWithoutExpected(c *gocheck.C) {
checker := &MyChecker{result: false, info: &gocheck.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"
testHelperFailure(c, "Check(1, checker)", false, false, log,
func() interface{} {
return c.Check(1, checker)
})
}
示例13: TestValueLoggingWithArrays
func (s *HelpersS) TestValueLoggingWithArrays(c *gocheck.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" +
"\\.+ myobtained \\[\\]uint8 = \\[\\]byte{0x1, 0x2}\n" +
"\\.+ myexpected \\[\\]uint8 = \\[\\]byte{0x1, 0x3}\n\n"
testHelperFailure(c, "Check([]byte{1}, chk, []byte{3})", false, false, log,
func() interface{} {
return c.Check([]byte{1, 2}, checker, []byte{1, 3})
})
}
示例14: TestAssertWithNilChecker
func (s *HelpersS) TestAssertWithNilChecker(c *gocheck.C) {
log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
" c\\.Assert\\(1, nil\\)\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
})
}
示例15: TestAssertFailWithoutExpected
func (s *HelpersS) TestAssertFailWithoutExpected(c *gocheck.C) {
checker := &MyChecker{result: false, info: &gocheck.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"
testHelperFailure(c, "Assert(1, checker)", nil, true, log,
func() interface{} {
c.Assert(1, checker)
return nil
})
}