本文整理汇总了Golang中github.com/jmorgan1321/golang-games/lib/engine/test.Checker函数的典型用法代码示例。如果您正苦于以下问题:Golang Checker函数的具体用法?Golang Checker怎么用?Golang Checker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Checker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestVector_Mul
func TestVector_Mul(t *testing.T) {
c := test.Checker(t)
c.Expect(test.EQ, Origin, Origin.Mul(5))
c.Expect(test.EQ, X, X.Mul(1))
c.Expect(test.EQ, Vector{2, 0}, X.Mul(2))
c.Expect(test.EQ, Vector{-5, 0}, X.Mul(-5))
c.Expect(test.EQ, Origin, Y.Mul(0))
c.Expect(test.EQ, Vector{0, 1}, Y.Mul(1))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:10,代码来源:vector_test.go
示例17: TestVector_Div
func TestVector_Div(t *testing.T) {
c := test.Checker(t)
c.Expect(test.EQ, Origin, Origin.Div(5))
c.Expect(test.PanicEQ, "div by zero", func() { Origin.Div(0) })
c.Expect(test.EQ, Vector{.5, 0}, X.Div(2))
c.Expect(test.EQ, Vector{-1, 0}, X.Div(-1))
c.Expect(test.EQ, Vector{0, .2}, Y.Div(5))
c.Expect(test.EQ, Y, Y.Div(1))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:10,代码来源:vector_test.go
示例18: TestMat2_MakeRow
func TestMat2_MakeRow(t *testing.T) {
c := test.Checker(t)
c.Expect(test.EQ, Row{1, 2, 0}, MakeRow(vec2.Vector{1, 2}))
c.Expect(test.EQ, Row{4, 7, 0}, MakeRow(&vec2.Vector{4, 7}))
c.Expect(test.EQ, Row{3, 2, 1}, MakeRow(pnt2.Point{3, 2}))
c.Expect(test.EQ, Row{1, 1, 1}, MakeRow(&pnt2.Point{1, 1}))
c.Expect(test.EQ, Row{1, 2, 3}, MakeRow(Col{1, 2, 3}))
type unknown int
c.Expect(test.PanicEQ, "invalid type passed into MakeRow: mat2.unknown", func() { MakeRow(unknown(5)) })
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:11,代码来源:mat2_test.go
示例19: TestVector_Unmarshal
func TestVector_Unmarshal(t *testing.T) {
b := []byte(`{"Type": "vec2.Vector", "X": 25, "Y": 12}`)
holder, err := support.ReadData(b)
if err != nil {
panic(err)
}
v := Vector{}
serialization.SerializeInPlace(&v, holder)
c := test.Checker(t)
c.Expect(test.EQ, Vector{25, 12}, v)
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:12,代码来源:vector_test.go
示例20: TestMatrix_Mul
func TestMatrix_Mul(t *testing.T) {
c := test.Checker(t)
m2 := Matrix{
0, 2, 4,
6, 8, 7,
5, 3, 1,
}
m1 := Matrix{
1, 2, 3,
4, 5, 6,
7, 8, 9,
}
c.Expect(test.EQ, Matrix{27, 27, 21, 60, 66, 57, 93, 105, 93}, m1.Mul(m2))
c.Expect(test.EQ, Matrix{36, 42, 48, 87, 108, 129, 24, 33, 42}, m2.Mul(m1))
}
开发者ID:jmorgan1321,项目名称:golang-games,代码行数:15,代码来源:matrix_test.go
注:本文中的github.com/jmorgan1321/golang-games/lib/engine/test.Checker函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论