當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.Log方法代碼示例

本文整理匯總了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))
	}
}
開發者ID:ninefive,項目名稱:tidb,代碼行數:7,代碼來源:bootstrap_test.go

示例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")
}
開發者ID:ninefive,項目名稱:tidb,代碼行數:14,代碼來源:foundation_test.go

示例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")
}
開發者ID:ninefive,項目名稱:tidb,代碼行數:21,代碼來源:foundation_test.go

示例4: TestLogAndSucceed

func (s *SuccessHelper) TestLogAndSucceed(c *check.C) {
	c.Log("Expected success!")
}
開發者ID:lovedboy,項目名稱:tidb,代碼行數:3,代碼來源:check_test.go

示例5: TestLogAndFail

func (s *FailHelper) TestLogAndFail(c *check.C) {
	s.testLine = getMyLine() - 1
	c.Log("Expected failure!")
	c.Fail()
}
開發者ID:lovedboy,項目名稱:tidb,代碼行數:5,代碼來源:check_test.go

示例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)
}
開發者ID:astaxie,項目名稱:tidb,代碼行數:101,代碼來源:convert_test.go


注:本文中的github.com/pingcap/check.C.Log方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。