当前位置: 首页>>代码示例>>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;未经允许,请勿转载。