minimalist hardware testing support

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Revision:
14:10219b869ac3
Parent:
13:c294236d7465
Child:
15:ac3e4930df8b
--- a/MaximTinyTester.cpp	Thu Apr 16 22:16:28 2020 -0700
+++ b/MaximTinyTester.cpp	Fri May 15 08:36:01 2020 +0000
@@ -389,6 +389,49 @@
 * @return true if success, false if test failed
 *
 */
+bool MaximTinyTester::FunctionCall_f_u_Expect(const char *nameOfFunctionUnderTest, 
+    Callback<double(uint16_t)> functionUnderTest,
+    uint16_t arg_1_u16,
+    double expect_result)
+{
+    double actual_result = functionUnderTest(arg_1_u16);
+    double err_result = (actual_result - expect_result);
+    if (( -err_threshold < err_result) && ( err_result < err_threshold))
+    {
+        PASS();
+        associatedCmdLine.serial().printf("%s(0x%x)", nameOfFunctionUnderTest, arg_1_u16);
+        associatedCmdLine.serial().printf(" expect %6.6f", expect_result);
+        return true;
+    }
+    else
+    {
+        FAIL();
+        associatedCmdLine.serial().printf("%s(0x%x)", nameOfFunctionUnderTest, arg_1_u16);
+        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
+*
+* @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_lu_Expect(const char *nameOfFunctionUnderTest, 
     Callback<double(uint32_t)> functionUnderTest,
     uint32_t arg_1_u32,