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


Golang assert.Equal函數代碼示例

本文整理匯總了Golang中github.com/ready-steady/assert.Equal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Equal函數的具體用法?Golang Equal怎麽用?Golang Equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Equal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


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