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.
Dependents: MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more
Diff: MaximTinyTester.cpp
- Revision:
- 10:b11ab5d7ac58
- Parent:
- 9:3ec00515891d
- Child:
- 11:bfa56dab822c
diff -r 3ec00515891d -r b11ab5d7ac58 MaximTinyTester.cpp
--- a/MaximTinyTester.cpp Tue Mar 17 15:33:36 2020 -0700
+++ b/MaximTinyTester.cpp Sun Mar 29 04:24:53 2020 -0700
@@ -205,6 +205,46 @@
}
}
+bool MaximTinyTester::Expect(const char *nameOfTest, int actual_result, int expect_result)
+{
+ if (actual_result != expect_result)
+ {
+ FAIL();
+ associatedCmdLine.serial().printf("%s", nameOfTest);
+ associatedCmdLine.serial().printf(" expect %d", expect_result);
+ associatedCmdLine.serial().printf(" but got %d", actual_result);
+ return false;
+ }
+ else
+ {
+ PASS();
+ associatedCmdLine.serial().printf("%s", nameOfTest);
+ associatedCmdLine.serial().printf(" expect %d", expect_result);
+ return true;
+ }
+}
+
+bool MaximTinyTester::Expect(const char *nameOfTest, double actual_result, double expect_result)
+{
+ double err_result = (actual_result - expect_result);
+ if (( -err_threshold < err_result) && ( err_result < err_threshold))
+ {
+ PASS();
+ associatedCmdLine.serial().printf("%s", nameOfTest);
+ associatedCmdLine.serial().printf(" expect %6.6f", expect_result);
+ return true;
+ }
+ else
+ {
+ FAIL();
+ associatedCmdLine.serial().printf("%s", nameOfTest);
+ associatedCmdLine.serial().printf(" expect %6.6f", expect_result);
+ associatedCmdLine.serial().printf(" but got %6.6f", actual_result);
+ associatedCmdLine.serial().printf(" err=%6.6f", err_result);
+ return false;
+ }
+}
+
/** Test a software function
*
* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test
@@ -262,8 +302,8 @@
*
*/
bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest,
- Callback<double(uint16_t)> functionUnderTest,
- uint16_t arg_1_u16,
+ Callback<double(int)> functionUnderTest,
+ int arg_1_u16,
double expect_result)
{
double actual_result = functionUnderTest(arg_1_u16);
@@ -425,8 +465,8 @@
*
*/
bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest,
- Callback<uint8_t(uint8_t)> functionUnderTest,
- uint8_t arg_1,
+ Callback<uint8_t(int)> functionUnderTest,
+ int arg_1,
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1);
@@ -465,9 +505,9 @@
*
*/
bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest,
- Callback<uint8_t(uint8_t, uint8_t)> functionUnderTest,
- uint8_t arg_1,
- uint8_t arg_2,
+ Callback<uint8_t(int, int)> functionUnderTest,
+ int arg_1,
+ int arg_2,
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2);
@@ -489,6 +529,53 @@
//~ associatedCmdLine.serial().printf("\r\n");
}
+bool MaximTinyTester::FunctionCall_i_pi_Expect(const char *nameOfFunctionUnderTest,
+ Callback<uint8_t(int, uint32_t*)> functionUnderTest,
+ int arg_1,
+ uint32_t* arg_2,
+ uint8_t expect_result,
+ uint32_t expect_buffer)
+{
+ uint8_t actual_result = functionUnderTest(arg_1, arg_2);
+ uint32_t actual_buffer = *arg_2;
+ if ((actual_result != expect_result) || (actual_buffer != expect_buffer))
+ {
+ FAIL();
+ associatedCmdLine.serial().printf("%s(%d,buf)", nameOfFunctionUnderTest, arg_1);
+ //associatedCmdLine.serial().print(nameOfFunctionUnderTest);
+ //associatedCmdLine.serial().print("(");
+ //associatedCmdLine.serial().print(arg_1);
+ //associatedCmdLine.serial().print(F(",buf)"));
+ associatedCmdLine.serial().printf(" expect %d", expect_result);
+ //associatedCmdLine.serial().print(F(" expect "));
+ //associatedCmdLine.serial().print(expect_result);
+ //associatedCmdLine.serial().print(F(" buf="));
+ //associatedCmdLine.serial().print(expect_buffer);
+ associatedCmdLine.serial().printf(" but got %d", actual_result);
+ //associatedCmdLine.serial().print(F(" but got "));
+ //associatedCmdLine.serial().print(actual_result);
+ //associatedCmdLine.serial().print(F(" buf="));
+ //associatedCmdLine.serial().print(actual_buffer);
+ return false;
+ }
+ else
+ {
+ PASS();
+ associatedCmdLine.serial().printf("%s(%d,buf)", nameOfFunctionUnderTest, arg_1);
+ //associatedCmdLine.serial().print(nameOfFunctionUnderTest);
+ //associatedCmdLine.serial().print("(");
+ //associatedCmdLine.serial().print(arg_1);
+ //associatedCmdLine.serial().print(F(",buf)"));
+ associatedCmdLine.serial().printf(" expect %d", expect_result);
+ //associatedCmdLine.serial().print(F(" expect "));
+ //associatedCmdLine.serial().print(expect_result);
+ //associatedCmdLine.serial().print(F(" buf="));
+ //associatedCmdLine.serial().print(expect_buffer);
+ return true;
+ }
+ //~ associatedCmdLine.serial().printf("\r\n");
+}
+
/** Test a software function
*
* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test