[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:
Abtin Keshavarzian
2021-06-28 11:38:10 -07:00
committed by GitHub
parent 2db3ddca33
commit 57d072d352
36 changed files with 1733 additions and 1864 deletions
+4 -4
View File
@@ -70,12 +70,12 @@ void VerifyEntry(EntryPool &aPool, const Entry &aEntry, bool aInitWithInstance)
uint16_t index;
const EntryPool &constPool = const_cast<const EntryPool &>(aPool);
VerifyOrQuit(aPool.IsPoolEntry(aEntry), "Pool::IsPoolEntry() failed");
VerifyOrQuit(aPool.IsPoolEntry(aEntry));
VerifyOrQuit(!aPool.IsPoolEntry(sNonPoolEntry), "Pool::IsPoolEntry() succeeded for non-pool entry");
index = aPool.GetIndexOf(aEntry);
VerifyOrQuit(&aPool.GetEntryAt(index) == &aEntry, "Pool::GetEntryAt() failed");
VerifyOrQuit(&constPool.GetEntryAt(index) == &aEntry, "Pool::GetEntryAt() failed");
VerifyOrQuit(&aPool.GetEntryAt(index) == &aEntry);
VerifyOrQuit(&constPool.GetEntryAt(index) == &aEntry);
VerifyOrQuit(aEntry.IsInitializedWithInstance() == aInitWithInstance, "Pool did not correctly Init() entry");
}
@@ -84,7 +84,7 @@ void TestPool(EntryPool &aPool, bool aInitWithInstance)
{
Entry *entries[kPoolSize];
VerifyOrQuit(aPool.GetSize() == kPoolSize, "Pool::GetSize() failed");
VerifyOrQuit(aPool.GetSize() == kPoolSize);
for (Entry *&entry : entries)
{