Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of el17z2q by
Diff: Bag/Hscore-test.h
- Revision:
- 1:00a4ea97c4cd
- Child:
- 2:6dc7bc55c1cb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bag/Hscore-test.h Mon May 07 21:24:25 2018 +0000 @@ -0,0 +1,44 @@ +#ifndef HSCORE_TEST_H +#define HSCORE_TEST_H + +/** Coin-test Class +* @brief Comfirm that int get_Hscore() function work +* @author Zikang Qian +* @date April, 2018 +*/ + +/** \returns true if all the tests passed + */ +bool GetHscore_test_value() +{ + // Initialise bag object with a width of 18, height of 2 and speed of 1 + Bag bag; + + int test_score_1 = 5; + bag.add_score(test_score_1); + int read_Hscroe_1 = bag.get_Hscore(); + printf("%f", read_Hscore_1); + + int test_score_2 = 3; + bag.add_score(test_score_2); + int read_Hscroe_2 = bag.get_Hscore(); + printf("%f", read_Hscore_2); + + // Update the position + bag.update(); + + // Now check that both the positions are as expected + bool success = true; + + // Fail the test if the initial position is wrong + if (read_Hscroe_1 != 5) { + success = false; + } + + if (read_Hscroe_2 != 5) { + success = false; + } + + return success; +} +#endif \ No newline at end of file