当前位置: 首页>>代码示例>>Golang>>正文


Golang test.Checker函数代码示例

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


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

示例1: TestMatrix_Col

func TestMatrix_Col(t *testing.T) {
	c := test.Checker(t)
	m := Matrix{1, 2, 3, 4, 5, 6, 7, 8, 9}
	c.Expect(test.EQ, Col{1, 4, 7}, m.Col(0))
	c.Expect(test.EQ, Col{2, 5, 8}, m.Col(1))
	c.Expect(test.EQ, Col{3, 6, 9}, m.Col(2))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:matrix_test.go

示例2: TestVector_Neg

func TestVector_Neg(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.EQ, Vector{-1, 0}, X.Neg())
	c.Expect(test.EQ, Vector{0, -1}, Y.Neg())
	c.Expect(test.EQ, Vector{-1, -1}, X.Add(Y).Neg())
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:vector_test.go

示例3: TestMatrix_Sub

func TestMatrix_Sub(t *testing.T) {
	c := test.Checker(t)
	m1 := Matrix{10, 20, 30, 40, 50, 60, 70, 80, 90}
	m2 := Matrix{1, 2, 3, 4, 5, 6, 7, 8, 9}
	c.Expect(test.EQ, Matrix{9, 18, 27, 36, 45, 54, 63, 72, 81}, m1.Sub(m2))
	c.Expect(test.EQ, Matrix{-9, -18, -27, -36, -45, -54, -63, -72, -81}, m2.Sub(m1))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:matrix_test.go

示例4: TestVec2_Variables

func TestVec2_Variables(t *testing.T) {
	c := test.Checker(t, test.Summary("spec testing exported variables"))

	c.Expect(test.EQ, Vector{0, 0}, Origin, "origin")
	c.Expect(test.EQ, Vector{1, 0}, X, "x-axis")
	c.Expect(test.EQ, Vector{0, 1}, Y, "y-axis")
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:vec2_test.go

示例5: TestNormal_Mag2

func TestNormal_Mag2(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.FloatEQ, 0.0, Normal{0, 0}.Mag2())
	c.Expect(test.FloatEQ, 1.0, Normal{0, 1}.Mag2())
	c.Expect(test.FloatEQ, 25.0, Normal{3, 4}.Mag2())
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:normal_test.go

示例6: TestVector_Mag2

func TestVector_Mag2(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.FloatEQ, 0.0, Origin.Mag2())
	c.Expect(test.FloatEQ, 1.0, Y.Mag2())
	c.Expect(test.FloatEQ, 25.0, Vector{3, 4}.Mag2())
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:vector_test.go

示例7: TestMatrix_Row

func TestMatrix_Row(t *testing.T) {
	c := test.Checker(t)
	m := Matrix{1, 2, 3, 4, 5, 6, 7, 8, 9}
	c.Expect(test.EQ, Row{1, 2, 3}, m.Row(0))
	c.Expect(test.EQ, Row{4, 5, 6}, m.Row(1))
	c.Expect(test.EQ, Row{7, 8, 9}, m.Row(2))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:7,代码来源:matrix_test.go

示例8: TestMat2_Construct

func TestMat2_Construct(t *testing.T) {
	tests := []struct {
		summary string
		args    interface{}
		exp     Matrix
	}{
		{
			summary: "an slice of float32",
			args:    []float32{0, 1, 2, 3, 4, 5, 6, 7, 8},
			exp:     Matrix{0, 1, 2, 3, 4, 5, 6, 7, 8},
		},

		{
			summary: "an [16]float32",
			args:    [9]float32{0, 1},
			exp:     Matrix{0, 1},
		},

		{
			summary: "a Matrix",
			args:    Matrix{7, 12, 15, -1, -1, -1, 0, 8, 7},
			exp:     Matrix{7, 12, 15, -1, -1, -1, 0, 8, 7},
		},

		{
			summary: "a *Matrix",
			args:    &Matrix{10, 9, 8, 7, 6, 5, 4, 3, 2},
			exp:     Matrix{10, 9, 8, 7, 6, 5, 4, 3, 2},
		},

		{
			summary: "a []Row",
			args:    []Row{{1, 2, 0}, {0, 1, 2}, {2, 0, 1}},
			exp:     Matrix{1, 2, 0, 0, 1, 2, 2, 0, 1},
		},

		{
			summary: "a [3]Row",
			args:    [3]Row{{1, 2, 0}, {0, 1, 2}, {2, 0, 1}},
			exp:     Matrix{1, 2, 0, 0, 1, 2, 2, 0, 1},
		},

		{
			summary: "a []Col",
			args:    []Col{{1, 2, 0}, {0, 1, 2}, {2, 0, 1}},
			exp:     Matrix{1, 0, 2, 2, 1, 0, 0, 2, 1},
		},

		{
			summary: "a [3]Col",
			args:    [3]Col{{1, 2, 0}, {0, 1, 2}, {2, 0, 1}},
			exp:     Matrix{1, 0, 2, 2, 1, 0, 0, 2, 1},
		},
	}
	for i, tt := range tests {
		c := test.Checker(t, test.Summary("with test %v: %v", i, tt.summary))
		c.Expect(test.EQ, tt.exp, Construct(tt.args))
	}
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:59,代码来源:mat2_test.go

示例9: TestVector_Sub

func TestVector_Sub(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.EQ, Vector{-2, -1}, Origin.Sub(Vector{2, 1}))
	c.Expect(test.EQ, Vector{0, 0}, X.Sub(X))
	c.Expect(test.EQ, Vector{1, -1}, X.Sub(Y))
	c.Expect(test.EQ, Vector{-1, 1}, Y.Sub(X))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:vector_test.go

示例10: TestVector_Add

func TestVector_Add(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.EQ, Vector{2, 1}, Origin.Add(Vector{2, 1}))
	c.Expect(test.EQ, Vector{2, 0}, X.Add(X))
	c.Expect(test.EQ, Vector{1, 1}, X.Add(Y))
	c.Expect(test.EQ, Vector{1, 1}, Y.Add(X))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:vector_test.go

示例11: TestMatrix_Add

func TestMatrix_Add(t *testing.T) {
	c := test.Checker(t)
	m1 := Matrix{10, 20, 30, 40, 50, 60, 70, 80, 90}
	m2 := Matrix{1, 2, 3, 4, 5, 6, 7, 8, 9}
	r := Matrix{11, 22, 33, 44, 55, 66, 77, 88, 99}
	c.Expect(test.EQ, r, m1.Add(m2))
	c.Expect(test.EQ, r, m2.Add(m1))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:matrix_test.go

示例12: TestVector_Norm

func TestVector_Norm(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.EQ, Y, Y.Norm())
	c.Expect(test.EQ, X, X.Norm())
	c.Expect(test.EQ, X, Vector{5, 0}.Norm())
	c.Expect(test.EQ, Vector{.70710677, .70710677}, Vector{1, 1}.Norm())
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:vector_test.go

示例13: TestNormal_Norm

func TestNormal_Norm(t *testing.T) {
	c := test.Checker(t)

	c.Expect(test.EQ, Normal{0, 1}, Normal{0, 1}.Norm())
	c.Expect(test.EQ, Normal{1, 0}, Normal{1, 0}.Norm())
	c.Expect(test.EQ, Normal{1, 0}, Normal{5, 0}.Norm())
	c.Expect(test.EQ, Normal{.70710677, .70710677}, Normal{1, 1}.Norm())
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:8,代码来源:normal_test.go

示例14: TestGoc_Serialization

func TestGoc_Serialization(t *testing.T) {
	c := test.Checker(t)
	// tt1 := TT1{
	// 	// TT2: TT2{
	// 	// 	S: "jeff",
	// 	// },
	// 	I: 13,
	// }
	// tt1.SetS("jeff")
	// fmt.Println("name:", tt1.S())
	tt2 := &TT2{}
	tt2.SetS("jeff")
	fmt.Println("S:", tt2.S())
	b, err := json.MarshalIndent(tt2, "    ", "    ")
	if err != nil {
		panic(err)
	}
	fmt.Println(string(b))

	// tf1 := testCmp1{
	// 	T: &testCmp1{
	// 		B: true,
	// 		S: "string",
	// 	},
	// }
	// tf1.Name_ = "name"
	// tf1.SetName("john")
	// b, err := json.MarshalIndent(tf1, "    ", "    ")
	// if err != nil {
	// 	panic(err)
	// }
	// fmt.Println(string(b))

	// err = json.Unmarshal(b, &tf2)
	// 	var tf2 = testCmp1
	// 	holder, err := support.ReadData([]byte(`
	// {
	//     "Type": "types.TestCmp1",
	//     "B": true,
	//     "T" : {
	//         "Type": "types.TestCmp1",
	//         "S": "string"
	//     }
	// }
	//         `))
	// 	if err != nil {
	// 		panic(err)
	// 	}
	// 	serialization.SerializeInPlace(&tf2, holder)
	// 	if err != nil {
	// 		panic(err)
	// 	}
	// 	// fmt.Println("data:", *tf2.(*testCmp1), *tf2.(*testCmp1).T.(*testCmp1))

	c.Assert(test.True, false, "not finished")
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:56,代码来源:goc_test.go

示例15: TestMat2_ExportedVariables

func TestMat2_ExportedVariables(t *testing.T) {
	c := test.Checker(t)

	i := Matrix{}
	i[0] = 1
	i[4] = 1
	i[8] = 1
	c.Expect(test.EQ, i, Identity)
	c.Expect(test.EQ, Matrix{}, Zero)
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:10,代码来源:mat2_test.go


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