• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ready-steady/assert.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestTraverse

func TestTraverse(t *testing.T) {
	const (
		ε = 1e-14
	)

	test := func(points, Δ []float64, steps []uint) {
		a, b := traverse(points, ε)
		assert.Equal(a, Δ, t)
		assert.Equal(b, steps, t)
	}

	test(
		[]float64{0, 1, 2, 3, 4, 1, 2, 3, 4, 5},
		[]float64{1, 1, 1, 1, 1},
		[]uint{0, 1, 2, 3, 4, 1, 2, 3, 4, 5},
	)

	test(
		[]float64{0, 0, 0, 2, 4, 0, 6, 8},
		[]float64{2, 2, 2, 2},
		[]uint{0, 0, 0, 1, 2, 0, 3, 4},
	)

	test(
		[]float64{15, 10, 6, 3, 3, 1},
		[]float64{2, 3, 4, 5},
		[]uint{4, 3, 2, 1, 1, 0},
	)
}
开发者ID:turing-complete,项目名称:power,代码行数:29,代码来源:main_test.go


示例2: TestNew

func TestNew(t *testing.T) {
	config, _ := New("fixtures/004_040.json")

	assert.Equal(config.System.Floorplan, "fixtures/004.flp", t)
	assert.Equal(config.System.Configuration, "fixtures/hotspot.config", t)
	assert.Equal(config.System.Specification, "fixtures/004_040.tgff", t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:7,代码来源:main_test.go


示例3: TestUniqueRewrite

func TestUniqueRewrite(t *testing.T) {
	unique := NewUnique(2)

	index := []uint64{4, 2}
	assert.Equal(unique.Distil(index), []uint64{4, 2}, t)

	index[0], index[1] = 6, 9
	assert.Equal(unique.Distil([]uint64{4, 2}), []uint64{}, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:9,代码来源:unique_test.go


示例4: TestStep

func TestStep(t *testing.T) {
	fixture := &fixtureStep
	algorithm, strategy := prepare(fixture)

	surrogate := algorithm.Compute(fixture.target, strategy)
	assert.Equal(surrogate, fixture.surrogate, t)

	values := algorithm.Evaluate(surrogate, fixture.points)
	assert.Equal(values, fixture.values, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:10,代码来源:main_test.go


示例5: TestSample

func TestSample(t *testing.T) {
	const (
		Δt = 1e-3
	)

	power, schedule := prepare("002_040")

	assert.Equal(power.Sample(schedule, Δt, 440), fixtureSample.P, t)
	assert.Equal(power.Sample(schedule, Δt, 42), fixtureSample.P[:2*42], t)
}
开发者ID:turing-complete,项目名称:power,代码行数:10,代码来源:main_test.go


示例6: TestListDelayDummy

func TestListDelayDummy(t *testing.T) {
	platform, application, _ := system.Load(findFixture("002_040"))
	profile := system.NewProfile(platform, application)

	list := NewList(platform, application)
	schedule1 := list.Compute(profile.Mobility)
	schedule2 := list.Delay(schedule1, make([]float64, len(schedule1.Start)))

	assert.Equal(schedule2.Start, schedule1.Start, t)
	assert.Equal(schedule2.Finish, schedule1.Finish, t)
}
开发者ID:turing-complete,项目名称:time,代码行数:11,代码来源:list_test.go


示例7: TestBranin

func TestBranin(t *testing.T) {
	fixture := &fixtureBranin
	algorithm, strategy := prepare(fixture)

	surrogate := algorithm.Compute(fixture.target, strategy)
	assert.Equal(surrogate.Nodes, fixture.surrogate.Nodes, t)
	assert.Equal(interpolation.Validate(surrogate.Indices, surrogate.Inputs,
		fixture.grid), true, t)

	values := algorithm.Evaluate(surrogate, fixture.points)
	assert.EqualWithin(values, fixture.values, 0.1, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:12,代码来源:main_test.go


示例8: TestKraichnanOrszag

func TestKraichnanOrszag(t *testing.T) {
	fixture := &fixtureKraichnanOrszag
	algorithm, strategy := prepare(fixture)

	surrogate := algorithm.Compute(fixture.target, strategy)
	assert.Equal(surrogate.Nodes, fixture.surrogate.Nodes, t)
	assert.EqualWithin(surrogate.Integral, fixture.surrogate.Integral, 2e-14, t)
	assert.Equal(interpolation.Validate(surrogate.Indices, surrogate.Inputs,
		fixture.grid), true, t)

	values := algorithm.Evaluate(surrogate, fixture.points)
	assert.EqualWithin(values, fixture.values, 6e-14, t)
}
开发者ID:ready-steady,项目名称:adapt,代码行数:13,代码来源:main_test.go


示例9: TestListCompute

func TestListCompute(t *testing.T) {
	platform, application, _ := system.Load(findFixture("002_040"))
	profile := system.NewProfile(platform, application)

	list := NewList(platform, application)
	schedule := list.Compute(profile.Mobility)

	mapping := []uint{
		0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0,
		1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0,
	}

	order := []uint{
		0, 1, 2, 4, 7, 8, 5, 11, 3, 9, 15, 19, 20, 10, 12, 24, 30, 17, 22, 28, 29,
		18, 21, 27, 34, 26, 13, 16, 23, 31, 33, 25, 38, 39, 37, 35, 14, 36, 6, 32,
	}

	start := []float64{
		0.0000, 0.0230, 0.0350, 0.0910, 0.0470, 0.0790, 0.4220, 0.0680,
		0.0680, 0.1030, 0.1530, 0.0900, 0.1720, 0.3150, 0.4040, 0.1170,
		0.3360, 0.2040, 0.2590, 0.1380, 0.1530, 0.2720, 0.2190, 0.3360,
		0.1850, 0.3640, 0.3040, 0.2920, 0.2340, 0.2590, 0.2040, 0.3510,
		0.4250, 0.3510, 0.3040, 0.4000, 0.4150, 0.3880, 0.3770, 0.3880,
	}

	duration := []float64{
		0.0230, 0.0120, 0.0120, 0.0120, 0.0210, 0.0110, 0.0180, 0.0230,
		0.0110, 0.0140, 0.0190, 0.0150, 0.0130, 0.0210, 0.0110, 0.0210,
		0.0150, 0.0150, 0.0130, 0.0150, 0.0210, 0.0200, 0.0150, 0.0100,
		0.0190, 0.0130, 0.0110, 0.0120, 0.0250, 0.0150, 0.0180, 0.0190,
		0.0140, 0.0130, 0.0260, 0.0220, 0.0100, 0.0160, 0.0110, 0.0120,
	}

	finish := make([]float64, len(start))
	span := 0.0
	for i := range start {
		finish[i] = start[i] + duration[i]
		if span < finish[i] {
			span = finish[i]
		}
	}

	assert.Equal(schedule.Cores, uint(2), t)
	assert.Equal(schedule.Tasks, uint(40), t)
	assert.EqualWithin(schedule.Span, span, 1e-15, t)

	assert.Equal(schedule.Mapping, mapping, t)
	assert.Equal(schedule.Order, order, t)
	assert.EqualWithin(schedule.Start, start, 1e-15, t)
	assert.EqualWithin(schedule.Finish, finish, 1e-15, t)
}
开发者ID:turing-complete,项目名称:time,代码行数:51,代码来源:list_test.go


示例10: TestUniqueMapping

func TestUniqueMapping(t *testing.T) {
	unique := NewUnique(2)

	assert.Equal(unique.Distil([]uint64{4, 2}), []uint64{4, 2}, t)
	assert.Equal(unique.Distil([]uint64{6, 9}), []uint64{6, 9}, t)
	assert.Equal(unique.Distil([]uint64{4, 2}), []uint64{}, t)

	keys := make([]string, 0)
	for k, _ := range unique.mapping {
		keys = append(keys, k)
	}
	sort.Sort(sort.StringSlice(keys))

	assert.Equal(len(keys), 2, t)

	if isLittleEndian() {
		assert.Equal(keys[0],
			"\x04\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", t)
		assert.Equal(keys[1],
			"\x06\x00\x00\x00\x00\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00", t)
	} else {
		assert.Equal(keys[0],
			"\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x02", t)
		assert.Equal(keys[1],
			"\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x09", t)
	}
}
开发者ID:ready-steady,项目名称:adapt,代码行数:27,代码来源:unique_test.go


示例11: TestOpenParent

func TestOpenParent(t *testing.T) {
	grid := NewOpen(1)

	childLevels := []uint64{1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}
	childOrders := []uint64{0, 2, 0, 2, 4, 6, 0, 2, 4, 6, 8, 10, 12, 14}

	parentLevels := []uint64{0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}
	parentOrders := []uint64{0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 4, 4, 6, 6}

	for i := range childLevels {
		level, order := grid.Parent(childLevels[i], childOrders[i])
		assert.Equal(level, parentLevels[i], t)
		assert.Equal(order, parentOrders[i], t)
	}
}
开发者ID:ready-steady,项目名称:adapt,代码行数:15,代码来源:open_test.go


示例12: TestClosedParent

func TestClosedParent(t *testing.T) {
	grid := NewClosed(1)

	childLevels := []uint64{1, 1, 2, 2, 3, 3, 3, 3}
	childOrders := []uint64{0, 2, 1, 3, 1, 3, 5, 7}

	parentLevels := []uint64{0, 0, 1, 1, 2, 2, 2, 2}
	parentOrders := []uint64{0, 0, 0, 2, 1, 1, 3, 3}

	for i := range childLevels {
		level, order := grid.Parent(childLevels[i], childOrders[i])
		assert.Equal(level, parentLevels[i], t)
		assert.Equal(order, parentOrders[i], t)
	}
}
开发者ID:ready-steady,项目名称:adapt,代码行数:15,代码来源:closed_test.go


示例13: TestDetect

func TestDetect(t *testing.T) {
	data1 := []float64{1, math.Inf(1), 2, 0}
	data2 := []float64{0, 2, 4, 1, 1, 1, 4}
	edges := []float64{math.Inf(-1), 0, 1, 2, 4, math.Inf(1)}

	assert.Equal(detect(data1, data2), edges, t)
}
开发者ID:postfix,项目名称:statistics-1,代码行数:7,代码来源:main_test.go


示例14: TestSolutionCompute

func TestSolutionCompute(t *testing.T) {
	config, _ := config.New("fixtures/002_020.json")
	system, _ := system.New(&config.System)
	uncertainty, _ := uncertainty.NewEpistemic(system, &config.Uncertainty)

	quantity, _ := quantity.New(system, uncertainty, &config.Quantity)
	ni, no := quantity.Dimensions()

	solution, _ := New(ni, no, &config.Solution)
	surrogate := solution.Compute(quantity, quantity)

	nn := surrogate.Surrogate.Nodes

	assert.Equal(nn, uint(841), t)

	grid := grid.NewClosed(ni)
	nodes := grid.Compute(surrogate.Surrogate.Indices)

	values := make([]float64, nn*no)
	for i := uint(0); i < nn; i++ {
		quantity.Compute(nodes[i*ni:(i+1)*ni], values[i*no:(i+1)*no])
	}

	assert.EqualWithin(values, solution.Evaluate(surrogate, nodes), 1e-15, t)
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:25,代码来源:main_test.go


示例15: TestGrid

func TestGrid(t *testing.T) {
	product := newGrid(3, 4*3*2)

	product.next([]float64{1, 2, 3, 4})
	product.next([]float64{10, 20, 30})
	product.next([]float64{100, 200})

	assert.Equal(product.values, []float64{
		1, 10, 100,
		2, 10, 100,
		3, 10, 100,
		4, 10, 100,
		1, 20, 100,
		2, 20, 100,
		3, 20, 100,
		4, 20, 100,
		1, 30, 100,
		2, 30, 100,
		3, 30, 100,
		4, 30, 100,
		1, 10, 200,
		2, 10, 200,
		3, 10, 200,
		4, 10, 200,
		1, 20, 200,
		2, 20, 200,
		3, 20, 200,
		4, 20, 200,
		1, 30, 200,
		2, 30, 200,
		3, 30, 200,
		4, 30, 200,
	}, t)
}
开发者ID:ready-steady,项目名称:lagrange,代码行数:34,代码来源:support_test.go


示例16: TestWeight

func TestWeight(t *testing.T) {
	product := newWeight(4 * 3 * 2)

	product.next([]float64{1, 2, 3, 4})
	product.next([]float64{10, 20, 30})
	product.next([]float64{100, 200})

	assert.Equal(product.values, []float64{
		1 * 10 * 100,
		2 * 10 * 100,
		3 * 10 * 100,
		4 * 10 * 100,
		1 * 20 * 100,
		2 * 20 * 100,
		3 * 20 * 100,
		4 * 20 * 100,
		1 * 30 * 100,
		2 * 30 * 100,
		3 * 30 * 100,
		4 * 30 * 100,
		1 * 10 * 200,
		2 * 10 * 200,
		3 * 10 * 200,
		4 * 10 * 200,
		1 * 20 * 200,
		2 * 20 * 200,
		3 * 20 * 200,
		4 * 20 * 200,
		1 * 30 * 200,
		2 * 30 * 200,
		3 * 30 * 200,
		4 * 30 * 200,
	}, t)
}
开发者ID:ready-steady,项目名称:lagrange,代码行数:34,代码来源:support_test.go


示例17: TestClosedCompute1D1P

func TestClosedCompute1D1P(t *testing.T) {
	basis := NewClosed(1, 1)

	compute := func(level, order uint64, point float64) float64 {
		return basis.Compute(internal.Compose([]uint64{level}, []uint64{order}), []float64{point})
	}

	points := []float64{0.0, 0.25, 0.5, 0.75, 1.0}

	cases := []struct {
		level  uint64
		order  uint64
		values []float64
	}{
		{0, 0, []float64{1.0, 1.0, 1.0, 1.0, 1.0}},
		{1, 0, []float64{1.0, 0.5, 0.0, 0.0, 0.0}},
		{1, 2, []float64{0.0, 0.0, 0.0, 0.5, 1.0}},
		{2, 1, []float64{0.0, 1.0, 0.0, 0.0, 0.0}},
		{2, 3, []float64{0.0, 0.0, 0.0, 1.0, 0.0}},
	}

	values := make([]float64, len(points))

	for i := range cases {
		for j := range values {
			values[j] = compute(cases[i].level, cases[i].order, points[j])
		}
		assert.Equal(values, cases[i].values, t)
	}
}
开发者ID:ready-steady,项目名称:adapt,代码行数:30,代码来源:closed_test.go


示例18: TestKolmogorovSmirnovGaussian

func TestKolmogorovSmirnovGaussian(t *testing.T) {
	data1 := []float64{
		+1.8368909586194213e-01, -4.7615301661907383e-01,
		+8.6202161155692203e-01, -1.3616944708707543e+00,
		+4.5502955644433435e-01, -8.4870937993365902e-01,
		-3.3488693896404770e-01, +5.5278334594455014e-01,
		+1.0390906535049560e+00, -1.1176386832652081e+00,
		+1.2606587091208963e+00, +6.6014314104697769e-01,
		-6.7865553542687335e-02, -1.9522119789875436e-01,
		-2.1760635014319193e-01, -3.0310762135174091e-01,
		+2.3045624425105282e-02, +5.1290355848774699e-02,
		+8.2606279021159545e-01, +1.5269766867333727e+00,
	}

	data2 := []float64{
		+4.6691443568470004e-01, -2.0971333838873671e-01,
		+6.2519035708762571e-01, +1.8322726300143696e-01,
		-1.0297675435666211e+00, +9.4922183113102254e-01,
		+3.0706191914670344e-01, +1.3517494209945566e-01,
		+5.1524633552484855e-01, +2.6140632405538267e-01,
		-9.4148577095543373e-01, -1.6233767280382774e-01,
		-1.4605463433152618e-01, -5.3201137680882071e-01,
		+1.6821035946631788e+00, -8.7572934616001730e-01,
		-4.8381505011012110e-01, -7.1200454902742250e-01,
		-1.1742123314568162e+00, -1.9223951753927476e-01,
	}

	rejected, pvalue, statistic := KolmogorovSmirnov(data1, data2, 0.05)

	assert.Equal(rejected, false, t)
	assert.EqualWithin(pvalue, 7.7095294467658659e-01, 1e-15, t)
	assert.EqualWithin(statistic, 2.0000000000000007e-01, 1e-15, t)
}
开发者ID:postfix,项目名称:statistics-1,代码行数:33,代码来源:main_test.go


示例19: TestExtractTaskNumber

func TestExtractTaskNumber(t *testing.T) {
	scenarios := []struct {
		name    string
		total   uint
		result  uint
		success bool
	}{
		{"t0_0", 50, 0, true},
		{"t0_42", 50, 42, true},
		{"t0_42", 43, 42, true},
		{"t0_42", 42, 0, false},
		{"t1_42", 50, 0, false},
		{"t0_-2", 50, 0, false},
	}

	for _, s := range scenarios {
		result, err := extractTaskID(s.name, s.total)

		if s.success {
			assert.Success(err, t)
		} else {
			assert.Failure(err, t)
		}

		assert.Equal(result, s.result, t)
	}
}
开发者ID:turing-complete,项目名称:system,代码行数:27,代码来源:tgff_test.go


示例20: TestParseNaturalIndex

func TestParseNaturalIndex(t *testing.T) {
	cases := []struct {
		line   string
		min    uint
		max    uint
		result []uint
	}{
		{"", 0, 10, nil},
		{"[]", 0, 10, []uint{}},
		{"[0, 1, 11]", 0, 10, nil},
		{"[0, 1, 9, 10]", 0, 10, []uint{0, 1, 9, 10}},
		{"[0:10]", 0, 10, []uint{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}},
		{"[1:2:10]", 0, 10, []uint{1, 3, 5, 7, 9}},
		{"[0:2:10]", 0, 10, []uint{0, 2, 4, 6, 8, 10}},
		{"[0:5:15]", 0, 10, nil},
		{"[0, 1, end]", 0, 10, []uint{0, 1, 10}},
		{"[0:2:end]", 0, 10, []uint{0, 2, 4, 6, 8, 10}},
		{"[0:end]", 0, 10, []uint{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}},
	}

	for _, c := range cases {
		result, err := ParseNaturalIndex(c.line, c.min, c.max)
		if c.result != nil {
			assert.Success(err, t)
		}
		assert.Equal(result, c.result, t)
	}
}
开发者ID:turing-complete,项目名称:laboratory,代码行数:28,代码来源:main_test.go



注:本文中的github.com/ready-steady/assert.Equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.EqualWithin函数代码示例发布时间:2022-05-28
下一篇:
Golang aws.ParseError函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap