================
@@ -35,13 +103,13 @@ class UnsafeBufferUsageTest : public testing::Test {
#define EXPECT_EXCLUDES(Set, Elt) EXPECT_EQ((Set).find(Elt), (Set).end())
----------------
steakhal wrote:
I think there is a bit of misunderstanding with how these matchers are defined
and used.
Basically, the matcher needs to be within an `EXPECT_THAT` or `ASSERT_THAT`
macro to be checked.
This isn't what the PR does right now.
I figured, I could recommend something so I checked out the branch and created
some commits:
To see my commits, fetch them and get some inspiration. Note that on my branch
I also merged upstream main, because I need the EntityId `operator <<`.
```
git fetch steak eng/PR-169191570
git log --oneline --first-parent steak/eng/PR-169191570...eng/PR-169191570
```
```
b8987d7cdfad3 (steak/eng/PR-169191570) Keep warning flags (except for -Wunused)
and fix the tests
9a15e373461c7 Simplify the tests by using the 'test_subject' to pin the
contributing entity
296c36d67047f First step of using gtest matchers
20954099f8d4e Merge remote-tracking branch 'llvm/main' into eng/PR-169191570
bab7e98f3ec1c Revert back to using macros
fa0823d89d8b3 Simplify UnsafeBufferUsageEntitySummaryTest
```
The result of these would be something like:
```c++
TEST_F(UnsafeBufferUsageTest, CompoundAssignment) {
auto Sum = setUpTest(R"cpp(
void test_subject(int *p, int *q) {
(p += 5)[5];
(q -= 3)[5];
}
)cpp");
ASSERT_NE(Sum, nullptr);
EXPECT_THAT(*Sum, UnorderedPointerLevelsAre({{"p", 1u}, {"q", 1u}}));
}
```
What is importance there that we don't need to explicitly spell how many
elements we expect and that something is inside the set because the whole set
is checked against a list. That means that if something is missing, or we have
more elements in the set, then that gets caught. So this is on par with the
previous implementation, but maybe it's a bit terser.
https://github.com/llvm/llvm-project/pull/182941
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits