From 8df46f8e642e28a696f12953641f9cfaf1f739a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 4 Nov 2014 16:21:59 -0600 Subject: Adjusting to use iterators --- tests/indicator-fixture.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/indicator-fixture.h') diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h index b8614a6..4f08ab5 100644 --- a/tests/indicator-fixture.h +++ b/tests/indicator-fixture.h @@ -154,21 +154,21 @@ class IndicatorFixture : public ::testing::Test return menuval; } - std::shared_ptr getMenuAttributeRecurse (const std::vector menuLocation, const std::string& attribute, std::shared_ptr& value, unsigned int index, std::shared_ptr& menu) { - if (index >= menuLocation.size()) + std::shared_ptr getMenuAttributeRecurse (std::vector::const_iterator menuLocation, std::vector::const_iterator menuEnd, const std::string& attribute, std::shared_ptr& value, std::shared_ptr& menu) { + if (menuLocation == menuEnd) return nullptr; - if (menuLocation.size() - 1 == index) - return getMenuAttributeVal(menuLocation[index], menu, attribute, value); + if (menuLocation + 1 == menuEnd) + return getMenuAttributeVal(*menuLocation, menu, attribute, value); - auto submenu = std::shared_ptr(g_menu_model_get_item_link(menu.get(), menuLocation[index], G_MENU_LINK_SUBMENU), [](GMenuModel * modelptr) { + auto submenu = std::shared_ptr(g_menu_model_get_item_link(menu.get(), *menuLocation, G_MENU_LINK_SUBMENU), [](GMenuModel * modelptr) { g_clear_object(&modelptr); }); if (submenu == nullptr) return nullptr; - return getMenuAttributeRecurse(menuLocation, attribute, value, index++, submenu); + return getMenuAttributeRecurse(menuLocation + 1, menuEnd, attribute, value, submenu); } bool expectMenuAttribute (const std::vector menuLocation, const std::string& attribute, GVariant * value) { @@ -177,7 +177,7 @@ class IndicatorFixture : public ::testing::Test g_variant_unref(varptr); }); - auto attrib = getMenuAttributeRecurse(menuLocation, attribute, varref, 0, _menu); + auto attrib = getMenuAttributeRecurse(menuLocation.cbegin(), menuLocation.cend(), attribute, varref, _menu); bool same = false; if (attrib != nullptr && varref != nullptr) { -- cgit v1.2.3