Skip to content

Commit bafb328

Browse files
author
svorenova
committed
Updating a utility function cont.
1 parent 5c3f423 commit bafb328

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

unit/testing-utils/require_parse_tree.cpp

+12-20
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
/// Find in the parsed class a specific entry within the
1212
/// lambda_method_handle_map with a matching descriptor. Will fail if no
1313
/// matching lambda entry found.
14-
/// \param parsed_class: the class to inspect
15-
/// \param lambda_method_ref: the reference/descriptor of the lambda method
16-
/// to which this lambda entry points to, must be unique
17-
/// \param method_type: the descriptor the lambda method should have
14+
/// \param parsed_class the class to inspect
15+
/// \param lambda_method_ref the reference/descriptor of the lambda method
16+
/// to which this lambda entry points to, must be unique
17+
/// \param method_type the descriptor the lambda method should have
1818
/// \return
1919
require_parse_tree::lambda_method_handlet
2020
require_parse_tree::require_lambda_entry_for_descriptor(
@@ -29,28 +29,20 @@ require_parse_tree::require_lambda_entry_for_descriptor(
2929
"Looking for entry with lambda_method_ref: " << lambda_method_ref
3030
<< " and method_type: "
3131
<< method_type);
32-
const auto num_matches = std::count_if(
32+
std::vector<lambda_method_entryt> matches;
33+
std::copy_if(
3334
parsed_class.lambda_method_handle_map.begin(),
3435
parsed_class.lambda_method_handle_map.end(),
35-
[&method_type, &lambda_method_ref](const lambda_method_entryt &entry) {
36+
back_inserter(matches),
37+
[&method_type,
38+
&lambda_method_ref](const lambda_method_entryt &entry) { //NOLINT
3639
return (
3740
entry.second.method_type == method_type &&
3841
entry.second.lambda_method_ref == lambda_method_ref);
3942
});
40-
41-
REQUIRE(num_matches == 1);
42-
INFO("Entry found");
43-
const auto matching_lambda_entry = std::find_if(
44-
parsed_class.lambda_method_handle_map.begin(),
45-
parsed_class.lambda_method_handle_map.end(),
46-
[&method_type, &lambda_method_ref](const lambda_method_entryt &entry) {
47-
return (
48-
entry.second.method_type == method_type &&
49-
entry.second.lambda_method_ref == lambda_method_ref);
50-
});
51-
REQUIRE(matching_lambda_entry != parsed_class.lambda_method_handle_map.end());
52-
53-
return matching_lambda_entry->second;
43+
INFO("Number of matching lambda method entries: " << matches.size());
44+
REQUIRE(matches.size() == 1);
45+
return matches.at(0).second;
5446
}
5547

5648
/// Finds a specific method in the parsed class with a matching name.

0 commit comments

Comments
 (0)