Пример #1
0
void testReadLevelSettingsFile()	{
	iprint(countKeywords());
	sput_fail_unless(countKeywords() == 9,"9 Keywords Should Exist in the level settings queue");
	initialQueueReader();	//! Removing set up commands
	sput_fail_unless(countKeywords() == 3,"Valid: 3 Keywords Should Exist in the level settings queue");
	sput_fail_unless(getNumberOfPaths() == 1,"Valid: Number of paths that have been set is 1");
	sput_fail_unless(getNumOfTowerPositions() == 4,"Valid: Number of tower positions that have been created is 4");
	sput_fail_unless(getTowerPositionX(1) == scaleTowerPos(10,SCREEN_WIDTH_GLOBAL,MAX_TOWER_X),"Valid: Tower position 1 x value is as expected after scaling");
	sput_fail_unless(getTowerPositionY(1) == scaleTowerPos(500,SCREEN_HEIGHT_GLOBAL,MAX_TOWER_Y),"Valid: Tower position 1 y value is as expected after scaling");
	sput_fail_unless(getTotalWaveNo() == 3,"Valid: Total Waves set to three");
	setCurrWaveNum(1);
	sput_fail_unless(returnPropertyValueFromQueue(1,waveID) == 1,"Valid: First keyword has waveID 1");
	sput_fail_unless(returnPropertyValueFromQueue(2,waveID) == 2,"Valid: Second keyword has waveID 2");
	sput_fail_unless(returnPropertyValueFromQueue(3,waveID) == 3,"Valid: Third keyword has waveID 3");
	sput_fail_unless(waveCreatorCommand(getKeywordFromQueue(1)) ==3,"Valid: Three enemy commands should be placed in the queue");
	sput_fail_unless(getKeywordTypeFromQueue(3) == wave,"Valid: Third command is queue should be wave");
	sput_fail_unless(getKeywordTypeFromQueue(4) == makeEnemy,"Valid: Fourth command is queue should be makeEnemy");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 0,"Invalid:Cooldown for single enemy creation not yet ready");
	delayGame(10);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 1,"Valid: Cooldown for single enemy creation is ready");
	sput_fail_unless(getKeywordTypeFromQueue(7) == delay,"Valid: Seventh Keyword in queue is delay");
	sput_fail_unless(setCreateEnemyGroupDelay(returnPropertyValue(getKeywordFromQueue(7),dTime)) == 30, "group delay is 30");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 0,"Invalid: Cooldown for enemy group creation is not ready");
	delayGame(30);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 1,"Valid: Cooldown for enemy group creation is ready");
	sput_fail_unless(waveCreatorCommand(getKeywordFromQueue(2)) ==10,"Valid: Ten enemy commands should be placed in the queue");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(9)) == 0,"Invalid: Enemy has wave ID for next wave");
	setCurrWaveNum(2);
	delayGame(ENEMYSPAWNCOOLDOWN);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(9)) == 1,"Valid: Enemy has wave ID for current wave");
	//levelQueueReader();
}
void testlastAction()	{

    GameProperties newGame = getGame(NULL);
    delayGame(ACTIONCOOLDOWN);
    sput_fail_unless(lastAction(newGame) == 1,"Checking delay more than Cooldown returns true");
    delayGame(ACTIONCOOLDOWN-1);
    sput_fail_unless(lastAction(newGame) == 0,"Checking delay less than Cooldown returns false");

}
void testSetLastAction()	{

    GameProperties newGame = getGame(NULL);
    clock_t currTime = clock()/CLOCKS_PER_SEC;
    delayGame(2);
    sput_fail_unless(setlastAction(newGame) == (currTime + 2),"Setting Last Action to current time");
    delayGame(2);
    sput_fail_unless(setlastAction(newGame) == (currTime + 4),"Setting Last Action to current time");
}
Пример #4
0
void testlastAction()	{

	GameProperties newGame = createGame();
	delayGame(ACTIONCOOLDOWN);
	sput_fail_unless(lastAction(newGame) == 1,"Checking delay more than Cooldown returns true");
	delayGame(ACTIONCOOLDOWN-1);
	sput_fail_unless(lastAction(newGame) == 0,"Checking delay less than Cooldown returns false");
	free(newGame->clock);
	free(newGame);

}
void testClocks()	{
    sput_fail_unless(addClock(testClock) == 1,"Valid: Adding Dummy Test Clock");
    sput_fail_unless(checkUniqueClockType(testClock) == 0,"Invalid: Unique clock checker.  Clocck should already exist");
    sput_fail_unless(addClock(testClock) == 0,"Invalid: Adding non unique Dummy clock");
    sput_fail_unless(checkClock(testClock,10) == 0,"Invalid: Cooldown of 10 has not passed");
    delayGame(10);
    sput_fail_unless(checkClock(testClock,10) == 1,"Valid: Cooldown of 10 has passed");
    sput_fail_unless(checkClock(testClock,10) == 0,"Invalid: Cooldown of 10 hasn't passed after reset of cooldown");
    delayGame(10);
    sput_fail_unless(checkClock(testClock,10) == 1,"Valid: Cooldown of 10 has passed after reset of cooldown");

}