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:
Mon May 25 18:39:51 2020 +0000
Revision:
82:3211b31e9421
Parent:
79:66bcf8fa2d2d
Child:
83:35d1e846eab2
Made commenting and formatting of code more consistent.

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 11:ab578a151f67 16
evanso 11:ab578a151f67 17 /** Test
evanso 27:8bb2bd97c319 18 * @brief Runs all tests for game
evanso 27:8bb2bd97c319 19 * @author Benjamin Evans, University of Leeds
evanso 27:8bb2bd97c319 20 * @date April 2020
evanso 27:8bb2bd97c319 21 */
evanso 13:12276eed13ac 22 // Spaceship tests -------------------------------------------------------------
evanso 65:daa792a09e1f 23
evanso 82:3211b31e9421 24 void run_spaceship_movement_tests() {
evanso 13:12276eed13ac 25 printf ("\nTesting spaceship_movement_test() \n");
evanso 13:12276eed13ac 26 int passed_counter = 0;
evanso 13:12276eed13ac 27
evanso 13:12276eed13ac 28 // Runs test with all posible movment directions
evanso 13:12276eed13ac 29 if (spaceship_movement_test(CENTRE, 36, 22)) passed_counter++;
evanso 13:12276eed13ac 30 if (spaceship_movement_test(N, 36, 21)) passed_counter++;
evanso 16:1ee3d3804557 31 if (spaceship_movement_test(NE, 35, 21)) passed_counter++;
evanso 16:1ee3d3804557 32 if (spaceship_movement_test(E, 35, 22)) passed_counter++;
evanso 16:1ee3d3804557 33 if (spaceship_movement_test(SE, 35, 23)) passed_counter++;
evanso 13:12276eed13ac 34 if (spaceship_movement_test(S, 36, 23)) passed_counter++;
evanso 16:1ee3d3804557 35 if (spaceship_movement_test(SW, 37, 23)) passed_counter++;
evanso 16:1ee3d3804557 36 if (spaceship_movement_test(W, 37, 22)) passed_counter++;
evanso 16:1ee3d3804557 37 if (spaceship_movement_test(NW, 37, 21)) passed_counter++;
evanso 11:ab578a151f67 38
evanso 82:3211b31e9421 39 // Prints results
evanso 37:a05eac7fcb4c 40 printf ("\nspaceship_movement_test passed %d tests out of 9\n\n\n",
evanso 27:8bb2bd97c319 41 passed_counter);
evanso 12:1c0b6796aaca 42 }
evanso 12:1c0b6796aaca 43
evanso 82:3211b31e9421 44 void run_spaceship_draw_tests() {
evanso 37:a05eac7fcb4c 45 printf ("\nTesting spaceship_draw_tests() \n\n");
evanso 13:12276eed13ac 46 int passed_counter = 0;
evanso 12:1c0b6796aaca 47
evanso 13:12276eed13ac 48 // Runs test with max movement directions
evanso 65:daa792a09e1f 49 if (spaceship_draw_test(NE, 1, 15, 9)) passed_counter++;
evanso 16:1ee3d3804557 50 if (spaceship_draw_test(SE, 1, 15, 44)) passed_counter++;
evanso 16:1ee3d3804557 51 if (spaceship_draw_test(SW, 1, 64, 44)) passed_counter++;
evanso 65:daa792a09e1f 52 if (spaceship_draw_test(NW, 1, 64, 9)) passed_counter++;
evanso 13:12276eed13ac 53
evanso 82:3211b31e9421 54 // Prints results
evanso 37:a05eac7fcb4c 55 printf ("\nspaceship_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 11:ab578a151f67 56 }
evanso 11:ab578a151f67 57
evanso 65:daa792a09e1f 58
evanso 65:daa792a09e1f 59
evanso 13:12276eed13ac 60 // Map tests -------------------------------------------------------------------
evanso 13:12276eed13ac 61
evanso 82:3211b31e9421 62 void run_map_draw_tests() {
evanso 37:a05eac7fcb4c 63 printf ("\nTesting map_draw_tests() \n\n");
evanso 14:7419c680656f 64 int passed_counter = 0;
evanso 14:7419c680656f 65
evanso 14:7419c680656f 66 // Runs multiple map tests
evanso 18:11068b98e261 67 if (map_move_test(CENTRE, -84)) passed_counter++;
evanso 18:11068b98e261 68 if (map_move_test(N, -84)) passed_counter++;
evanso 18:11068b98e261 69 if (map_move_test(NE,-86)) passed_counter++;
evanso 18:11068b98e261 70 if (map_move_test(E, -86)) passed_counter++;
evanso 18:11068b98e261 71 if (map_move_test(SE, -86)) passed_counter++;
evanso 18:11068b98e261 72 if (map_move_test(S, -84)) passed_counter++;
evanso 18:11068b98e261 73 if (map_move_test(SW, -82)) passed_counter++;
evanso 18:11068b98e261 74 if (map_move_test(W, -82)) passed_counter++;
evanso 18:11068b98e261 75 if (map_move_test(NW, -82)) passed_counter++;
evanso 14:7419c680656f 76
evanso 82:3211b31e9421 77 // Prints results
evanso 37:a05eac7fcb4c 78 printf ("\nmap_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 14:7419c680656f 79 }
evanso 13:12276eed13ac 80
evanso 65:daa792a09e1f 81
evanso 65:daa792a09e1f 82
evanso 22:053c11a202e1 83 // Alien tests -----------------------------------------------------------------
evanso 65:daa792a09e1f 84
evanso 82:3211b31e9421 85 void run_alien_draw_tests() {
evanso 37:a05eac7fcb4c 86 printf ("\nTesting alien_draw_test() \n\n");
evanso 22:053c11a202e1 87 int passed_counter = 0;
evanso 22:053c11a202e1 88
evanso 22:053c11a202e1 89 // Runs test with all posible movment directions
evanso 37:a05eac7fcb4c 90 if (alien_draw_test(1,CENTRE, 1, 1)) passed_counter++;
evanso 37:a05eac7fcb4c 91 if (alien_draw_test(1,N, 43, 20)) passed_counter++;
evanso 37:a05eac7fcb4c 92 if (alien_draw_test(0,NE, -23, 6)) passed_counter++;
evanso 37:a05eac7fcb4c 93 if (alien_draw_test(0,E, 23, -34)) passed_counter++;
evanso 37:a05eac7fcb4c 94 if (alien_draw_test(0,SE, -23, -43)) passed_counter++;
evanso 37:a05eac7fcb4c 95 if (alien_draw_test(0,S, 100, 26)) passed_counter++;
evanso 37:a05eac7fcb4c 96 if (alien_draw_test(0,SE, 40, 100)) passed_counter++;
evanso 37:a05eac7fcb4c 97 if (alien_draw_test(1,E, 70, 5)) passed_counter++;
evanso 37:a05eac7fcb4c 98 if (alien_draw_test(1,NE, 6, 44)) passed_counter++;
evanso 22:053c11a202e1 99
evanso 82:3211b31e9421 100 // Prints results
evanso 37:a05eac7fcb4c 101 printf ("\nalien_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 22:053c11a202e1 102 }
evanso 22:053c11a202e1 103
evanso 82:3211b31e9421 104 void run_check_collision_test() {
evanso 37:a05eac7fcb4c 105 printf ("\nTesting alien_collision_test() \n\n");
evanso 22:053c11a202e1 106 int passed_counter = 0;
evanso 22:053c11a202e1 107
evanso 22:053c11a202e1 108 // Runs test with all differnt possible inputs
evanso 38:75bd968daa31 109 if (check_collision_test(1, 1, 10,22)) passed_counter++;
evanso 38:75bd968daa31 110 if (check_collision_test(0, 1, 28,40)) passed_counter++;
evanso 38:75bd968daa31 111 if (check_collision_test(1, 0, 11,22)) passed_counter++;
evanso 38:75bd968daa31 112 if (check_collision_test(0, 0, 20,22)) passed_counter++;
evanso 22:053c11a202e1 113
evanso 82:3211b31e9421 114 // Prints results
evanso 37:a05eac7fcb4c 115 printf ("\nalien_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 22:053c11a202e1 116 }
evanso 15:90b6821bcf64 117
evanso 65:daa792a09e1f 118
evanso 27:8bb2bd97c319 119 // Weapons tests ---------------------------------------------------------------
evanso 65:daa792a09e1f 120
evanso 82:3211b31e9421 121 void run_weapons_draw_tests() {
evanso 37:a05eac7fcb4c 122 printf ("\nTesting spaceship_draw_tests() \n\n");
evanso 23:cc44e26c08fa 123 int passed_counter = 0;
evanso 23:cc44e26c08fa 124
evanso 23:cc44e26c08fa 125 // Runs test with max movement directions
evanso 23:cc44e26c08fa 126 if (weapons_draw_test(1, 1, 1, 49, 24)) passed_counter++;
evanso 23:cc44e26c08fa 127 if (weapons_draw_test(1, 1, 2, 52, 24)) passed_counter++;
evanso 23:cc44e26c08fa 128 if (weapons_draw_test(0, 1, 2, 49, 24)) passed_counter++;
evanso 23:cc44e26c08fa 129 if (weapons_draw_test(1, 0, 1, 36, 24)) passed_counter++;
evanso 23:cc44e26c08fa 130 if (weapons_draw_test(1, 0, 2, 33, 24)) passed_counter++;
evanso 23:cc44e26c08fa 131 if (weapons_draw_test(0, 0, 2, 33, 24)) passed_counter++;
evanso 23:cc44e26c08fa 132
evanso 82:3211b31e9421 133 // Prints results
evanso 37:a05eac7fcb4c 134 printf ("\nspaceship_draw_test passed %d tests out of 6\n\n\n",passed_counter);
evanso 23:cc44e26c08fa 135 }
evanso 26:1a7056eb3253 136
evanso 65:daa792a09e1f 137
evanso 65:daa792a09e1f 138
evanso 27:8bb2bd97c319 139 // Explosion tests -------------------------------------------------------------
evanso 65:daa792a09e1f 140
evanso 82:3211b31e9421 141 void run_explosion_draw_tests() {
evanso 37:a05eac7fcb4c 142 printf ("\nTesting explosion_draw_tests() \n\n");
evanso 26:1a7056eb3253 143 int passed_counter = 0;
evanso 26:1a7056eb3253 144
evanso 26:1a7056eb3253 145 // Runs test with max movement directions
evanso 26:1a7056eb3253 146 if (explosion_draw_test(1, 15, 3)) passed_counter++;
evanso 26:1a7056eb3253 147 if (explosion_draw_test(1, 15, 44)) passed_counter++;
evanso 26:1a7056eb3253 148 if (explosion_draw_test(1, 64, 44)) passed_counter++;
evanso 26:1a7056eb3253 149 if (explosion_draw_test(1, 64, 2)) passed_counter++;
evanso 26:1a7056eb3253 150
evanso 82:3211b31e9421 151 // Prints results
evanso 37:a05eac7fcb4c 152 printf ("\nspaceship_draw_test passed %d tests out of 4\n\n\n",passed_counter);
evanso 37:a05eac7fcb4c 153 }
evanso 37:a05eac7fcb4c 154
evanso 65:daa792a09e1f 155
evanso 65:daa792a09e1f 156
evanso 37:a05eac7fcb4c 157 // People tests ----------------------------------------------------------------
evanso 37:a05eac7fcb4c 158
evanso 82:3211b31e9421 159 void run_people_draw_tests() {
evanso 37:a05eac7fcb4c 160 printf ("\nTesting people_draw_tests() \n\n");
evanso 37:a05eac7fcb4c 161 int passed_counter = 0;
evanso 37:a05eac7fcb4c 162
evanso 37:a05eac7fcb4c 163 // Runs test with max movement directions
evanso 37:a05eac7fcb4c 164 if (people_draw_test(CENTRE, 1,44)) passed_counter++;
evanso 37:a05eac7fcb4c 165 if (people_draw_test(N, 0,100)) passed_counter++;
evanso 37:a05eac7fcb4c 166 if (people_draw_test(NE, 0, -100)) passed_counter++;
evanso 37:a05eac7fcb4c 167 if (people_draw_test(E, 1,0)) passed_counter++;
evanso 37:a05eac7fcb4c 168 if (people_draw_test(SE, 1,82)) passed_counter++;
evanso 37:a05eac7fcb4c 169 if (people_draw_test(S, 1,43)) passed_counter++;
evanso 37:a05eac7fcb4c 170 if (people_draw_test(SW, 0,-64)) passed_counter++;
evanso 37:a05eac7fcb4c 171 if (people_draw_test(W, 0,-6)) passed_counter++;
evanso 37:a05eac7fcb4c 172 if (people_draw_test(NW, 0,84)) passed_counter++;
evanso 37:a05eac7fcb4c 173
evanso 82:3211b31e9421 174 // Prints results
evanso 37:a05eac7fcb4c 175 printf ("\npeople_draw_test passed %d tests out of 9\n\n\n",passed_counter);
evanso 26:1a7056eb3253 176 }
evanso 27:8bb2bd97c319 177
evanso 82:3211b31e9421 178 void run_check_alien_collision_test() {
evanso 38:75bd968daa31 179 printf ("\nTesting check_alien_collision_test() \n\n");
evanso 38:75bd968daa31 180 int passed_counter = 0;
evanso 38:75bd968daa31 181
evanso 38:75bd968daa31 182 // Runs test with all differnt possible inputs
evanso 38:75bd968daa31 183 if (check_alien_collision_test(1,1)) passed_counter++;
evanso 38:75bd968daa31 184 if (check_alien_collision_test(1,80)) passed_counter++;
evanso 38:75bd968daa31 185 if (check_alien_collision_test(1,-42)) passed_counter++;
evanso 38:75bd968daa31 186 if (check_alien_collision_test(1,100)) passed_counter++;
evanso 38:75bd968daa31 187
evanso 82:3211b31e9421 188 // Prints results
evanso 65:daa792a09e1f 189 printf ("\ncheck_alien_collision_test passed %d tests out of 4\n\n\n",
evanso 65:daa792a09e1f 190 passed_counter);
evanso 65:daa792a09e1f 191 }
evanso 65:daa792a09e1f 192
evanso 65:daa792a09e1f 193
evanso 65:daa792a09e1f 194
evanso 65:daa792a09e1f 195 // Menu tests ------------------------------------------------------------------
evanso 65:daa792a09e1f 196
evanso 82:3211b31e9421 197 void run_menu_select_part_test() {
evanso 65:daa792a09e1f 198 printf ("\nTesting menu_select_part_test() \n\n");
evanso 65:daa792a09e1f 199 int passed_counter = 0;
evanso 65:daa792a09e1f 200
evanso 65:daa792a09e1f 201 // Runs test with all differnt possible inputs
evanso 65:daa792a09e1f 202 if (menu_select_part_test(play,1)) passed_counter++;
evanso 65:daa792a09e1f 203 if (menu_select_part_test(main_menu,0)) passed_counter++;
evanso 65:daa792a09e1f 204
evanso 82:3211b31e9421 205 // Prints results
evanso 65:daa792a09e1f 206 printf ("\nmenu_select_part_test passed %d tests out of 2\n\n\n",
evanso 65:daa792a09e1f 207 passed_counter);
evanso 65:daa792a09e1f 208 }
evanso 65:daa792a09e1f 209
evanso 82:3211b31e9421 210 void run_menu_scroll_test() {
evanso 65:daa792a09e1f 211 printf ("\nTesting menu_scroll_test() \n\n");
evanso 65:daa792a09e1f 212 int passed_counter = 0;
evanso 65:daa792a09e1f 213
evanso 65:daa792a09e1f 214 // Runs test with all differnt possible inputs
evanso 65:daa792a09e1f 215 if (menu_scroll_test(CENTRE, play)) passed_counter++;
evanso 65:daa792a09e1f 216 if (menu_scroll_test(N, settings)) passed_counter++;
evanso 65:daa792a09e1f 217 if (menu_scroll_test(NE, settings)) passed_counter++;
evanso 65:daa792a09e1f 218 if (menu_scroll_test(E, play)) passed_counter++;
evanso 79:66bcf8fa2d2d 219 if (menu_scroll_test(SE, high_score)) passed_counter++;
evanso 79:66bcf8fa2d2d 220 if (menu_scroll_test(S, high_score)) passed_counter++;
evanso 79:66bcf8fa2d2d 221 if (menu_scroll_test(SW, high_score)) passed_counter++;
evanso 65:daa792a09e1f 222 if (menu_scroll_test(W, play)) passed_counter++;
evanso 65:daa792a09e1f 223 if (menu_scroll_test(NW, settings)) passed_counter++;
evanso 65:daa792a09e1f 224
evanso 82:3211b31e9421 225 // Prints results
evanso 65:daa792a09e1f 226 printf ("\nmenu_scroll_test passed %d tests out of 9\n\n\n",
evanso 65:daa792a09e1f 227 passed_counter);
evanso 38:75bd968daa31 228 }
evanso 38:75bd968daa31 229
evanso 82:3211b31e9421 230 void run_menu_draw_part_test() {
evanso 70:8c4572d17441 231 printf ("\nmenu_draw_part_test() \n\n");
evanso 70:8c4572d17441 232 int passed_counter = 0;
evanso 70:8c4572d17441 233
evanso 70:8c4572d17441 234 // Runs test with all differnt possible inputs
evanso 70:8c4572d17441 235 if (menu_draw_part_test(1, 42, 27)) passed_counter++;
evanso 70:8c4572d17441 236 if (menu_draw_part_test(1, 41, 43)) passed_counter++;
evanso 70:8c4572d17441 237 if (menu_draw_part_test(0, 9, 1)) passed_counter++;
evanso 70:8c4572d17441 238 if (menu_draw_part_test(0, 0, 0)) passed_counter++;
evanso 70:8c4572d17441 239
evanso 82:3211b31e9421 240 // Prints results
evanso 70:8c4572d17441 241 printf ("\nmenu_draw_part_test %d tests out of 4\n\n\n",
evanso 70:8c4572d17441 242 passed_counter);
evanso 70:8c4572d17441 243 }
evanso 70:8c4572d17441 244
evanso 70:8c4572d17441 245
evanso 66:33f479036a5d 246
evanso 66:33f479036a5d 247
evanso 66:33f479036a5d 248 // HUD tests -------------------------------------------------------------------
evanso 66:33f479036a5d 249
evanso 82:3211b31e9421 250 void run_HUD_draw_test() {
evanso 66:33f479036a5d 251 printf ("\nTesting HUD_draw_test() \n\n");
evanso 66:33f479036a5d 252 int passed_counter = 0;
evanso 66:33f479036a5d 253
evanso 66:33f479036a5d 254 // Runs test with all differnt possible inputs
evanso 66:33f479036a5d 255 if (HUD_draw_test(3, 0, 4, 1, 3, 3)) passed_counter++;
evanso 66:33f479036a5d 256 if (HUD_draw_test(3, 0, 4, 1, 12, 3)) passed_counter++;
evanso 66:33f479036a5d 257 if (HUD_draw_test(1, 0, 4, 0, 12, 3)) passed_counter++;
evanso 66:33f479036a5d 258 if (HUD_draw_test(3, 0, 4, 1, 62, 3)) passed_counter++;
evanso 66:33f479036a5d 259 if (HUD_draw_test(3, 0, 3, 0, 62, 3)) passed_counter++;
evanso 66:33f479036a5d 260 if (HUD_draw_test(3, 0, 3, 1, 30, 3)) passed_counter++;
evanso 66:33f479036a5d 261 if (HUD_draw_test(3, 1111, 3, 00, 30, 3)) passed_counter++;
evanso 66:33f479036a5d 262
evanso 82:3211b31e9421 263 // Prints results
evanso 66:33f479036a5d 264 printf ("\nHUD_draw_test passed %d tests out of 7\n\n\n",
evanso 66:33f479036a5d 265 passed_counter);
evanso 66:33f479036a5d 266 }
evanso 66:33f479036a5d 267
evanso 70:8c4572d17441 268
evanso 70:8c4572d17441 269
evanso 70:8c4572d17441 270
evanso 67:a2984682d641 271 // Saved Games tests -----------------------------------------------------------
evanso 67:a2984682d641 272
evanso 82:3211b31e9421 273 void run_saved_games_scroll_test() {
evanso 67:a2984682d641 274 printf ("\nsaved_games_scroll_test() \n\n");
evanso 67:a2984682d641 275 int passed_counter = 0;
evanso 67:a2984682d641 276
evanso 67:a2984682d641 277 // Runs test with all differnt possible inputs
evanso 67:a2984682d641 278 if (saved_games_scroll_test(CENTRE, 1)) passed_counter++;
evanso 67:a2984682d641 279 if (saved_games_scroll_test(N, 2)) passed_counter++;
evanso 67:a2984682d641 280 if (saved_games_scroll_test(NE, 2)) passed_counter++;
evanso 67:a2984682d641 281 if (saved_games_scroll_test(E, 1)) passed_counter++;
evanso 67:a2984682d641 282 if (saved_games_scroll_test(SE, 3)) passed_counter++;
evanso 67:a2984682d641 283 if (saved_games_scroll_test(S, 3)) passed_counter++;
evanso 67:a2984682d641 284 if (saved_games_scroll_test(SW, 3)) passed_counter++;
evanso 67:a2984682d641 285 if (saved_games_scroll_test(W, 1)) passed_counter++;
evanso 67:a2984682d641 286 if (saved_games_scroll_test(NW, 2)) passed_counter++;
evanso 67:a2984682d641 287
evanso 82:3211b31e9421 288 // Prints results
evanso 67:a2984682d641 289 printf ("\nsaved_games_scroll_test passed %d tests out of 9\n\n\n",
evanso 67:a2984682d641 290 passed_counter);
evanso 67:a2984682d641 291 }
evanso 67:a2984682d641 292
evanso 82:3211b31e9421 293 void run_display_saved_games_test() {
evanso 67:a2984682d641 294 printf ("\nTesting display_saved_games_test() \n\n");
evanso 67:a2984682d641 295 int passed_counter = 0;
evanso 67:a2984682d641 296
evanso 67:a2984682d641 297 // Runs test with all differnt possible inputs
evanso 67:a2984682d641 298 if (display_saved_games_test(1, 41, 18 )) passed_counter++;
evanso 67:a2984682d641 299 if (display_saved_games_test(1, 41, 34)) passed_counter++;
evanso 67:a2984682d641 300 if (display_saved_games_test(1, 9, 1)) passed_counter++;
evanso 67:a2984682d641 301 if (display_saved_games_test(0, 0, 0)) passed_counter++;
evanso 67:a2984682d641 302
evanso 82:3211b31e9421 303 // Prints results
evanso 67:a2984682d641 304 printf ("\ndisplay_saved_games_test %d tests out of 4\n\n\n",
evanso 67:a2984682d641 305 passed_counter);
evanso 67:a2984682d641 306 }
evanso 67:a2984682d641 307
evanso 82:3211b31e9421 308 void run_save_game_screen_test() {
evanso 67:a2984682d641 309 printf ("\nTesting save_game_screen_test() \n\n");
evanso 67:a2984682d641 310 int passed_counter = 0;
evanso 67:a2984682d641 311
evanso 67:a2984682d641 312 // Runs test with all differnt possible inputs
evanso 67:a2984682d641 313 if (save_game_screen_test(1, 41, 18 )) passed_counter++;
evanso 67:a2984682d641 314 if (save_game_screen_test(1, 41, 34)) passed_counter++;
evanso 67:a2984682d641 315 if (save_game_screen_test(1, 3, 1)) passed_counter++;
evanso 67:a2984682d641 316 if (save_game_screen_test(0, 0, 0)) passed_counter++;
evanso 67:a2984682d641 317
evanso 82:3211b31e9421 318 // Prints results
evanso 70:8c4572d17441 319 printf ("\nsave_game_screen_test %d tests out of 4\n\n\n",
evanso 67:a2984682d641 320 passed_counter);
evanso 67:a2984682d641 321 }
evanso 67:a2984682d641 322
evanso 67:a2984682d641 323
evanso 70:8c4572d17441 324
evanso 70:8c4572d17441 325 // Settings tests --------------------------------------------------------------
evanso 70:8c4572d17441 326
evanso 82:3211b31e9421 327 void run_settings_select_part_test() {
evanso 70:8c4572d17441 328 printf ("\nTesting settings_select_part_test() \n\n");
evanso 70:8c4572d17441 329 int passed_counter = 0;
evanso 70:8c4572d17441 330
evanso 70:8c4572d17441 331 // Runs test with all differnt possible inputs
evanso 70:8c4572d17441 332 if (settings_select_part_test(acc,1)) passed_counter++;
evanso 70:8c4572d17441 333 if (settings_select_part_test(joy,0)) passed_counter++;
evanso 70:8c4572d17441 334
evanso 82:3211b31e9421 335 // Prints results
evanso 70:8c4572d17441 336 printf ("\nsettings_select_part_test passed %d tests out of 2\n\n\n",
evanso 70:8c4572d17441 337 passed_counter);
evanso 70:8c4572d17441 338 }
evanso 70:8c4572d17441 339
evanso 82:3211b31e9421 340 void run_settings_scroll_test() {
evanso 70:8c4572d17441 341 printf ("\nsettings_scroll_test() \n\n");
evanso 70:8c4572d17441 342 int passed_counter = 0;
evanso 70:8c4572d17441 343
evanso 70:8c4572d17441 344 // Runs test with all differnt possible inputs
evanso 70:8c4572d17441 345 if (settings_scroll_test(CENTRE, controls)) passed_counter++;
evanso 70:8c4572d17441 346 if (settings_scroll_test(N, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 347 if (settings_scroll_test(NE, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 348 if (settings_scroll_test(E, controls)) passed_counter++;
evanso 70:8c4572d17441 349 if (settings_scroll_test(SE, contrast)) passed_counter++;
evanso 70:8c4572d17441 350 if (settings_scroll_test(S, contrast)) passed_counter++;
evanso 70:8c4572d17441 351 if (settings_scroll_test(SW, contrast)) passed_counter++;
evanso 70:8c4572d17441 352 if (settings_scroll_test(W, controls)) passed_counter++;
evanso 70:8c4572d17441 353 if (settings_scroll_test(NW, sound_fx)) passed_counter++;
evanso 70:8c4572d17441 354
evanso 82:3211b31e9421 355 // Prints results
evanso 70:8c4572d17441 356 printf ("\nsettings_scroll_test passed %d tests out of 9\n\n\n",
evanso 70:8c4572d17441 357 passed_counter);
evanso 70:8c4572d17441 358 }
evanso 70:8c4572d17441 359
evanso 82:3211b31e9421 360 void run_display_settings_screen_test() {
evanso 79:66bcf8fa2d2d 361 printf ("\ndisplay_settings_screen_test() \n\n");
evanso 70:8c4572d17441 362 int passed_counter = 0;
evanso 70:8c4572d17441 363
evanso 70:8c4572d17441 364 // Runs test with all differnt possible inputs
evanso 70:8c4572d17441 365 if (display_settings_screen_test(1, 41, 18 )) passed_counter++;
evanso 70:8c4572d17441 366 if (display_settings_screen_test(1, 41, 34)) passed_counter++;
evanso 70:8c4572d17441 367 if (display_settings_screen_test(0, 9, 1)) passed_counter++;
evanso 70:8c4572d17441 368 if (display_settings_screen_test(0, 0, 0)) passed_counter++;
evanso 70:8c4572d17441 369
evanso 82:3211b31e9421 370 // Prints results
evanso 70:8c4572d17441 371 printf ("\ndisplay_settings_screen_test %d tests out of 4\n\n\n",
evanso 70:8c4572d17441 372 passed_counter);
evanso 70:8c4572d17441 373 }
evanso 70:8c4572d17441 374
evanso 79:66bcf8fa2d2d 375
evanso 79:66bcf8fa2d2d 376
evanso 79:66bcf8fa2d2d 377
evanso 79:66bcf8fa2d2d 378 // High Score tests ------------------------------------------------------------
evanso 79:66bcf8fa2d2d 379
evanso 82:3211b31e9421 380 void run_no_high_scores_test() {
evanso 79:66bcf8fa2d2d 381 printf ("\nno_high_scores_test_test() \n\n");
evanso 79:66bcf8fa2d2d 382 int passed_counter = 0;
evanso 79:66bcf8fa2d2d 383
evanso 79:66bcf8fa2d2d 384 // Runs test with all differnt possible inputs
evanso 79:66bcf8fa2d2d 385 if (no_high_scores_test(1, 0, 27)) passed_counter++;
evanso 79:66bcf8fa2d2d 386 if (no_high_scores_test(1, 3, 35)) passed_counter++;
evanso 79:66bcf8fa2d2d 387 if (no_high_scores_test(0, 9, 1)) passed_counter++;
evanso 79:66bcf8fa2d2d 388 if (no_high_scores_test(0, 0, 0)) passed_counter++;
evanso 79:66bcf8fa2d2d 389
evanso 82:3211b31e9421 390 // Prints results
evanso 79:66bcf8fa2d2d 391 printf ("\nno_high_scores_test %d tests out of 4\n\n\n",
evanso 79:66bcf8fa2d2d 392 passed_counter);
evanso 79:66bcf8fa2d2d 393 }
evanso 79:66bcf8fa2d2d 394
evanso 79:66bcf8fa2d2d 395
evanso 11:ab578a151f67 396 #endif