Mark Underwood / MaximTinyTester

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Revision:
12:55db0f4a417d
Parent:
11:bfa56dab822c
Child:
13:c294236d7465
--- a/MaximTinyTester.cpp	Sun Mar 29 15:57:49 2020 -0700
+++ b/MaximTinyTester.cpp	Mon Apr 13 02:53:26 2020 +0000
@@ -260,7 +260,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_u_f_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint16_t(double)> functionUnderTest,
     double arg_1_voltageV,
     uint16_t expect_result)
@@ -301,7 +301,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_f_d_Expect(const char *nameOfFunctionUnderTest, 
     Callback<double(int)> functionUnderTest,
     int arg_1_u16,
     double expect_result)
@@ -333,6 +333,51 @@
 *
 * @param[in] functionUnderTest points to the function under test
 *
+* @param[in] arg_1_int is a test argument given to the function under test
+* @param[in] arg_2_int is a test argument given to the function under test
+*
+* @param[in] expect_result contains the expected result
+*
+* @pre err_threshold determines how closely the result must match the expected value
+*
+* @post nPass and nFail counters are updated
+*
+* @return true if success, false if test failed
+*
+*/
+bool MaximTinyTester::FunctionCall_f_d_d_Expect(const char *nameOfFunctionUnderTest, 
+    Callback<double(int, int)> functionUnderTest,
+    int arg_1_int,
+    int arg_2_int,
+    double expect_result)
+{
+    double actual_result = functionUnderTest(arg_1_int, arg_2_int);
+    double err_result = (actual_result - expect_result);
+    if (( -err_threshold < err_result) && ( err_result < err_threshold))
+    {
+        PASS();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1_int, arg_2_int);
+        associatedCmdLine.serial().printf(" expect %6.6f", expect_result);
+        return true;
+    }
+    else
+    {
+        FAIL();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1_int, arg_2_int);
+        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;
+    }
+    //~ associatedCmdLine.serial().printf("\r\n");
+}
+
+/** Test a software function
+*
+* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test
+*
+* @param[in] functionUnderTest points to the function under test
+*
 * @param[in] arg_1_u32 is a test argument given to the function under test
 *
 * @param[in] expect_result contains the expected result
@@ -344,7 +389,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_f_lu_Expect(const char *nameOfFunctionUnderTest, 
     Callback<double(uint32_t)> functionUnderTest,
     uint32_t arg_1_u32,
     double expect_result)
@@ -387,7 +432,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_f_f_Expect(const char *nameOfFunctionUnderTest, 
     Callback<double(double)> functionUnderTest,
     double arg_1_d,
     double expect_result)
@@ -426,7 +471,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t()> functionUnderTest,
     uint8_t expect_result)
 {
@@ -464,7 +509,46 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_su_Expect(const char *nameOfFunctionUnderTest, 
+    Callback<uint8_t(uint8_t)> functionUnderTest,
+    uint8_t arg_1,
+    uint8_t expect_result)
+{
+    uint8_t actual_result = functionUnderTest(arg_1);
+    if (actual_result != expect_result)
+    {
+        FAIL();
+        associatedCmdLine.serial().printf("%s(%d)", nameOfFunctionUnderTest, arg_1);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        associatedCmdLine.serial().printf(" but got %d", actual_result);
+        return false;
+    }
+    else
+    {
+        PASS();
+        associatedCmdLine.serial().printf("%s(%d)", nameOfFunctionUnderTest, arg_1);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        return true;
+    }
+    //~ associatedCmdLine.serial().printf("\r\n");
+}
+
+/** Test a software function
+*
+* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test
+*
+* @param[in] functionUnderTest points to the function under test
+*
+* @param[in] arg_1 is a test argument given to the function under test
+*
+* @param[in] expect_result contains the expected result
+*
+* @post nPass and nFail counters are updated
+*
+* @return true if success, false if test failed
+*
+*/
+bool MaximTinyTester::FunctionCall_su_d_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(int)> functionUnderTest,
     int arg_1,
     uint8_t expect_result)
@@ -504,7 +588,48 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_su_su_Expect(const char *nameOfFunctionUnderTest, 
+    Callback<uint8_t(uint8_t, uint8_t)> functionUnderTest,
+    uint8_t arg_1,
+    uint8_t arg_2,
+    uint8_t expect_result)
+{
+    uint8_t actual_result = functionUnderTest(arg_1, arg_2);
+    if (actual_result != expect_result)
+    {
+        FAIL();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        associatedCmdLine.serial().printf(" but got %d", actual_result);
+        return false;
+    }
+    else
+    {
+        PASS();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        return true;
+    }
+    //~ associatedCmdLine.serial().printf("\r\n");
+}
+
+/** Test a software function
+*
+* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test
+*
+* @param[in] functionUnderTest points to the function under test
+*
+* @param[in] arg_1 is a test argument given to the function under test
+* @param[in] arg_2 is a test argument given to the function under test
+*
+* @param[in] expect_result contains the expected result
+*
+* @post nPass and nFail counters are updated
+*
+* @return true if success, false if test failed
+*
+*/
+bool MaximTinyTester::FunctionCall_su_d_d_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(int, int)> functionUnderTest,
     int arg_1,
     int arg_2,
@@ -529,7 +654,48 @@
     //~ associatedCmdLine.serial().printf("\r\n");
 }
 
-bool MaximTinyTester::FunctionCall_i_pi_Expect(const char *nameOfFunctionUnderTest, 
+/** Test a software function
+*
+* @param[in] nameOfFunctionUnderTest is the user-facing name of the function under test
+*
+* @param[in] functionUnderTest points to the function under test
+*
+* @param[in] arg_1 is a test argument given to the function under test
+* @param[in] arg_2 is a test argument given to the function under test
+*
+* @param[in] expect_result contains the expected result
+*
+* @post nPass and nFail counters are updated
+*
+* @return true if success, false if test failed
+*
+*/
+bool MaximTinyTester::FunctionCall_su_d_lu_Expect(const char *nameOfFunctionUnderTest, 
+    Callback<uint8_t(int, uint32_t)> functionUnderTest,
+    int arg_1,
+    uint32_t arg_2,
+    uint8_t expect_result)
+{
+    uint8_t actual_result = functionUnderTest(arg_1, arg_2);
+    if (actual_result != expect_result)
+    {
+        FAIL();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        associatedCmdLine.serial().printf(" but got %d", actual_result);
+        return false;
+    }
+    else
+    {
+        PASS();
+        associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
+        associatedCmdLine.serial().printf(" expect %d", expect_result);
+        return true;
+    }
+    //~ associatedCmdLine.serial().printf("\r\n");
+}
+
+bool MaximTinyTester::FunctionCall_su_d_plu_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(int, uint32_t*)> functionUnderTest,
     int arg_1,
     uint32_t* arg_2,
@@ -593,7 +759,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(uint8_t, uint8_t, uint8_t)> functionUnderTest,
     uint8_t arg_1,
     uint8_t arg_2,
@@ -637,7 +803,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
     uint8_t arg_1,
     uint8_t arg_2,
@@ -683,7 +849,7 @@
 * @return true if success, false if test failed
 *
 */
-bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+bool MaximTinyTester::FunctionCall_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, 
     Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
     uint8_t arg_1,
     uint8_t arg_2,
@@ -732,7 +898,7 @@
 * @return true if success, false if test failed
 *
 */
-//bool MaximTinyTester::FunctionCall_Expect(const char *nameOfFunctionUnderTest, 
+//bool MaximTinyTester::FunctionCall_su_su_su_su_su_su_su_Expect(const char *nameOfFunctionUnderTest, 
 //    Callback<uint8_t(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)> functionUnderTest,
 //    uint8_t arg_1,
 //    uint8_t arg_2,