Zikang Qian / Mbed 2 deprecated el17z2q

Dependencies:   mbed

Fork of el17z2q by ELEC2645 (2017/18)

Committer:
yzjdxl
Date:
Mon May 07 21:24:25 2018 +0000
Revision:
1:00a4ea97c4cd
Child:
2:6dc7bc55c1cb
Final Submission. I have read and agreed with Statement of Academic Integrity.

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 1:00a4ea97c4cd 14 // Initialise bag object with a width of 18, height of 2 and speed of 1
yzjdxl 1:00a4ea97c4cd 15 Bag bag;
yzjdxl 1:00a4ea97c4cd 16
yzjdxl 1:00a4ea97c4cd 17 int test_score_1 = 5;
yzjdxl 1:00a4ea97c4cd 18 bag.add_score(test_score_1);
yzjdxl 1:00a4ea97c4cd 19 int read_Hscroe_1 = bag.get_Hscore();
yzjdxl 1:00a4ea97c4cd 20 printf("%f", read_Hscore_1);
yzjdxl 1:00a4ea97c4cd 21
yzjdxl 1:00a4ea97c4cd 22 int test_score_2 = 3;
yzjdxl 1:00a4ea97c4cd 23 bag.add_score(test_score_2);
yzjdxl 1:00a4ea97c4cd 24 int read_Hscroe_2 = bag.get_Hscore();
yzjdxl 1:00a4ea97c4cd 25 printf("%f", read_Hscore_2);
yzjdxl 1:00a4ea97c4cd 26
yzjdxl 1:00a4ea97c4cd 27 // Update the position
yzjdxl 1:00a4ea97c4cd 28 bag.update();
yzjdxl 1:00a4ea97c4cd 29
yzjdxl 1:00a4ea97c4cd 30 // Now check that both the positions are as expected
yzjdxl 1:00a4ea97c4cd 31 bool success = true;
yzjdxl 1:00a4ea97c4cd 32
yzjdxl 1:00a4ea97c4cd 33 // Fail the test if the initial position is wrong
yzjdxl 1:00a4ea97c4cd 34 if (read_Hscroe_1 != 5) {
yzjdxl 1:00a4ea97c4cd 35 success = false;
yzjdxl 1:00a4ea97c4cd 36 }
yzjdxl 1:00a4ea97c4cd 37
yzjdxl 1:00a4ea97c4cd 38 if (read_Hscroe_2 != 5) {
yzjdxl 1:00a4ea97c4cd 39 success = false;
yzjdxl 1:00a4ea97c4cd 40 }
yzjdxl 1:00a4ea97c4cd 41
yzjdxl 1:00a4ea97c4cd 42 return success;
yzjdxl 1:00a4ea97c4cd 43 }
yzjdxl 1:00a4ea97c4cd 44 #endif