本文整理汇总了Golang中github.com/pingcap/check.C.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Log方法的具体用法?Golang C.Log怎么用?Golang C.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/check.C
的用法示例。
在下文中一共展示了C.Log方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLogAndGetTestLog
func (s *BootstrapS) TestLogAndGetTestLog(c *check.C) {
c.Log("Hello there!")
log := c.GetTestLog()
if log != "Hello there!\n" {
critical(fmt.Sprintf("Log() or GetTestLog() is not working! Got: %#v", log))
}
}
示例2: TestSucceedNow
func (s *FoundationS) TestSucceedNow(c *check.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")
}
示例3: TestFatalf
func (s *FoundationS) TestFatalf(c *check.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")
}
示例4: TestLogAndSucceed
func (s *SuccessHelper) TestLogAndSucceed(c *check.C) {
c.Log("Expected success!")
}
示例5: TestLogAndFail
func (s *FailHelper) TestLogAndFail(c *check.C) {
s.testLine = getMyLine() - 1
c.Log("Expected failure!")
c.Fail()
}
示例6: TestConvertType
//.........这里部分代码省略.........
c.Assert(err, check.IsNil)
c.Assert(v.(mysql.Time).String(), check.Equals, "2010-10-10 10:11:11.123")
ft.Decimal = 1
vv, err = Convert(v, ft)
c.Assert(err, check.IsNil)
c.Assert(vv.(mysql.Time).String(), check.Equals, "2010-10-10 10:11:11.1")
// For TypeLonglong
ft = NewFieldType(mysql.TypeLonglong)
v, err = Convert("100", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, int64(100))
ft = NewFieldType(mysql.TypeLonglong)
ft.Flag |= mysql.UnsignedFlag
v, err = Convert("100", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, uint64(100))
// For TypeBit
ft = NewFieldType(mysql.TypeBit)
ft.Flen = 8
v, err = Convert("100", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, mysql.Bit{Value: 100, Width: 8})
v, err = Convert(mysql.Hex{Value: 100}, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, mysql.Bit{Value: 100, Width: 8})
v, err = Convert(mysql.Bit{Value: 100, Width: 8}, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, mysql.Bit{Value: 100, Width: 8})
ft.Flen = 1
v, err = Convert(1, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, mysql.Bit{Value: 1, Width: 1})
_, err = Convert(2, ft)
c.Assert(err, check.NotNil)
ft.Flen = 0
_, err = Convert(2, ft)
c.Assert(err, check.NotNil)
// For TypeNewDecimal
ft = NewFieldType(mysql.TypeNewDecimal)
ft.Decimal = 5
v, err = Convert(3.1415926, ft)
c.Assert(err, check.IsNil)
c.Assert(v.(mysql.Decimal).String(), check.Equals, "3.14159")
// For TypeYear
ft = NewFieldType(mysql.TypeYear)
v, err = Convert("2015-11-11", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, int64(2015))
v, err = Convert(2015, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.Equals, int64(2015))
v, err = Convert(1800, ft)
c.Assert(err, check.NotNil)
dt, err := mysql.ParseDate("2015-11-11")
c.Assert(err, check.IsNil)
v, err = Convert(dt, ft)
c.Assert(v, check.Equals, int64(2015))
v, err = Convert(mysql.ZeroDuration, ft)
c.Assert(v, check.Equals, int64(time.Now().Year()))
// For enum
ft = NewFieldType(mysql.TypeEnum)
ft.Elems = []string{"a", "b", "c"}
v, err = Convert("a", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.DeepEquals, mysql.Enum{Name: "a", Value: 1})
v, err = Convert(2, ft)
c.Log(errors.ErrorStack(err))
c.Assert(err, check.IsNil)
c.Assert(v, check.DeepEquals, mysql.Enum{Name: "b", Value: 2})
_, err = Convert("d", ft)
c.Assert(err, check.NotNil)
_, err = Convert(4, ft)
c.Assert(err, check.NotNil)
ft = NewFieldType(mysql.TypeSet)
ft.Elems = []string{"a", "b", "c"}
v, err = Convert("a", ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.DeepEquals, mysql.Set{Name: "a", Value: 1})
v, err = Convert(2, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.DeepEquals, mysql.Set{Name: "b", Value: 2})
v, err = Convert(3, ft)
c.Assert(err, check.IsNil)
c.Assert(v, check.DeepEquals, mysql.Set{Name: "a,b", Value: 3})
_, err = Convert("d", ft)
c.Assert(err, check.NotNil)
_, err = Convert(9, ft)
c.Assert(err, check.NotNil)
}