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



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to