Skip to content

Commit d71dcfa

Browse files
[XRay] Use llvm::is_contained (NFC) (#141318)
1 parent c180d0c commit d71dcfa

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

llvm/unittests/XRay/GraphTest.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ template <typename T> void graphVertexTester(T &G) {
7272
ASSERT_TRUE(!!EVV);
7373
EXPECT_EQ(1u, G.count(u));
7474
EXPECT_EQ(VA[u], EVV->VA);
75-
EXPECT_NE(G.vertices().end(),
76-
llvm::find_if(G.vertices(),
77-
[&](const VVT &VV) { return VV.first == u; }));
75+
EXPECT_TRUE(llvm::is_contained(llvm::make_first_range(G.vertices()), u));
7876
consumeError(EVV.takeError());
7977
}
8078

@@ -97,8 +95,7 @@ template <typename T> void graphEdgeTester(T &G) {
9795
EXPECT_EQ(1u, G.count(u));
9896
EXPECT_EQ(VA[u.first] * VA[u.second] * ((u.first > u.second) ? 2 : 1),
9997
EEV->EA);
100-
auto Pred = [&](const EVT &EV) { return EV.first == u; };
101-
EXPECT_NE(G.edges().end(), llvm::find_if(G.edges(), Pred));
98+
EXPECT_TRUE(llvm::is_contained(llvm::make_first_range(G.edges()), u));
10299
consumeError(EEV.takeError());
103100
}
104101

@@ -113,31 +110,14 @@ template <typename T> void graphEdgeTester(T &G) {
113110
EXPECT_NE(OE.size(), 0u);
114111
EXPECT_NE(IE.begin(), IE.end());
115112
EXPECT_NE(OE.begin(), OE.end());
116-
{
117-
auto It = std::find_if(
118-
G.inEdges(EV.first.second).begin(), G.inEdges(EV.first.second).end(),
119-
[&](const EVT &EVI) { return EVI.first == EV.first; });
120-
EXPECT_NE(G.inEdges(EV.first.second).end(), It);
121-
}
122-
{
123-
auto It = std::find_if(
124-
G.inEdges(EV.first.first).begin(), G.inEdges(EV.first.first).end(),
125-
[&](const EVT &EVI) { return EVI.first == EV.first; });
126-
EXPECT_EQ(G.inEdges(EV.first.first).end(), It);
127-
}
128-
{
129-
auto It =
130-
std::find_if(G.outEdges(EV.first.second).begin(),
131-
G.outEdges(EV.first.second).end(),
132-
[&](const EVT &EVI) { return EVI.first == EV.first; });
133-
EXPECT_EQ(G.outEdges(EV.first.second).end(), It);
134-
}
135-
{
136-
auto It = std::find_if(
137-
G.outEdges(EV.first.first).begin(), G.outEdges(EV.first.first).end(),
138-
[&](const EVT &EVI) { return EVI.first == EV.first; });
139-
EXPECT_NE(G.outEdges(EV.first.first).end(), It);
140-
}
113+
EXPECT_TRUE(llvm::is_contained(
114+
llvm::make_first_range(G.inEdges(EV.first.second)), EV.first));
115+
EXPECT_FALSE(llvm::is_contained(
116+
llvm::make_first_range(G.inEdges(EV.first.first)), EV.first));
117+
EXPECT_FALSE(llvm::is_contained(
118+
llvm::make_first_range(G.outEdges(EV.first.second)), EV.first));
119+
EXPECT_TRUE(llvm::is_contained(
120+
llvm::make_first_range(G.outEdges(EV.first.first)), EV.first));
141121
}
142122
}
143123

0 commit comments

Comments
 (0)