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 TestMkdir(t *testing.T) { exists, _ := fileSystem.FileExists("testdir") unittest.CheckFalse(t, exists) err := fileSystem.Mkdir("testdir") unittest.CheckNil(t, &err) defer func() { os.Remove("testdir") }() exists, _ = fileSystem.FileExists("testdir") unittest.Check(t, exists) }
func TestFileExists(t *testing.T) { exists, _ := fileSystem.FileExists("testpath") unittest.CheckFalse(t, exists) p := MakePlayer(1, "test-player", vector.Vector2{-1, 1}) p.Token = "waffle" defer func() { os.Remove("testpath") }() err := fileSystem.Save("testpath", p) unittest.CheckNil(t, &err) exists, _ = fileSystem.FileExists("testpath") unittest.Check(t, exists) }
func TestHasTokenGoodLogin(t *testing.T) { p.loginState = TOKEN_RECEIVED unittest.Check(t, p.Login("")) unittest.Check(t, p.IsOnline()) }
func TestHasTokenBadLogin(t *testing.T) { p.loginState = TOKEN_RECEIVED unittest.CheckFalse(t, p.Login("bad")) unittest.Check(t, p.IsOffline()) }
func TestOfflineLogin(t *testing.T) { unittest.Check(t, p.IsOffline()) unittest.CheckFalse(t, p.Login("")) }
func TestHealthIsDead(t *testing.T) { unittest.Check(t, MakeHealth(0).IsDead()) unittest.CheckFalse(t, MakeHealth(5).IsDead()) }