[Lldb-commits] [PATCH] D24919: Adding a RegisterContextMinidump_x86_64 converter
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 27 08:51:25 PDT 2016
zturner added a comment.
`ASSERT_EQ` causes the test method to return immediately if the condition fails. `EXPECT_EQ` will continue running the same test body. I like to use `ASSERT_EQ`, for example, if you are checking the value of a pointer returned by a function. First you want to check if it's null, then you want to check that its value is the value you expect. So I would do
ASSERT_NE(p, nullptr);
EXPECT_EQ(*p, 42);
Because if it's null, the rest of the statements in the test body are undefined.
Another example is if a method returns some value, say number of items in a list, and then you want to call another method to process that many items. Say:
int x = foo.GetItemCount();
const Item *items = foo.GetItems();
bool Success = ProcessItems(items, x);
If the number of items is not what you expect, it doesn't make sense to run the next statement. So you could write:
int x = foo.GetItemCount();
ASSERT_EQ(42, x);
const Item *items = foo.GetItems();
EXPECT_TRUE(ProcessItems(items, x));
https://reviews.llvm.org/D24919
More information about the lldb-commits
mailing list