示例#1
0
func TestHealthDoDamage(t *testing.T) {
	h := MakeHealth(10)
	h.DoDamage(5)
	unittest.CheckEqual(t, h.CurHealth, uint(5))
	h.DoDamage(7)
	unittest.CheckEqual(t, h.CurHealth, uint(0))
	unittest.Check(t, h.IsDead())
}
示例#2
0
func TestSetTile(t *testing.T) {
	v := vector.Vector2{5, 5}
	x, y := v.Values()
	initChunk.SetTileVec(v, TILE_GRASS)
	unittest.CheckEqual(t, initChunk.GetTileVec(v), TILE_GRASS)

	initChunk.SetTile(x, y, TILE_EMPTY)
	unittest.CheckEqual(t, initChunk.GetTile(x, y), TILE_EMPTY)
}
示例#3
0
func TestMakeWorldMap(t *testing.T) {
	unittest.CheckEqual(t, testWorldMap.width, uint(5))
	unittest.CheckEqual(t, testWorldMap.height, uint(10))
	for y := 0; y < 10; y++ {
		for x := 0; x < 5; x++ {
			unittest.CheckFalse(t, testWorldMap.grid[x][y])
		}
	}
}
示例#4
0
func TestMakeGameChunk(t *testing.T) {
	unittest.CheckEqual(t, initChunk.Width, uint(10))
	unittest.CheckEqual(t, initChunk.Height, uint(10))
	for x := 0; x < 10; x++ {
		for y := 0; y < 10; y++ {
			unittest.CheckEqual(t, initChunk.Grid[x][y], TILE_EMPTY)
		}
	}
}
示例#5
0
func TestVectorAdd(t *testing.T) {
	v := Vector2{0, 1}
	v.Add(Vector2{3, 5})
	unittest.CheckEqual(t, v, Vector2{3, 6})
}
示例#6
0
func TestSumVector(t *testing.T) {
	unittest.CheckEqual(t, SumVector(zero), 0)
	unittest.CheckEqual(t, SumVector(three_four), 7)
	unittest.CheckEqual(t, SumVector(six_eight), 14)
}
示例#7
0
func TestDivVector(t *testing.T) {
	unittest.CheckEqual(t, DivVector(zero, three_four), zero)
	unittest.CheckEqual(t, DivVector(three_four, three_four), one)
	unittest.CheckEqual(t, DivVector(six_eight, three_four), two)
}
示例#8
0
func TestMulVector(t *testing.T) {
	unittest.CheckEqual(t, MulVector(three_four, zero), zero)
	unittest.CheckEqual(t, MulVector(three_four, three_four), nine_sixteen)
}
示例#9
0
func TestVectorDiv(t *testing.T) {
	v := Vector2{10, 10}
	v.Div(Vector2{5, 5})
	unittest.CheckEqual(t, v, Vector2{2, 2})
}
示例#10
0
// Test for CheckEqual/NotEqual -- Should go in another file eventually.
func TestEqual(t *testing.T) {
	unittest.CheckEqual(t, zero, zero)
	unittest.CheckEqual(t, three_four, three_four)
	unittest.CheckNotEqual(t, zero, three_four)
}
示例#11
0
func TextGetNextId(t *testing.T) {
	unittest.CheckEqual(t, w.getNextId(), uint(0))
	unittest.CheckEqual(t, w.getNextId(), uint(1))
	unittest.CheckEqual(t, w.getNextId(), uint(2))
	unittest.CheckEqual(t, w.getNextId(), uint(3))
}
示例#12
0
func TestMax(t *testing.T) {
	unittest.CheckEqual(t, Max(3, 5), uint(5))
	unittest.CheckEqual(t, Max(5, 3), uint(5))
	unittest.CheckEqual(t, Max(5, 5), uint(5))
}
示例#13
0
func TestSubNoWrap(t *testing.T) {
	unittest.CheckEqual(t, SubtractNoWrap(5, 7), uint(0))
	unittest.CheckEqual(t, SubtractNoWrap(7, 5), uint(2))
}
示例#14
0
func TestMin(t *testing.T) {
	unittest.CheckEqual(t, Min(3, 5), uint(3))
	unittest.CheckEqual(t, Min(5, 3), uint(3))
	unittest.CheckEqual(t, Min(5, 5), uint(5))
}
示例#15
0
func TestEntityMove(t *testing.T) {
	simpleMover.Move(vector.Vector2{5, 5})
	unittest.CheckEqual(t, simpleMover.Position, vector.Vector2{10, 10})
}
示例#16
0
func TestVectorSub(t *testing.T) {
	v := Vector2{5, 5}
	v.Sub(Vector2{3, 7})
	unittest.CheckEqual(t, v, Vector2{2, -2})
}
示例#17
0
func TestVectorMul(t *testing.T) {
	v := Vector2{5, 5}
	v.Mul(v)
	unittest.CheckEqual(t, v, Vector2{25, 25})
}
示例#18
0
func TestAddVector(t *testing.T) {
	unittest.CheckEqual(t, AddVector(zero, zero), zero)
	unittest.CheckEqual(t, AddVector(zero, three_four), three_four)
	unittest.CheckEqual(t, AddVector(three_four, three_four), six_eight)
}
示例#19
0
func TestVectorValues(t *testing.T) {
	v := Vector2{10, 20}
	x, y := v.Values()
	unittest.CheckEqual(t, x, 10)
	unittest.CheckEqual(t, y, 20)
}
示例#20
0
func TestSubVector(t *testing.T) {
	unittest.CheckEqual(t, SubVector(zero, zero), zero)
	unittest.CheckEqual(t, SubVector(six_eight, three_four), three_four)
	unittest.CheckEqual(t, SubVector(three_four, three_four), zero)
}
示例#21
0
func TestWorldMapSetGet(t *testing.T) {
	pos := vector.Vector2{0, 0}
	gm := MakeGameChunk(10, 10, pos)
	testWorldMap.SetGameChunk(pos, gm)
	unittest.CheckEqual(t, gm, testWorldMap.GetGameChunk(pos))
}
示例#22
0
func TestScalarMulVector(t *testing.T) {
	unittest.CheckEqual(t, ScalarMulVector(three_four, 1), three_four)
	unittest.CheckEqual(t, ScalarMulVector(three_four, 0), zero)
	unittest.CheckEqual(t, ScalarMulVector(three_four, 2), six_eight)
}