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


Golang Context.Errorf方法代碼示例

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


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

示例1: ConcurrencySpec

func ConcurrencySpec(c nanospec.Context) {
	r := NewRunner()
	r.AddSpec(VerySlowDummySpec)

	start := time.Now()
	r.Run()
	end := time.Now()
	totalTime := end.Sub(start).Nanoseconds()

	// If the spec is executed single-threadedly, then it would take
	// at least 4*DELAY to execute. If executed multi-threadedly, it
	// would take at least 2*DELAY to execute, because the first spec
	// needs to be executed fully before the other specs are found, but
	// after that the other specs can be executed in parallel.
	expectedMaxTime := int64(math.Floor(2.9 * DELAY))

	if totalTime > expectedMaxTime {
		c.Errorf("Expected the run to take less than %v ms but it took %v ms",
			expectedMaxTime/MILLISECOND, totalTime/MILLISECOND)
	}

	runCounts := countSpecNames(r.executed)
	c.Expect(runCounts["Child A"]).Equals(1)
	c.Expect(runCounts["Child B"]).Equals(1)
	c.Expect(runCounts["Child C"]).Equals(1)
	c.Expect(runCounts["Child D"]).Equals(1)
}
開發者ID:rafrombrc,項目名稱:gospec,代碼行數:27,代碼來源:concurrency_test.go


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