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


Golang C.Logf方法代碼示例

本文整理匯總了Golang中github.com/dvln/check.C.Logf方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Logf方法的具體用法?Golang C.Logf怎麽用?Golang C.Logf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/dvln/check.C的用法示例。


在下文中一共展示了C.Logf方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestLogfAndGetTestLog

func (s *BootstrapS) TestLogfAndGetTestLog(c *check.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))
	}
}
開發者ID:dvln,項目名稱:check,代碼行數:7,代碼來源:bootstrap_test.go

示例2: TestConcurrentLogging

// Concurrent logging should not corrupt the underling buffer.
// Use go test -race to detect the race in this test.
func (s *HelpersS) TestConcurrentLogging(c *check.C) {
	defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU()))
	var start, stop sync.WaitGroup
	start.Add(1)
	for i, n := 0, runtime.NumCPU()*2; i < n; i++ {
		stop.Add(1)
		go func(i int) {
			start.Wait()
			for j := 0; j < 30; j++ {
				c.Logf("Worker %d: line %d", i, j)
			}
			stop.Done()
		}(i)
	}
	start.Done()
	stop.Wait()
}
開發者ID:dvln,項目名稱:check,代碼行數:19,代碼來源:helpers_test.go

示例3: TestErrorf

func (s *FoundationS) TestErrorf(c *check.C) {
	// Do not use checkState() here.  It depends on Errorf() working.
	expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
		"    c.Errorf(\"Error %%v!\", \"message\")\n"+
		"... Error: Error message!\n\n",
		getMyLine()+1)
	c.Errorf("Error %v!", "message")
	failed := c.Failed()
	c.Succeed()
	if log := c.GetTestLog(); log != expectedLog {
		c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog)
		c.Fail()
	}
	if !failed {
		c.Logf("Errorf() didn't put the test in a failed state")
		c.Fail()
	}
}
開發者ID:dvln,項目名稱:check,代碼行數:18,代碼來源:foundation_test.go

示例4: testHelperFailure

func testHelperFailure(c *check.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) {
	var result interface{}
	defer (func() {
		if err := recover(); err != nil {
			panic(err)
		}
		checkState(c, result,
			&expectedState{
				name:   name,
				result: expectedResult,
				failed: true,
				log:    log,
			})
	})()
	result = closure()
	if shouldStop {
		c.Logf("%s didn't stop when it should", name)
	}
}
開發者ID:dvln,項目名稱:check,代碼行數:19,代碼來源:helpers_test.go


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