Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HighScore_test.h Source File

HighScore_test.h

00001 #ifndef HIGHSCORE_TEST_H
00002 #define HIGHSCORE_TEST_H
00003 
00004 /** High Score Test
00005  * @brief Checks no score screen displays
00006  * @author Benjamin Evans, University of Leeds
00007  * @date May 2020
00008  * @return true if test are passed 
00009  */
00010  bool no_high_scores_test(int expected_pixel_status, int expected_postion_x, 
00011 int expected_postion_y) {
00012     
00013     // Objects required for test
00014     HighScore high_score;
00015     N5110 lcd;
00016     
00017     // Initialise save and lcd
00018     high_score.init();
00019     lcd.init();
00020     
00021     printf("no_high_scores x,y = %d,%d : ",expected_postion_x,
00022     expected_postion_y );
00023     
00024     high_score.no_high_scores(lcd);
00025     
00026     // Reads pixel where hud is expected to be drawn 
00027     int actual_pixel_status = lcd.getPixel(expected_postion_x, 
00028     expected_postion_y);
00029     
00030     // Checks if pixel is drawn and therefor testing it hasn’t gone of screen
00031     if (actual_pixel_status == expected_pixel_status) {
00032         printf ( "Passed!\n");
00033         return true;
00034     } else {
00035         printf ( "Failed! value = %d  (expecting  %d)\n", actual_pixel_status, 
00036         expected_pixel_status);
00037         return false;
00038     }
00039 }
00040  
00041 #endif