- unsigned int it2_unit;
- /* search it, first (we won't reuse it for external loop which gets broken) */
- for (it2_unit = 0;
- it2_unit < xbt_dynar_length(thissuite->units);
- it2_unit++) {
- xbt_test_unit_t thisunit = xbt_dynar_get_as(thissuite->units, it2_unit, xbt_test_unit_t);
- if (not strcmp(thisunit->name, unitname)) {
- thisunit->enabled = enabling;
- break;
- }
- } /* search relevant unit */
- xbt_assert(it2_unit != xbt_dynar_length(thissuite->units),
- "Suite '%s' has no unit of name '%s'. Cannot apply the selection\n", suitename, unitname);
+ /* search relevant unit */
+ auto unit = std::find_if(begin(thissuite->units), end(thissuite->units),
+ [&unitname](s_xbt_test_unit const& unit) { return unit.name_ == unitname; });
+ if (unit == end(thissuite->units))
+ xbt_die("Suite '%s' has no unit of name '%s'. Cannot apply the selection\n", suitename, unitname);
+ unit->enabled_ = enabling;