Esempio n. 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())
}
Esempio n. 2
0
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)
}
Esempio n. 3
0
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)
}
Esempio n. 4
0
func TestHasTokenGoodLogin(t *testing.T) {
	p.loginState = TOKEN_RECEIVED
	unittest.Check(t, p.Login(""))
	unittest.Check(t, p.IsOnline())
}
Esempio n. 5
0
func TestHasTokenBadLogin(t *testing.T) {
	p.loginState = TOKEN_RECEIVED
	unittest.CheckFalse(t, p.Login("bad"))
	unittest.Check(t, p.IsOffline())
}
Esempio n. 6
0
func TestOfflineLogin(t *testing.T) {
	unittest.Check(t, p.IsOffline())
	unittest.CheckFalse(t, p.Login(""))
}
Esempio n. 7
0
func TestHealthIsDead(t *testing.T) {
	unittest.Check(t, MakeHealth(0).IsDead())
	unittest.CheckFalse(t, MakeHealth(5).IsDead())
}