Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

Hello, soldier, you have been specially selected as the defender of planet earth.

Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.

But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.

As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.

Committer:
evanso
Date:
Tue May 26 19:38:48 2020 +0000
Revision:
85:87bc28b151d8
Parent:
83:35d1e846eab2
Child:
87:832ca78426b5
Spell checked all of code and comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 11:ab578a151f67 1 #ifndef TESTS_H
evanso 11:ab578a151f67 2 #define TESTS_H
evanso 11:ab578a151f67 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
evanso 11:ab578a151f67 5 #include "Spaceship_test.h"
evanso 14:7419c680656f 6 #include "Map_test.h"
evanso 22:053c11a202e1 7 #include "Alien_test.h"
evanso 23:cc44e26c08fa 8 #include "Weapons_test.h"
evanso 26:1a7056eb3253 9 #include "Explosion_test.h"
evanso 37:a05eac7fcb4c 10 #include "People_test.h"
evanso 65:daa792a09e1f 11 #include "Menu_test.h"
evanso 66:33f479036a5d 12 #include "HUD_test.h"
evanso 67:a2984682d641 13 #include "SavedGames_test.h"
evanso 70:8c4572d17441 14 #include "Settings_test.h"
evanso 79:66bcf8fa2d2d 15 #include "HighScore_test.h"
evanso 83:35d1e846eab2 16 #include "PlayEngine_test.h"
evanso 11:ab578a151f67 17
evanso 11:ab578a151f67 18 /** Test
evanso 27:8bb2bd97c319 19 * @brief Runs all tests for game
evanso 27:8bb2bd97c319 20 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 21 * @date April 2020
evanso 27:8bb2bd97c319 22 */
evanso 13:12276eed13ac 23 // Spaceship tests -------------------------------------------------------------
evanso 65:daa792a09e1f 24
evanso 82:3211b31e9421 25 void run_spaceship_movement_tests() {
evanso 13:12276eed13ac 26 printf ("\nTesting spaceship_movement_test() \n");
evanso 13:12276eed13ac 27 int passed_counter = 0;
evanso 13:12276eed13ac 28
evanso 85:87bc28b151d8 29 // Runs test with all possible movement directions
evanso 13:12276eed13ac 30 if (spaceship_movement_test(CENTRE, 36, 22)) passed_counter++;
evanso 13:12276eed13ac 31 if (spaceship_movement_test(N, 36, 21)) passed_counter++;
evanso 16:1ee3d3804557 32 if (spaceship_movement_test(NE, 35, 21)) passed_counter++;
evanso 16:1ee3d3804557 33 if (spaceship_movement_test(E, 35, 22)) passed_counter++;
evanso 16:1ee3d3804557 34 if (spaceship_movement_test(SE, 35, 23)) passed_counter++;
evanso 13:12276eed13ac 35 if (spaceship_movement_test(S, 36, 23)) passed_counter++;
evanso 16:1ee3d3804557 36 if (spaceship_movement_test(SW, 37, 23)) passed_counter++;
evanso 16:1ee3d3804557 37 if (spaceship_movement_test(W, 37, 22)) passed_counter++;
evanso 16:1ee3d3804557 38 if (spaceship_movement_test(NW, 37, 21)) passed_counter++;
evanso 11:ab578a151f67 39
evanso 82:3211b31e9421 40 // Prints results
evanso 37:a05eac7fcb4c 41 printf ("\nspaceship_movement_test passed %d tests out of 9\n\n\n",
evanso 27:8bb2bd97c319 42 passed_counter);
evanso 12:1c0b6796aaca 43 }
evanso 12:1c0b6796aaca 44
evanso 82:3211b31e9421 45 void run_spaceship_draw_tests() {
evanso 37:a05eac7fcb4c 46 printf ("\nTesting spaceship_draw_tests() \n\n");
evanso 13:12276eed13ac 47 int passed_counter = 0;
evanso 12:1c0b6796aaca 48
evanso 13:12276eed13ac 49 // Runs test with max movement directions
evanso 65:daa792a09e1f 50 if (spaceship_draw_test(NE, 1, 15, 9)) passed_counter++;
evanso 16:1ee3d3804557 51 if (spaceship_draw_test(SE, 1, 15, 44)) passed_counter++;
evanso 16:1ee3d3804557 52 if (spaceship_draw_test(SW, 1, 64, 44)) passed_counter++;
evanso 65:daa792a09e1f 53 if (spaceship_draw_test(NW, 1, 64, 9)) passed_counter++;
evanso 13:12276eed13ac 54
evanso 82:3211b31e9421 55 // Prints results
evanso 37:a05eac7fcb4c 56 printf ("\nspaceship_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 11:ab578a151f67 57 }
evanso 11:ab578a151f67 58
evanso 65:daa792a09e1f 59
evanso 65:daa792a09e1f 60
evanso 13:12276eed13ac 61 // Map tests -------------------------------------------------------------------
evanso 13:12276eed13ac 62
evanso 82:3211b31e9421 63 void run_map_draw_tests() {
evanso 37:a05eac7fcb4c 64 printf ("\nTesting map_draw_tests() \n\n");
evanso 14:7419c680656f 65 int passed_counter = 0;
evanso 14:7419c680656f 66
evanso 14:7419c680656f 67 // Runs multiple map tests
evanso 18:11068b98e261 68 if (map_move_test(CENTRE, -84)) passed_counter++;
evanso 18:11068b98e261 69 if (map_move_test(N, -84)) passed_counter++;
evanso 18:11068b98e261 70 if (map_move_test(NE,-86)) passed_counter++;
evanso 18:11068b98e261 71 if (map_move_test(E, -86)) passed_counter++;
evanso 18:11068b98e261 72 if (map_move_test(SE, -86)) passed_counter++;
evanso 18:11068b98e261 73 if (map_move_test(S, -84)) passed_counter++;
evanso 18:11068b98e261 74 if (map_move_test(SW, -82)) passed_counter++;
evanso 18:11068b98e261 75 if (map_move_test(W, -82)) passed_counter++;
evanso 18:11068b98e261 76 if (map_move_test(NW, -82)) passed_counter++;
evanso 14:7419c680656f 77
evanso 82:3211b31e9421 78 // Prints results
evanso 37:a05eac7fcb4c 79 printf ("\nmap_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 14:7419c680656f 80 }
evanso 13:12276eed13ac 81
evanso 65:daa792a09e1f 82
evanso 65:daa792a09e1f 83
evanso 22:053c11a202e1 84 // Alien tests -----------------------------------------------------------------
evanso 65:daa792a09e1f 85
evanso 82:3211b31e9421 86 void run_alien_draw_tests() {
evanso 37:a05eac7fcb4c 87 printf ("\nTesting alien_draw_test() \n\n");
evanso 22:053c11a202e1 88 int passed_counter = 0;
evanso 22:053c11a202e1 89
evanso 85:87bc28b151d8 90 // Runs test with all possible movement directions
evanso 37:a05eac7fcb4c 91 if (alien_draw_test(1,CENTRE, 1, 1)) passed_counter++;
evanso 37:a05eac7fcb4c 92 if (alien_draw_test(1,N, 43, 20)) passed_counter++;
evanso 37:a05eac7fcb4c 93 if (alien_draw_test(0,NE, -23, 6)) passed_counter++;
evanso 37:a05eac7fcb4c 94 if (alien_draw_test(0,E, 23, -34)) passed_counter++;
evanso 37:a05eac7fcb4c 95 if (alien_draw_test(0,SE, -23, -43)) passed_counter++;
evanso 37:a05eac7fcb4c 96 if (alien_draw_test(0,S, 100, 26)) passed_counter++;
evanso 37:a05eac7fcb4c 97 if (alien_draw_test(0,SE, 40, 100)) passed_counter++;
evanso 37:a05eac7fcb4c 98 if (alien_draw_test(1,E, 70, 5)) passed_counter++;
evanso 37:a05eac7fcb4c 99 if (alien_draw_test(1,NE, 6, 44)) passed_counter++;
evanso 22:053c11a202e1 100
evanso 82:3211b31e9421 101 // Prints results
evanso 37:a05eac7fcb4c 102 printf ("\nalien_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 22:053c11a202e1 103 }
evanso 22:053c11a202e1 104
evanso 82:3211b31e9421 105 void run_check_collision_test() {
evanso 37:a05eac7fcb4c 106 printf ("\nTesting alien_collision_test() \n\n");
evanso 22:053c11a202e1 107 int passed_counter = 0;
evanso 22:053c11a202e1 108
evanso 85:87bc28b151d8 109 // Runs test with all different possible inputs
evanso 38:75bd968daa31 110 if (check_collision_test(1, 1, 10,22)) passed_counter++;
evanso 38:75bd968daa31 111 if (check_collision_test(0, 1, 28,40)) passed_counter++;
evanso 38:75bd968daa31 112 if (check_collision_test(1, 0, 11,22)) passed_counter++;
evanso 38:75bd968daa31 113 if (check_collision_test(0, 0, 20,22)) passed_counter++;
evanso 22:053c11a202e1 114
evanso 82:3211b31e9421 115 // Prints results
evanso 37:a05eac7fcb4c 116 printf ("\nalien_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 22:053c11a202e1 117 }
evanso 15:90b6821bcf64 118
evanso 65:daa792a09e1f 119
evanso 27:8bb2bd97c319 120 // Weapons tests ---------------------------------------------------------------
evanso 65:daa792a09e1f 121
evanso 82:3211b31e9421 122 void run_weapons_draw_tests() {
evanso 37:a05eac7fcb4c 123 printf ("\nTesting spaceship_draw_tests() \n\n");
evanso 23:cc44e26c08fa 124 int passed_counter = 0;
evanso 23:cc44e26c08fa 125
evanso 23:cc44e26c08fa 126 // Runs test with max movement directions
evanso 23:cc44e26c08fa 127 if (weapons_draw_test(1, 1, 1, 49, 24)) passed_counter++;
evanso 23:cc44e26c08fa 128 if (weapons_draw_test(1, 1, 2, 52, 24)) passed_counter++;
evanso 23:cc44e26c08fa 129 if (weapons_draw_test(0, 1, 2, 49, 24)) passed_counter++;
evanso 23:cc44e26c08fa 130 if (weapons_draw_test(1, 0, 1, 36, 24)) passed_counter++;
evanso 23:cc44e26c08fa 131 if (weapons_draw_test(1, 0, 2, 33, 24)) passed_counter++;
evanso 23:cc44e26c08fa 132 if (weapons_draw_test(0, 0, 2, 33, 24)) passed_counter++;
evanso 23:cc44e26c08fa 133
evanso 82:3211b31e9421 134 // Prints results
evanso 37:a05eac7fcb4c 135 printf ("\nspaceship_draw_test passed %d tests out of 6\n\n\n",passed_counter);
evanso 23:cc44e26c08fa 136 }
evanso 26:1a7056eb3253 137
evanso 65:daa792a09e1f 138
evanso 65:daa792a09e1f 139
evanso 27:8bb2bd97c319 140 // Explosion tests -------------------------------------------------------------
evanso 65:daa792a09e1f 141
evanso 82:3211b31e9421 142 void run_explosion_draw_tests() {
evanso 37:a05eac7fcb4c 143 printf ("\nTesting explosion_draw_tests() \n\n");
evanso 26:1a7056eb3253 144 int passed_counter = 0;
evanso 26:1a7056eb3253 145
evanso 26:1a7056eb3253 146 // Runs test with max movement directions
evanso 26:1a7056eb3253 147 if (explosion_draw_test(1, 15, 3)) passed_counter++;
evanso 26:1a7056eb3253 148 if (explosion_draw_test(1, 15, 44)) passed_counter++;
evanso 26:1a7056eb3253 149 if (explosion_draw_test(1, 64, 44)) passed_counter++;
evanso 26:1a7056eb3253 150 if (explosion_draw_test(1, 64, 2)) passed_counter++;
evanso 26:1a7056eb3253 151
evanso 82:3211b31e9421 152 // Prints results
evanso 37:a05eac7fcb4c 153 printf ("\nspaceship_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 37:a05eac7fcb4c 154 }
evanso 37:a05eac7fcb4c 155
evanso 65:daa792a09e1f 156
evanso 65:daa792a09e1f 157
evanso 37:a05eac7fcb4c 158 // People tests ----------------------------------------------------------------
evanso 37:a05eac7fcb4c 159
evanso 82:3211b31e9421 160 void run_people_draw_tests() {
evanso 37:a05eac7fcb4c 161 printf ("\nTesting people_draw_tests() \n\n");
evanso 37:a05eac7fcb4c 162 int passed_counter = 0;
evanso 37:a05eac7fcb4c 163
evanso 37:a05eac7fcb4c 164 // Runs test with max movement directions
evanso 37:a05eac7fcb4c 165 if (people_draw_test(CENTRE, 1,44)) passed_counter++;
evanso 37:a05eac7fcb4c 166 if (people_draw_test(N, 0,100)) passed_counter++;
evanso 37:a05eac7fcb4c 167 if (people_draw_test(NE, 0, -100)) passed_counter++;
evanso 37:a05eac7fcb4c 168 if (people_draw_test(E, 1,0)) passed_counter++;
evanso 37:a05eac7fcb4c 169 if (people_draw_test(SE, 1,82)) passed_counter++;
evanso 37:a05eac7fcb4c 170 if (people_draw_test(S, 1,43)) passed_counter++;
evanso 37:a05eac7fcb4c 171 if (people_draw_test(SW, 0,-64)) passed_counter++;
evanso 37:a05eac7fcb4c 172 if (people_draw_test(W, 0,-6)) passed_counter++;
evanso 37:a05eac7fcb4c 173 if (people_draw_test(NW, 0,84)) passed_counter++;
evanso 37:a05eac7fcb4c 174
evanso 82:3211b31e9421 175 // Prints results
evanso 37:a05eac7fcb4c 176 printf ("\npeople_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 26:1a7056eb3253 177 }
evanso 27:8bb2bd97c319 178
evanso 82:3211b31e9421 179 void run_check_alien_collision_test() {
evanso 38:75bd968daa31 180 printf ("\nTesting check_alien_collision_test() \n\n");
evanso 38:75bd968daa31 181 int passed_counter = 0;
evanso 38:75bd968daa31 182
evanso 85:87bc28b151d8 183 // Runs test with all different possible inputs
evanso 38:75bd968daa31 184 if (check_alien_collision_test(1,1)) passed_counter++;
evanso 38:75bd968daa31 185 if (check_alien_collision_test(1,80)) passed_counter++;
evanso 38:75bd968daa31 186 if (check_alien_collision_test(1,-42)) passed_counter++;
evanso 38:75bd968daa31 187 if (check_alien_collision_test(1,100)) passed_counter++;
evanso 38:75bd968daa31 188
evanso 82:3211b31e9421 189 // Prints results
evanso 65:daa792a09e1f 190 printf ("\ncheck_alien_collision_test passed %d tests out of 4\n\n\n",
evanso 65:daa792a09e1f 191 passed_counter);
evanso 65:daa792a09e1f 192 }
evanso 65:daa792a09e1f 193
evanso 65:daa792a09e1f 194
evanso 65:daa792a09e1f 195
evanso 65:daa792a09e1f 196 // Menu tests ------------------------------------------------------------------
evanso 65:daa792a09e1f 197
evanso 82:3211b31e9421 198 void run_menu_select_part_test() {
evanso 65:daa792a09e1f 199 printf ("\nTesting menu_select_part_test() \n\n");
evanso 65:daa792a09e1f 200 int passed_counter = 0;
evanso 65:daa792a09e1f 201
evanso 85:87bc28b151d8 202 // Runs test with all different possible inputs
evanso 65:daa792a09e1f 203 if (menu_select_part_test(play,1)) passed_counter++;
evanso 65:daa792a09e1f 204 if (menu_select_part_test(main_menu,0)) passed_counter++;
evanso 65:daa792a09e1f 205
evanso 82:3211b31e9421 206 // Prints results
evanso 65:daa792a09e1f 207 printf ("\nmenu_select_part_test passed %d tests out of 2\n\n\n",
evanso 65:daa792a09e1f 208 passed_counter);
evanso 65:daa792a09e1f 209 }
evanso 65:daa792a09e1f 210
evanso 82:3211b31e9421 211 void run_menu_scroll_test() {
evanso 65:daa792a09e1f 212 printf ("\nTesting menu_scroll_test() \n\n");
evanso 65:daa792a09e1f 213 int passed_counter = 0;
evanso 65:daa792a09e1f 214
evanso 85:87bc28b151d8 215 // Runs test with all different possible inputs
evanso 65:daa792a09e1f 216 if (menu_scroll_test(CENTRE, play)) passed_counter++;
evanso 65:daa792a09e1f 217 if (menu_scroll_test(N, settings)) passed_counter++;
evanso 65:daa792a09e1f 218 if (menu_scroll_test(NE, settings)) passed_counter++;
evanso 65:daa792a09e1f 219 if (menu_scroll_test(E, play)) passed_counter++;
evanso 79:66bcf8fa2d2d 220 if (menu_scroll_test(SE, high_score)) passed_counter++;
evanso 79:66bcf8fa2d2d 221 if (menu_scroll_test(S, high_score)) passed_counter++;
evanso 79:66bcf8fa2d2d 222 if (menu_scroll_test(SW, high_score)) passed_counter++;
evanso 65:daa792a09e1f 223 if (menu_scroll_test(W, play)) passed_counter++;
evanso 65:daa792a09e1f 224 if (menu_scroll_test(NW, settings)) passed_counter++;
evanso 65:daa792a09e1f 225
evanso 82:3211b31e9421 226 // Prints results
evanso 65:daa792a09e1f 227 printf ("\nmenu_scroll_test passed %d tests out of 9\n\n\n",
evanso 65:daa792a09e1f 228 passed_counter);
evanso 38:75bd968daa31 229 }
evanso 38:75bd968daa31 230
evanso 82:3211b31e9421 231 void run_menu_draw_part_test() {
evanso 70:8c4572d17441 232 printf ("\nmenu_draw_part_test() \n\n");
evanso 70:8c4572d17441 233 int passed_counter = 0;
evanso 70:8c4572d17441 234
evanso 85:87bc28b151d8 235 // Runs test with all different possible inputs
evanso 70:8c4572d17441 236 if (menu_draw_part_test(1, 42, 27)) passed_counter++;
evanso 70:8c4572d17441 237 if (menu_draw_part_test(1, 41, 43)) passed_counter++;
evanso 70:8c4572d17441 238 if (menu_draw_part_test(0, 9, 1)) passed_counter++;
evanso 70:8c4572d17441 239 if (menu_draw_part_test(0, 0, 0)) passed_counter++;
evanso 70:8c4572d17441 240
evanso 82:3211b31e9421 241 // Prints results
evanso 70:8c4572d17441 242 printf ("\nmenu_draw_part_test %d tests out of 4\n\n\n",
evanso 70:8c4572d17441 243 passed_counter);
evanso 70:8c4572d17441 244 }
evanso 70:8c4572d17441 245
evanso 70:8c4572d17441 246
evanso 66:33f479036a5d 247
evanso 66:33f479036a5d 248
evanso 66:33f479036a5d 249 // HUD tests -------------------------------------------------------------------
evanso 66:33f479036a5d 250
evanso 82:3211b31e9421 251 void run_HUD_draw_test() {
evanso 66:33f479036a5d 252 printf ("\nTesting HUD_draw_test() \n\n");
evanso 66:33f479036a5d 253 int passed_counter = 0;
evanso 66:33f479036a5d 254
evanso 85:87bc28b151d8 255 // Runs test with all different possible inputs
evanso 66:33f479036a5d 256 if (HUD_draw_test(3, 0, 4, 1, 3, 3)) passed_counter++;
evanso 66:33f479036a5d 257 if (HUD_draw_test(3, 0, 4, 1, 12, 3)) passed_counter++;
evanso 66:33f479036a5d 258 if (HUD_draw_test(1, 0, 4, 0, 12, 3)) passed_counter++;
evanso 66:33f479036a5d 259 if (HUD_draw_test(3, 0, 4, 1, 62, 3)) passed_counter++;
evanso 66:33f479036a5d 260 if (HUD_draw_test(3, 0, 3, 0, 62, 3)) passed_counter++;
evanso 66:33f479036a5d 261 if (HUD_draw_test(3, 0, 3, 1, 30, 3)) passed_counter++;
evanso 66:33f479036a5d 262 if (HUD_draw_test(3, 1111, 3, 00, 30, 3)) passed_counter++;
evanso 66:33f479036a5d 263
evanso 82:3211b31e9421 264 // Prints results
evanso 66:33f479036a5d 265 printf ("\nHUD_draw_test passed %d tests out of 7\n\n\n",
evanso 66:33f479036a5d 266 passed_counter);
evanso 66:33f479036a5d 267 }
evanso 66:33f479036a5d 268
evanso 70:8c4572d17441 269
evanso 70:8c4572d17441 270
evanso 70:8c4572d17441 271
evanso 67:a2984682d641 272 // Saved Games tests -----------------------------------------------------------
evanso 67:a2984682d641 273
evanso 82:3211b31e9421 274 void run_saved_games_scroll_test() {
evanso 67:a2984682d641 275 printf ("\nsaved_games_scroll_test() \n\n");
evanso 67:a2984682d641 276 int passed_counter = 0;
evanso 67:a2984682d641 277
evanso 85:87bc28b151d8 278 // Runs test with all different possible inputs
evanso 67:a2984682d641 279 if (saved_games_scroll_test(CENTRE, 1)) passed_counter++;
evanso 67:a2984682d641 280 if (saved_games_scroll_test(N, 2)) passed_counter++;
evanso 67:a2984682d641 281 if (saved_games_scroll_test(NE, 2)) passed_counter++;
evanso 67:a2984682d641 282 if (saved_games_scroll_test(E, 1)) passed_counter++;
evanso 67:a2984682d641 283 if (saved_games_scroll_test(SE, 3)) passed_counter++;
evanso 67:a2984682d641 284 if (saved_games_scroll_test(S, 3)) passed_counter++;
evanso 67:a2984682d641 285 if (saved_games_scroll_test(SW, 3)) passed_counter++;
evanso 67:a2984682d641 286 if (saved_games_scroll_test(W, 1)) passed_counter++;
evanso 67:a2984682d641 287 if (saved_games_scroll_test(NW, 2)) passed_counter++;
evanso 67:a2984682d641 288
evanso 82:3211b31e9421 289 // Prints results
evanso 67:a2984682d641 290 printf ("\nsaved_games_scroll_test passed %d tests out of 9\n\n\n",
evanso 67:a2984682d641 291 passed_counter);
evanso 67:a2984682d641 292 }
evanso 67:a2984682d641 293
evanso 82:3211b31e9421 294 void run_display_saved_games_test() {
evanso 67:a2984682d641 295 printf ("\nTesting display_saved_games_test() \n\n");
evanso 67:a2984682d641 296 int passed_counter = 0;
evanso 67:a2984682d641 297
evanso 85:87bc28b151d8 298 // Runs test with all different possible inputs
evanso 67:a2984682d641 299 if (display_saved_games_test(1, 41, 18 )) passed_counter++;
evanso 67:a2984682d641 300 if (display_saved_games_test(1, 41, 34)) passed_counter++;
evanso 67:a2984682d641 301 if (display_saved_games_test(1, 9, 1)) passed_counter++;
evanso 67:a2984682d641 302 if (display_saved_games_test(0, 0, 0)) passed_counter++;
evanso 67:a2984682d641 303
evanso 82:3211b31e9421 304 // Prints results
evanso 67:a2984682d641 305 printf ("\ndisplay_saved_games_test %d tests out of 4\n\n\n",
evanso 67:a2984682d641 306 passed_counter);
evanso 67:a2984682d641 307 }
evanso 67:a2984682d641 308
evanso 82:3211b31e9421 309 void run_save_game_screen_test() {
evanso 67:a2984682d641 310 printf ("\nTesting save_game_screen_test() \n\n");
evanso 67:a2984682d641 311 int passed_counter = 0;
evanso 67:a2984682d641 312
evanso 85:87bc28b151d8 313 // Runs test with all different possible inputs
evanso 67:a2984682d641 314 if (save_game_screen_test(1, 41, 18 )) passed_counter++;
evanso 67:a2984682d641 315 if (save_game_screen_test(1, 41, 34)) passed_counter++;
evanso 67:a2984682d641 316 if (save_game_screen_test(1, 3, 1)) passed_counter++;
evanso 67:a2984682d641 317 if (save_game_screen_test(0, 0, 0)) passed_counter++;
evanso 67:a2984682d641 318
evanso 82:3211b31e9421 319 // Prints results
evanso 70:8c4572d17441 320 printf ("\nsave_game_screen_test %d tests out of 4\n\n\n",
evanso 67:a2984682d641 321 passed_counter);
evanso 67:a2984682d641 322 }
evanso 67:a2984682d641 323
evanso 67:a2984682d641 324
evanso 70:8c4572d17441 325
evanso 70:8c4572d17441 326 // Settings tests --------------------------------------------------------------
evanso 70:8c4572d17441 327
evanso 82:3211b31e9421 328 void run_settings_select_part_test() {
evanso 70:8c4572d17441 329 printf ("\nTesting settings_select_part_test() \n\n");
evanso 70:8c4572d17441 330 int passed_counter = 0;
evanso 70:8c4572d17441 331
evanso 85:87bc28b151d8 332 // Runs test with all different possible inputs
evanso 70:8c4572d17441 333 if (settings_select_part_test(acc,1)) passed_counter++;
evanso 70:8c4572d17441 334 if (settings_select_part_test(joy,0)) passed_counter++;
evanso 70:8c4572d17441 335
evanso 82:3211b31e9421 336 // Prints results
evanso 70:8c4572d17441 337 printf ("\nsettings_select_part_test passed %d tests out of 2\n\n\n",
evanso 70:8c4572d17441 338 passed_counter);
evanso 70:8c4572d17441 339 }
evanso 70:8c4572d17441 340
evanso 82:3211b31e9421 341 void run_settings_scroll_test() {
evanso 70:8c4572d17441 342 printf ("\nsettings_scroll_test() \n\n");
evanso 70:8c4572d17441 343 int passed_counter = 0;
evanso 70:8c4572d17441 344
evanso 85:87bc28b151d8 345 // Runs test with all different possible inputs
evanso 70:8c4572d17441 346 if (settings_scroll_test(CENTRE, controls)) passed_counter++;
evanso 70:8c4572d17441 347 if (settings_scroll_test(N, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 348 if (settings_scroll_test(NE, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 349 if (settings_scroll_test(E, controls)) passed_counter++;
evanso 70:8c4572d17441 350 if (settings_scroll_test(SE, contrast)) passed_counter++;
evanso 70:8c4572d17441 351 if (settings_scroll_test(S, contrast)) passed_counter++;
evanso 70:8c4572d17441 352 if (settings_scroll_test(SW, contrast)) passed_counter++;
evanso 70:8c4572d17441 353 if (settings_scroll_test(W, controls)) passed_counter++;
evanso 70:8c4572d17441 354 if (settings_scroll_test(NW, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 355
evanso 82:3211b31e9421 356 // Prints results
evanso 70:8c4572d17441 357 printf ("\nsettings_scroll_test passed %d tests out of 9\n\n\n",
evanso 70:8c4572d17441 358 passed_counter);
evanso 70:8c4572d17441 359 }
evanso 70:8c4572d17441 360
evanso 82:3211b31e9421 361 void run_display_settings_screen_test() {
evanso 79:66bcf8fa2d2d 362 printf ("\ndisplay_settings_screen_test() \n\n");
evanso 70:8c4572d17441 363 int passed_counter = 0;
evanso 70:8c4572d17441 364
evanso 85:87bc28b151d8 365 // Runs test with all different possible inputs
evanso 70:8c4572d17441 366 if (display_settings_screen_test(1, 41, 18 )) passed_counter++;
evanso 70:8c4572d17441 367 if (display_settings_screen_test(1, 41, 34)) passed_counter++;
evanso 70:8c4572d17441 368 if (display_settings_screen_test(0, 9, 1)) passed_counter++;
evanso 70:8c4572d17441 369 if (display_settings_screen_test(0, 0, 0)) passed_counter++;
evanso 70:8c4572d17441 370
evanso 82:3211b31e9421 371 // Prints results
evanso 70:8c4572d17441 372 printf ("\ndisplay_settings_screen_test %d tests out of 4\n\n\n",
evanso 70:8c4572d17441 373 passed_counter);
evanso 70:8c4572d17441 374 }
evanso 70:8c4572d17441 375
evanso 79:66bcf8fa2d2d 376
evanso 79:66bcf8fa2d2d 377
evanso 79:66bcf8fa2d2d 378
evanso 79:66bcf8fa2d2d 379 // High Score tests ------------------------------------------------------------
evanso 79:66bcf8fa2d2d 380
evanso 82:3211b31e9421 381 void run_no_high_scores_test() {
evanso 79:66bcf8fa2d2d 382 printf ("\nno_high_scores_test_test() \n\n");
evanso 79:66bcf8fa2d2d 383 int passed_counter = 0;
evanso 79:66bcf8fa2d2d 384
evanso 85:87bc28b151d8 385 // Runs test with all different possible inputs
evanso 79:66bcf8fa2d2d 386 if (no_high_scores_test(1, 0, 27)) passed_counter++;
evanso 79:66bcf8fa2d2d 387 if (no_high_scores_test(1, 3, 35)) passed_counter++;
evanso 79:66bcf8fa2d2d 388 if (no_high_scores_test(0, 9, 1)) passed_counter++;
evanso 79:66bcf8fa2d2d 389 if (no_high_scores_test(0, 0, 0)) passed_counter++;
evanso 79:66bcf8fa2d2d 390
evanso 82:3211b31e9421 391 // Prints results
evanso 79:66bcf8fa2d2d 392 printf ("\nno_high_scores_test %d tests out of 4\n\n\n",
evanso 79:66bcf8fa2d2d 393 passed_counter);
evanso 79:66bcf8fa2d2d 394 }
evanso 79:66bcf8fa2d2d 395
evanso 79:66bcf8fa2d2d 396
evanso 83:35d1e846eab2 397
evanso 83:35d1e846eab2 398
evanso 83:35d1e846eab2 399 // Play Engine tests -----------------------------------------------------------
evanso 83:35d1e846eab2 400
evanso 83:35d1e846eab2 401 void run_read_accelerometer_direction_test() {
evanso 83:35d1e846eab2 402 printf ("\nread_accelerometer_direction_test() \n\n");
evanso 83:35d1e846eab2 403 int passed_counter = 0;
evanso 83:35d1e846eab2 404
evanso 85:87bc28b151d8 405 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 406 if (read_accelerometer_direction_test(CENTRE,5,-40 )) passed_counter++;
evanso 83:35d1e846eab2 407 if (read_accelerometer_direction_test(N, 5,-10)) passed_counter++;
evanso 83:35d1e846eab2 408 if (read_accelerometer_direction_test(NE, 20, -10)) passed_counter++;
evanso 83:35d1e846eab2 409 if (read_accelerometer_direction_test(E, 20,-40)) passed_counter++;
evanso 83:35d1e846eab2 410 if (read_accelerometer_direction_test(SE, 20,-60)) passed_counter++;
evanso 83:35d1e846eab2 411 if (read_accelerometer_direction_test(S, 5,-60)) passed_counter++;
evanso 83:35d1e846eab2 412 if (read_accelerometer_direction_test(SW, -20,-60)) passed_counter++;
evanso 83:35d1e846eab2 413 if (read_accelerometer_direction_test(W, -40, -40)) passed_counter++;
evanso 83:35d1e846eab2 414 if (read_accelerometer_direction_test(NW, -15, -10)) passed_counter++;
evanso 83:35d1e846eab2 415
evanso 83:35d1e846eab2 416 // Prints results
evanso 83:35d1e846eab2 417 printf ("\nread_accelerometer_direction_test passed %d tests out of 9\n\n\n"
evanso 83:35d1e846eab2 418 ,passed_counter);
evanso 83:35d1e846eab2 419 }
evanso 83:35d1e846eab2 420
evanso 83:35d1e846eab2 421 void run_spawn_aliens_test() {
evanso 83:35d1e846eab2 422 printf ("\nspawn_aliens_test() \n\n");
evanso 83:35d1e846eab2 423 int passed_counter = 0;
evanso 83:35d1e846eab2 424
evanso 85:87bc28b151d8 425 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 426 if (spawn_aliens_test(1)) passed_counter++;
evanso 83:35d1e846eab2 427 if (spawn_aliens_test(3)) passed_counter++;
evanso 83:35d1e846eab2 428 if (spawn_aliens_test(5)) passed_counter++;
evanso 83:35d1e846eab2 429 if (spawn_aliens_test(10)) passed_counter++;
evanso 83:35d1e846eab2 430 if (spawn_aliens_test(20)) passed_counter++;
evanso 83:35d1e846eab2 431
evanso 83:35d1e846eab2 432 // Prints results
evanso 83:35d1e846eab2 433 printf ("\nspawn_aliens_test passed %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 434 ,passed_counter);
evanso 83:35d1e846eab2 435 }
evanso 83:35d1e846eab2 436
evanso 83:35d1e846eab2 437 void run_create_alien_test() {
evanso 83:35d1e846eab2 438 printf ("\ncreate_aliens_test() \n\n");
evanso 83:35d1e846eab2 439 int passed_counter = 0;
evanso 83:35d1e846eab2 440
evanso 85:87bc28b151d8 441 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 442 if (create_alien_test(2)) passed_counter++;
evanso 83:35d1e846eab2 443 if (create_alien_test(4)) passed_counter++;
evanso 83:35d1e846eab2 444 if (create_alien_test(6)) passed_counter++;
evanso 83:35d1e846eab2 445 if (create_alien_test(15)) passed_counter++;
evanso 83:35d1e846eab2 446 if (create_alien_test(30)) passed_counter++;
evanso 83:35d1e846eab2 447
evanso 83:35d1e846eab2 448 // Prints results
evanso 83:35d1e846eab2 449 printf ("\ncreate_aliens_test() %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 450 ,passed_counter);
evanso 83:35d1e846eab2 451 }
evanso 83:35d1e846eab2 452
evanso 83:35d1e846eab2 453 void run_create_explosion_test() {
evanso 83:35d1e846eab2 454 printf ("\ncreate_explosion_test() \n\n");
evanso 83:35d1e846eab2 455 int passed_counter = 0;
evanso 83:35d1e846eab2 456
evanso 85:87bc28b151d8 457 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 458 if (create_explosion_test(3)) passed_counter++;
evanso 83:35d1e846eab2 459 if (create_explosion_test(6)) passed_counter++;
evanso 83:35d1e846eab2 460 if (create_explosion_test(9)) passed_counter++;
evanso 83:35d1e846eab2 461 if (create_explosion_test(1)) passed_counter++;
evanso 83:35d1e846eab2 462 if (create_explosion_test(22)) passed_counter++;
evanso 83:35d1e846eab2 463
evanso 83:35d1e846eab2 464 // Prints results
evanso 83:35d1e846eab2 465 printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 466 ,passed_counter);
evanso 83:35d1e846eab2 467 }
evanso 83:35d1e846eab2 468 void run_draw_explosions_test() {
evanso 83:35d1e846eab2 469 printf ("\ndraw_explosions_test() \n\n");
evanso 83:35d1e846eab2 470 int passed_counter = 0;
evanso 83:35d1e846eab2 471
evanso 85:87bc28b151d8 472 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 473 if (draw_explosions_test(1,32,33)) passed_counter++;
evanso 83:35d1e846eab2 474 if (draw_explosions_test(0,100,20)) passed_counter++;
evanso 83:35d1e846eab2 475 if (draw_explosions_test(1,1,20)) passed_counter++;
evanso 83:35d1e846eab2 476 if (draw_explosions_test(1,1,44)) passed_counter++;
evanso 83:35d1e846eab2 477 if (draw_explosions_test(1,78,1)) passed_counter++;
evanso 83:35d1e846eab2 478
evanso 83:35d1e846eab2 479 // Prints results
evanso 83:35d1e846eab2 480 printf ("\ncreate_explosion_test() %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 481 ,passed_counter);
evanso 83:35d1e846eab2 482 }
evanso 83:35d1e846eab2 483
evanso 83:35d1e846eab2 484 void run_spawn_people_test() {
evanso 83:35d1e846eab2 485 printf ("\nspawn_people_test() \n\n");
evanso 83:35d1e846eab2 486 int passed_counter = 0;
evanso 83:35d1e846eab2 487
evanso 85:87bc28b151d8 488 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 489 if (spawn_people_test(1)) passed_counter++;
evanso 83:35d1e846eab2 490 if (spawn_people_test(2)) passed_counter++;
evanso 83:35d1e846eab2 491 if (spawn_people_test(3)) passed_counter++;
evanso 83:35d1e846eab2 492 if (spawn_people_test(4)) passed_counter++;
evanso 83:35d1e846eab2 493 if (spawn_people_test(5)) passed_counter++;
evanso 83:35d1e846eab2 494
evanso 83:35d1e846eab2 495 // Prints results
evanso 83:35d1e846eab2 496 printf ("\nspawn_people_test passed %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 497 ,passed_counter);
evanso 83:35d1e846eab2 498 }
evanso 83:35d1e846eab2 499
evanso 83:35d1e846eab2 500 void run_people_alien_test() {
evanso 83:35d1e846eab2 501 printf ("\ncreate_people_test() \n\n");
evanso 83:35d1e846eab2 502 int passed_counter = 0;
evanso 83:35d1e846eab2 503
evanso 85:87bc28b151d8 504 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 505 if (create_people_test(1)) passed_counter++;
evanso 83:35d1e846eab2 506 if (create_people_test(2)) passed_counter++;
evanso 83:35d1e846eab2 507 if (create_people_test(3)) passed_counter++;
evanso 83:35d1e846eab2 508 if (create_people_test(4)) passed_counter++;
evanso 83:35d1e846eab2 509 if (create_people_test(5)) passed_counter++;
evanso 83:35d1e846eab2 510
evanso 83:35d1e846eab2 511 // Prints results
evanso 83:35d1e846eab2 512 printf ("\ncreate_people_test() %d tests out of 5\n\n\n"
evanso 83:35d1e846eab2 513 ,passed_counter);
evanso 83:35d1e846eab2 514 }
evanso 83:35d1e846eab2 515
evanso 83:35d1e846eab2 516 void run_reset_map_timer_test() {
evanso 83:35d1e846eab2 517 printf ("\nreset_map_timer_test() \n\n");
evanso 83:35d1e846eab2 518 int passed_counter = 0;
evanso 83:35d1e846eab2 519
evanso 85:87bc28b151d8 520 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 521 if (reset_map_timer_test(CENTRE, true)) passed_counter++;
evanso 83:35d1e846eab2 522 if (reset_map_timer_test(N, false)) passed_counter++;
evanso 83:35d1e846eab2 523
evanso 83:35d1e846eab2 524 // Prints results
evanso 83:35d1e846eab2 525 printf ("\nreset_map_timer_test() %d tests out of 2\n\n\n"
evanso 83:35d1e846eab2 526 ,passed_counter);
evanso 83:35d1e846eab2 527 }
evanso 83:35d1e846eab2 528
evanso 83:35d1e846eab2 529 void run_reset_map_test() {
evanso 83:35d1e846eab2 530 printf ("\nreset_map_test() \n\n");
evanso 83:35d1e846eab2 531 int passed_counter = 0;
evanso 83:35d1e846eab2 532
evanso 85:87bc28b151d8 533 // Runs test with all different possible inputs
evanso 83:35d1e846eab2 534 if (reset_map_test()) passed_counter++;
evanso 83:35d1e846eab2 535
evanso 83:35d1e846eab2 536 // Prints results
evanso 83:35d1e846eab2 537 printf ("\nreset_map_test() %d tests out of 1\n\n\n"
evanso 83:35d1e846eab2 538 ,passed_counter);
evanso 83:35d1e846eab2 539 }
evanso 85:87bc28b151d8 540 #endif