mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 18:20: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:
@@ -192,16 +192,16 @@ void VerifyChildTableContent(ChildTable &aTable, uint16_t aChildListLength, cons
|
||||
|
||||
// Verify that when iterator is done, it points to `nullptr`.
|
||||
|
||||
VerifyOrQuit(iter.GetChild() == nullptr, "iterator GetChild() failed");
|
||||
VerifyOrQuit(iter.GetChild() == nullptr);
|
||||
|
||||
iter++;
|
||||
VerifyOrQuit(iter.IsDone(), "iterator Advance() (after iterator is done) failed");
|
||||
VerifyOrQuit(iter.GetChild() == nullptr, "iterator GetChild() failed");
|
||||
VerifyOrQuit(iter.GetChild() == nullptr);
|
||||
|
||||
// Verify that the number of children matches the number of entries we get from iterator.
|
||||
|
||||
VerifyOrQuit(aTable.GetNumChildren(filter) == numChildren, "GetNumChildren() failed");
|
||||
VerifyOrQuit(aTable.HasChildren(filter) == (numChildren != 0), "HasChildren() failed");
|
||||
VerifyOrQuit(aTable.GetNumChildren(filter) == numChildren);
|
||||
VerifyOrQuit(aTable.HasChildren(filter) == (numChildren != 0));
|
||||
|
||||
// Verify that there is no missing or extra entry between the expected list
|
||||
// and what was observed/returned by the iterator.
|
||||
@@ -298,7 +298,7 @@ void TestChildTable(void)
|
||||
Error error;
|
||||
|
||||
sInstance = testInitInstance();
|
||||
VerifyOrQuit(sInstance != nullptr, "Null instance");
|
||||
VerifyOrQuit(sInstance != nullptr);
|
||||
|
||||
table = &sInstance->Get<ChildTable>();
|
||||
|
||||
@@ -310,8 +310,8 @@ void TestChildTable(void)
|
||||
|
||||
for (Child::StateFilter filter : kAllFilters)
|
||||
{
|
||||
VerifyOrQuit(table->HasChildren(filter) == false, "HasChildren() failed after init");
|
||||
VerifyOrQuit(table->GetNumChildren(filter) == 0, "GetNumChildren() failed after init");
|
||||
VerifyOrQuit(table->HasChildren(filter) == false);
|
||||
VerifyOrQuit(table->GetNumChildren(filter) == 0);
|
||||
}
|
||||
|
||||
printf(" -- PASS\n");
|
||||
@@ -375,7 +375,7 @@ void TestChildTable(void)
|
||||
|
||||
error = table->SetMaxChildrenAllowed(testNumAllowedChildren);
|
||||
VerifyOrQuit(error == kErrorNone, "SetMaxChildrenAllowed() failed");
|
||||
VerifyOrQuit(table->GetMaxChildrenAllowed() == testNumAllowedChildren, "GetMaxChildrenAllowed() failed");
|
||||
VerifyOrQuit(table->GetMaxChildrenAllowed() == testNumAllowedChildren);
|
||||
|
||||
for (uint16_t num = 0; num < testNumAllowedChildren; num++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user