mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 08:40:06 +00:00
[test] enhance {Verify/Success}OrQuit() and their use in unit test (#6764)
This commit updates `VerifyOrQuit()` and `SuccessOrQuit()` macros to include the failed condition in the error message that is printed on a failure (in addition to function name and line number where the error happened). This commit also changes the second parameter (`aMessage`) to in these macros to be optional. This commit also updates unit tests to remove the second `aMessage` string in cases where the failure can be inferred from the condition itself.
This commit is contained in:
@@ -45,9 +45,8 @@ void TestMinimumPassphrase(void)
|
||||
const char passphrase[] = "123456";
|
||||
otInstance * instance = testInitInstance();
|
||||
SuccessOrQuit(ot::MeshCoP::GeneratePskc(passphrase, *reinterpret_cast<const ot::Mac::NetworkName *>("OpenThread"),
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc),
|
||||
"TestMinimumPassphrase failed to generate PSKc");
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0, "TestMinimumPassphrase got wrong pskc");
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc));
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0);
|
||||
testFreeInstance(instance);
|
||||
}
|
||||
|
||||
@@ -76,9 +75,8 @@ void TestMaximumPassphrase(void)
|
||||
|
||||
otInstance *instance = testInitInstance();
|
||||
SuccessOrQuit(ot::MeshCoP::GeneratePskc(passphrase, *reinterpret_cast<const ot::Mac::NetworkName *>("OpenThread"),
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc),
|
||||
"TestMaximumPassphrase failed to generate PSKc");
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0, "TestMaximumPassphrase got wrong pskc");
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc));
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0);
|
||||
testFreeInstance(instance);
|
||||
}
|
||||
|
||||
@@ -92,9 +90,8 @@ void TestExampleInSpec(void)
|
||||
|
||||
otInstance *instance = testInitInstance();
|
||||
SuccessOrQuit(ot::MeshCoP::GeneratePskc(passphrase, *reinterpret_cast<const ot::Mac::NetworkName *>("Test Network"),
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc),
|
||||
"ExampleInSpec failed to generate PSKc");
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0, "TestExampleInSpec got wrong pskc");
|
||||
static_cast<const ot::Mac::ExtendedPanId &>(xpanid), pskc));
|
||||
VerifyOrQuit(memcmp(pskc.m8, expectedPskc, sizeof(pskc)) == 0);
|
||||
testFreeInstance(instance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user