Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

Committer:
yzjdxl
Date:
Mon May 07 22:11:43 2018 +0000
Branch:
GameEngine
Revision:
2:6dc7bc55c1cb
Parent:
1:00a4ea97c4cd
publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yzjdxl 1:00a4ea97c4cd 1 #ifndef HSCORE_TEST_H
yzjdxl 1:00a4ea97c4cd 2 #define HSCORE_TEST_H
yzjdxl 1:00a4ea97c4cd 3
yzjdxl 1:00a4ea97c4cd 4 /** Coin-test Class
yzjdxl 1:00a4ea97c4cd 5 * @brief Comfirm that int get_Hscore() function work
yzjdxl 1:00a4ea97c4cd 6 * @author Zikang Qian
yzjdxl 1:00a4ea97c4cd 7 * @date April, 2018
yzjdxl 1:00a4ea97c4cd 8 */
yzjdxl 1:00a4ea97c4cd 9
yzjdxl 1:00a4ea97c4cd 10 /** \returns true if all the tests passed
yzjdxl 1:00a4ea97c4cd 11 */
yzjdxl 1:00a4ea97c4cd 12 bool GetHscore_test_value()
yzjdxl 1:00a4ea97c4cd 13 {
yzjdxl 2:6dc7bc55c1cb 14 // Just quote the get_Hscore() function
yzjdxl 1:00a4ea97c4cd 15 Bag bag;
yzjdxl 1:00a4ea97c4cd 16
yzjdxl 2:6dc7bc55c1cb 17 // int score 5 firstly
yzjdxl 1:00a4ea97c4cd 18 int test_score_1 = 5;
yzjdxl 2:6dc7bc55c1cb 19 // get the score
yzjdxl 1:00a4ea97c4cd 20 bag.add_score(test_score_1);
yzjdxl 1:00a4ea97c4cd 21 int read_Hscroe_1 = bag.get_Hscore();
yzjdxl 1:00a4ea97c4cd 22 printf("%f", read_Hscore_1);
yzjdxl 1:00a4ea97c4cd 23
yzjdxl 2:6dc7bc55c1cb 24 // then int score 3
yzjdxl 1:00a4ea97c4cd 25 int test_score_2 = 3;
yzjdxl 1:00a4ea97c4cd 26 bag.add_score(test_score_2);
yzjdxl 1:00a4ea97c4cd 27 int read_Hscroe_2 = bag.get_Hscore();
yzjdxl 1:00a4ea97c4cd 28 printf("%f", read_Hscore_2);
yzjdxl 1:00a4ea97c4cd 29
yzjdxl 2:6dc7bc55c1cb 30 // Update the score
yzjdxl 1:00a4ea97c4cd 31 bag.update();
yzjdxl 1:00a4ea97c4cd 32
yzjdxl 2:6dc7bc55c1cb 33 // Now check that both the scores are as expected
yzjdxl 1:00a4ea97c4cd 34 bool success = true;
yzjdxl 1:00a4ea97c4cd 35
yzjdxl 2:6dc7bc55c1cb 36 // Fail the test if the score is wrong
yzjdxl 1:00a4ea97c4cd 37 if (read_Hscroe_1 != 5) {
yzjdxl 1:00a4ea97c4cd 38 success = false;
yzjdxl 1:00a4ea97c4cd 39 }
yzjdxl 1:00a4ea97c4cd 40
yzjdxl 1:00a4ea97c4cd 41 if (read_Hscroe_2 != 5) {
yzjdxl 1:00a4ea97c4cd 42 success = false;
yzjdxl 1:00a4ea97c4cd 43 }
yzjdxl 1:00a4ea97c4cd 44
yzjdxl 1:00a4ea97c4cd 45 return success;
yzjdxl 1:00a4ea97c4cd 46 }
yzjdxl 1:00a4ea97c4cd 47 #endif