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()) }
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) }
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]) } } }
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) } } }
func TestVectorAdd(t *testing.T) { v := Vector2{0, 1} v.Add(Vector2{3, 5}) unittest.CheckEqual(t, v, Vector2{3, 6}) }
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) }
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) }
func TestMulVector(t *testing.T) { unittest.CheckEqual(t, MulVector(three_four, zero), zero) unittest.CheckEqual(t, MulVector(three_four, three_four), nine_sixteen) }
func TestVectorDiv(t *testing.T) { v := Vector2{10, 10} v.Div(Vector2{5, 5}) unittest.CheckEqual(t, v, Vector2{2, 2}) }
// 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) }
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)) }
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)) }
func TestSubNoWrap(t *testing.T) { unittest.CheckEqual(t, SubtractNoWrap(5, 7), uint(0)) unittest.CheckEqual(t, SubtractNoWrap(7, 5), uint(2)) }
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)) }
func TestEntityMove(t *testing.T) { simpleMover.Move(vector.Vector2{5, 5}) unittest.CheckEqual(t, simpleMover.Position, vector.Vector2{10, 10}) }
func TestVectorSub(t *testing.T) { v := Vector2{5, 5} v.Sub(Vector2{3, 7}) unittest.CheckEqual(t, v, Vector2{2, -2}) }
func TestVectorMul(t *testing.T) { v := Vector2{5, 5} v.Mul(v) unittest.CheckEqual(t, v, Vector2{25, 25}) }
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) }
func TestVectorValues(t *testing.T) { v := Vector2{10, 20} x, y := v.Values() unittest.CheckEqual(t, x, 10) unittest.CheckEqual(t, y, 20) }
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) }
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)) }
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) }