示例#1
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])
		}
	}
}
示例#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)
}
示例#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)
}
示例#4
0
func TestHasTokenBadLogin(t *testing.T) {
	p.loginState = TOKEN_RECEIVED
	unittest.CheckFalse(t, p.Login("bad"))
	unittest.Check(t, p.IsOffline())
}
示例#5
0
func TestOnlineLogin(t *testing.T) {
	p.loginState = ONLINE
	unittest.CheckFalse(t, p.Login(""))
}
示例#6
0
func TestOfflineLogin(t *testing.T) {
	unittest.Check(t, p.IsOffline())
	unittest.CheckFalse(t, p.Login(""))
}
示例#7
0
func TestHealthIsDead(t *testing.T) {
	unittest.Check(t, MakeHealth(0).IsDead())
	unittest.CheckFalse(t, MakeHealth(5).IsDead())
}