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:
- 17:65fb4afe4991
- Parent:
- 16:bb4b003a5cd2
- Child:
- 18:9874cd1e6cb0
--- a/MaximTinyTester.cpp Sat May 29 03:14:33 2021 -0700
+++ b/MaximTinyTester.cpp Tue Jun 01 19:43:11 2021 -0700
@@ -67,6 +67,7 @@
nPass = 0;
nFail = 0;
err_threshold = 0.030; // 30mV
+ mask = 0; // 0=require all bits
input_timeout_time_msec = 250;
settle_time_msec = 250;
blink_time_msec = 75;
@@ -97,6 +98,7 @@
if (m_BBusyLED.is_connected()) {
m_BBusyLED = LED_OFF;
}
+ mask = 0; // reset mask (0=require all bits) after every FunctionCall_Expect
}
/** report that a test has completed with success.
@@ -124,6 +126,7 @@
}
wait_ms(blink_time_msec); // delay
associatedCmdLine.serial().printf("\r\n+PASS ");
+ mask = 0; // reset mask (0=require all bits) after every FunctionCall_Expect
}
/** report that a test has completed with failure.
@@ -161,6 +164,7 @@
//~ rgb_led.yellow(); // diagnostic rbg led RED+GREEN=YELLOW
//~ rgb_led.black(); // diagnostic rbg led BLACK
#endif // USE_LEDS
+ mask = 0; // reset mask (0=require all bits) after every FunctionCall_Expect
}
/** Print a message to the console during test.
@@ -207,7 +211,7 @@
bool MaximTinyTester::Expect(const char *nameOfTest, int actual_result, int expect_result)
{
- if (actual_result != expect_result)
+ if ((int)(actual_result & mask) != (int)(expect_result & mask)) // Expect (int)
{
FAIL();
associatedCmdLine.serial().printf("%s", nameOfTest);
@@ -266,7 +270,7 @@
uint16_t expect_result)
{
uint16_t actual_result = functionUnderTest(arg_1_voltageV);
- if (actual_result != expect_result)
+ if ((uint16_t)(actual_result & mask) != (uint16_t)(expect_result & mask)) // FunctionCall_u_f_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%6.4fV)", nameOfFunctionUnderTest, arg_1_voltageV);
@@ -307,7 +311,7 @@
uint32_t expect_result)
{
uint32_t actual_result = functionUnderTest(arg_1_voltageV);
- if (actual_result != expect_result)
+ if ((uint32_t)(actual_result & mask) != (uint32_t)(expect_result & mask)) // FunctionCall_lu_f_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%6.6fV)", nameOfFunctionUnderTest, arg_1_voltageV);
@@ -560,7 +564,43 @@
int expect_result)
{
int actual_result = functionUnderTest();
- if (actual_result != expect_result)
+ if ((int)(actual_result & mask) != (int)(expect_result & mask)) // FunctionCall_d_Expect
+ {
+ FAIL();
+ associatedCmdLine.serial().printf("%s()", nameOfFunctionUnderTest);
+ associatedCmdLine.serial().printf(" expect %d", expect_result);
+ associatedCmdLine.serial().printf(" but got %d", actual_result);
+ return false;
+ }
+ else
+ {
+ PASS();
+ associatedCmdLine.serial().printf("%s()", nameOfFunctionUnderTest);
+ 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] expect_result contains the expected result
+*
+* @post nPass and nFail counters are updated
+*
+* @return true if success, false if test failed
+*
+*/
+bool MaximTinyTester::FunctionCall_md_Expect(const char *nameOfFunctionUnderTest,
+ Callback<int16_t()> functionUnderTest,
+ int16_t expect_result)
+{
+ int16_t actual_result = functionUnderTest();
+ if ((int16_t)(actual_result & mask) != (int16_t)(expect_result & mask)) // FunctionCall_md_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s()", nameOfFunctionUnderTest);
@@ -596,7 +636,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest();
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s()", nameOfFunctionUnderTest);
@@ -635,7 +675,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d)", nameOfFunctionUnderTest, arg_1);
@@ -674,7 +714,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_d_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d)", nameOfFunctionUnderTest, arg_1);
@@ -715,7 +755,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_su_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
@@ -756,7 +796,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_d_d_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2);
@@ -797,7 +837,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_d_lu_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%ld)", nameOfFunctionUnderTest, arg_1, arg_2);
@@ -887,7 +927,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2, arg_3);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_su_su_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2, arg_3);
@@ -932,7 +972,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2, arg_3, arg_4);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_su_su_su_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%d,%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2, arg_3, arg_4);
@@ -979,7 +1019,7 @@
uint8_t expect_result)
{
uint8_t actual_result = functionUnderTest(arg_1, arg_2, arg_3, arg_4, arg_5);
- if (actual_result != expect_result)
+ if ((uint8_t)(actual_result & mask) != (uint8_t)(expect_result & mask)) // FunctionCall_su_su_su_su_su_su_Expect
{
FAIL();
associatedCmdLine.serial().printf("%s(%d,%d,%d,%d,%d)", nameOfFunctionUnderTest, arg_1, arg_2, arg_3, arg_4, arg_5);
@@ -1454,7 +1494,8 @@
int actual_UPO_value = -1;
for (int retry_count = 0; retry_count < 10; retry_count++) {
actual_UPO_value = digitalInPin.read(); // g_MAX5171_device.UPOinputValue();
- if (actual_UPO_value == expect_result) {
+ if (actual_UPO_value == expect_result) // DigitalIn_Read_Expect_WarnOnly
+ {
PASS();
associatedCmdLine.serial().printf("%s signal=%d %s", pinName, expect_result, expect_description);
return true;