From b3d8778a52576b66ab00b08aa939612136a49a01 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 17 Sep 2014 11:51:51 -0500 Subject: fix flint++ warnings --- tests/actions-mock.h | 2 +- tests/geoclue-fixture.h | 8 ++++++-- tests/glib-fixture.h | 13 +++++++++++-- tests/manual-test-snap.cpp | 2 +- tests/state-fixture.h | 24 +++++++++++++++++++++++- tests/state-mock.h | 20 +++++++++++++++++++- tests/test-actions.cpp | 4 ++-- tests/test-dbus-fixture.h | 14 ++++++++++---- tests/test-exporter.cpp | 10 +++++----- tests/test-formatter.cpp | 12 ++++++------ tests/test-live-actions.cpp | 10 ++++++---- tests/test-locations.cpp | 4 ++-- tests/test-menus.cpp | 4 ++-- tests/test-settings.cpp | 4 ++-- tests/test-snap.cpp | 8 ++++---- tests/test-timezone-file.cpp | 4 ++-- tests/test-timezones.cpp | 2 +- 17 files changed, 103 insertions(+), 42 deletions(-) (limited to 'tests') diff --git a/tests/actions-mock.h b/tests/actions-mock.h index 77315c0..9421708 100644 --- a/tests/actions-mock.h +++ b/tests/actions-mock.h @@ -31,7 +31,7 @@ namespace datetime { class MockActions: public Actions { public: - MockActions(std::shared_ptr& state_in): Actions(state_in) {} + explicit MockActions(const std::shared_ptr& state_in): Actions(state_in) {} ~MockActions() =default; enum Action { DesktopOpenAlarmApp, diff --git a/tests/geoclue-fixture.h b/tests/geoclue-fixture.h index 0c597d3..d028ec9 100644 --- a/tests/geoclue-fixture.h +++ b/tests/geoclue-fixture.h @@ -17,6 +17,9 @@ * with this program. If not, see . */ +#ifndef INDICATOR_DATETIME_TESTS_GEOCLUE_FIXTURE_H +#define INDICATOR_DATETIME_TESTS_GEOCLUE_FIXTURE_H + #include "glib-fixture.h" #include @@ -39,7 +42,7 @@ class GeoclueFixture : public GlibFixture DbusTestDbusMockObject * obj_geo_addr = nullptr; const std::string timezone_1 = "America/Denver"; - void SetUp () + void SetUp () override { super::SetUp(); @@ -80,7 +83,7 @@ class GeoclueFixture : public GlibFixture g_string_free (gstr, TRUE); } - virtual void TearDown () + void TearDown () override { g_clear_object (&mock); g_clear_object (&service); @@ -148,3 +151,4 @@ public: }; +#endif /* INDICATOR_DATETIME_TESTS_GEOCLUE_FIXTURE_H */ diff --git a/tests/glib-fixture.h b/tests/glib-fixture.h index 1914b8c..f888c59 100644 --- a/tests/glib-fixture.h +++ b/tests/glib-fixture.h @@ -17,6 +17,9 @@ * with this program. If not, see . */ +#ifndef INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H +#define INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H + #include #include @@ -29,6 +32,10 @@ class GlibFixture : public ::testing::Test { + public: + + virtual ~GlibFixture() =default; + private: //GLogFunc realLogHandler; @@ -59,7 +66,7 @@ class GlibFixture : public ::testing::Test protected: - virtual void SetUp() + virtual void SetUp() override { setlocale(LC_ALL, "C.UTF-8"); @@ -76,7 +83,7 @@ class GlibFixture : public ::testing::Test } - virtual void TearDown() + virtual void TearDown() override { #if 0 // confirm there aren't any unexpected log messages @@ -136,3 +143,5 @@ class GlibFixture : public ::testing::Test GMainLoop * loop; }; + +#endif /* INDICATOR_DATETIME_TESTS_GLIB_FIXTURE_H */ diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp index 369e6cd..d4d9ec9 100644 --- a/tests/manual-test-snap.cpp +++ b/tests/manual-test-snap.cpp @@ -47,7 +47,7 @@ namespace GOptionEntry entries[] = { { "volume", 'v', 0, G_OPTION_ARG_INT, &volume, "Volume level [1..100]", "volume" }, - { NULL } + { nullptr } }; } diff --git a/tests/state-fixture.h b/tests/state-fixture.h index 7d8358e..e466a79 100644 --- a/tests/state-fixture.h +++ b/tests/state-fixture.h @@ -17,18 +17,30 @@ * Charles Kerr */ +#ifndef INDICATOR_DATETIME_TESTS_STATE_FIXTURE_H +#define INDICATOR_DATETIME_TESTS_STATE_FIXTURE_H + #include "glib-fixture.h" #include "actions-mock.h" #include "state-mock.h" -using namespace unity::indicator::datetime; +namespace unity { +namespace indicator { +namespace datetime { + +/*** +**** +***/ class StateFixture: public GlibFixture { private: typedef GlibFixture super; +public: + virtual ~StateFixture() =default; + protected: std::shared_ptr m_mock_state; std::shared_ptr m_state; @@ -56,5 +68,15 @@ protected: super::TearDown(); } + }; +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif /* INDICATOR_DATETIME_TESTS_STATE_FIXTURE_H */ diff --git a/tests/state-mock.h b/tests/state-mock.h index 792c60d..caa6393 100644 --- a/tests/state-mock.h +++ b/tests/state-mock.h @@ -17,12 +17,21 @@ * Charles Kerr */ +#ifndef INDICATOR_DATETIME_STATE_MOCK_H +#define INDICATOR_DATETIME_STATE_MOCK_H + #include "planner-mock.h" #include #include -using namespace unity::indicator::datetime; +namespace unity { +namespace indicator { +namespace datetime { + +/*** +**** +***/ class MockState: public State { @@ -47,3 +56,12 @@ public: } }; +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif /* INDICATOR_DATETIME_STATE_MOCK_H */ diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp index 9f7856c..aefeac0 100644 --- a/tests/test-actions.cpp +++ b/tests/test-actions.cpp @@ -55,12 +55,12 @@ class ActionsFixture: public StateFixture protected: - virtual void SetUp() + void SetUp() override { super::SetUp(); } - virtual void TearDown() + void TearDown() override { super::TearDown(); } diff --git a/tests/test-dbus-fixture.h b/tests/test-dbus-fixture.h index db06be2..a894f11 100644 --- a/tests/test-dbus-fixture.h +++ b/tests/test-dbus-fixture.h @@ -17,6 +17,9 @@ * Charles Kerr */ +#ifndef INDICATOR_DATETIME_TESTS_DBUS_FIXTURE_H +#define INDICATOR_DATETIME_TESTS_DBUS_FIXTURE_H + #include "glib-fixture.h" /*** @@ -27,9 +30,10 @@ class TestDBusFixture: public GlibFixture { public: - TestDBusFixture() {} + TestDBusFixture() =default; + virtual ~TestDBusFixture() =default; - TestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} + explicit TestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} private: @@ -65,7 +69,7 @@ class TestDBusFixture: public GlibFixture GDBusConnection * system_bus; const std::vector service_dirs; - virtual void SetUp () + virtual void SetUp() override { super::SetUp (); @@ -84,7 +88,7 @@ class TestDBusFixture: public GlibFixture g_main_loop_run (loop); } - virtual void TearDown () + virtual void TearDown() override { wait_msec(); @@ -100,3 +104,5 @@ class TestDBusFixture: public GlibFixture super::TearDown(); } }; + +#endif /* INDICATOR_DATETIME_TESTS_DBUS_FIXTURE_H */ diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index ec19ef4..be8fcc3 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -42,7 +42,7 @@ protected: GTestDBus* bus = nullptr; - void SetUp() + void SetUp() override { super::SetUp(); @@ -54,7 +54,7 @@ protected: g_setenv("DBUS_SESSION_BUS_ADDRESS", address, true); } - void TearDown() + void TearDown() override { GError * error = nullptr; GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); @@ -76,9 +76,9 @@ TEST_F(ExporterFixture, HelloWorld) TEST_F(ExporterFixture, Publish) { - std::shared_ptr state(new MockState); - std::shared_ptr actions(new MockActions(state)); - std::shared_ptr settings(new Settings); + auto state = std::make_shared(); + auto actions = std::make_shared(state); + auto settings = std::make_shared(); std::vector> menus; MenuFactory menu_factory (actions, state); diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp index 01df4f2..d011fea 100644 --- a/tests/test-formatter.cpp +++ b/tests/test-formatter.cpp @@ -46,7 +46,7 @@ class FormatterFixture: public GlibFixture std::shared_ptr m_settings; - virtual void SetUp() + void SetUp() override { super::SetUp(); @@ -54,7 +54,7 @@ class FormatterFixture: public GlibFixture m_original_locale = g_strdup(setlocale(LC_TIME, nullptr)); } - virtual void TearDown() + void TearDown() override { m_settings.reset(); @@ -90,7 +90,7 @@ class FormatterFixture: public GlibFixture TEST_F(FormatterFixture, TestPhoneHeader) { auto now = g_date_time_new_local(2020, 10, 31, 18, 30, 59); - std::shared_ptr clock(new MockClock(DateTime(now))); + auto clock = std::make_shared(DateTime(now)); g_date_time_unref(now); // test the default value in a 24h locale @@ -143,7 +143,7 @@ TEST_F(FormatterFixture, TestDesktopHeader) }; auto now = g_date_time_new_local(2020, 10, 31, 18, 30, 59); - std::shared_ptr clock(new MockClock(DateTime(now))); + auto clock = std::make_shared(DateTime(now)); g_date_time_unref(now); for(const auto& test_case : test_cases) @@ -193,7 +193,7 @@ TEST_F(FormatterFixture, TestUpcomingTimes) { if (test_case.is_12h ? Set12hLocale() : Set24hLocale()) { - std::shared_ptr clock (new MockClock(DateTime(test_case.now))); + auto clock = std::make_shared(DateTime(test_case.now)); DesktopFormatter f(clock, m_settings); const auto fmt = f.relative_format(test_case.then); @@ -236,7 +236,7 @@ TEST_F(FormatterFixture, TestEventTimes) { if (test_case.is_12h ? Set12hLocale() : Set24hLocale()) { - std::shared_ptr clock(new MockClock(DateTime(test_case.now))); + auto clock = std::make_shared(DateTime(test_case.now)); DesktopFormatter f(clock, m_settings); const auto fmt = f.relative_format(test_case.then, test_case.then_end); diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp index c67b380..2cd6eef 100644 --- a/tests/test-live-actions.cpp +++ b/tests/test-live-actions.cpp @@ -26,17 +26,19 @@ **** ***/ +using namespace unity::indicator::datetime; + class MockLiveActions: public LiveActions { public: std::string last_cmd; std::string last_url; - MockLiveActions(const std::shared_ptr& state_in): LiveActions(state_in) {} - virtual ~MockLiveActions() {} + explicit MockLiveActions(const std::shared_ptr& state_in): LiveActions(state_in) {} + ~MockLiveActions() {} protected: - void dispatch_url(const std::string& url) { last_url = url; } - void execute_command(const std::string& cmd) { last_cmd = cmd; } + void dispatch_url(const std::string& url) override { last_url = url; } + void execute_command(const std::string& cmd) override { last_cmd = cmd; } }; /*** diff --git a/tests/test-locations.cpp b/tests/test-locations.cpp index 48e845a..61a6ffd 100644 --- a/tests/test-locations.cpp +++ b/tests/test-locations.cpp @@ -47,7 +47,7 @@ class LocationsFixture: public GlibFixture const std::string nyc = "America/New_York"; const std::string chicago = "America/Chicago"; - virtual void SetUp() + void SetUp() override { super::SetUp(); @@ -65,7 +65,7 @@ class LocationsFixture: public GlibFixture m_timezones->timezones.set(std::set({ nyc, chicago })); } - virtual void TearDown() + void TearDown() override { m_timezones.reset(); m_settings.reset(); diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp index f5f8df2..363a132 100644 --- a/tests/test-menus.cpp +++ b/tests/test-menus.cpp @@ -39,7 +39,7 @@ protected: std::shared_ptr m_menu_factory; std::vector> m_menus; - virtual void SetUp() + void SetUp() override { super::SetUp(); @@ -49,7 +49,7 @@ protected: m_menus.push_back(m_menu_factory->buildMenu(Menu::Profile(i))); } - virtual void TearDown() + void TearDown() override { m_menus.clear(); m_menu_factory.reset(); diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp index 5dfb5ae..44037f7 100644 --- a/tests/test-settings.cpp +++ b/tests/test-settings.cpp @@ -39,7 +39,7 @@ protected: std::shared_ptr m_settings; GSettings * m_gsettings; - virtual void SetUp() + void SetUp() override { super::SetUp(); @@ -48,7 +48,7 @@ protected: m_settings = std::dynamic_pointer_cast(m_live); } - virtual void TearDown() + void TearDown() override { g_clear_object(&m_gsettings); m_settings.reset(); diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp index 5afaab1..21202f4 100644 --- a/tests/test-snap.cpp +++ b/tests/test-snap.cpp @@ -96,7 +96,7 @@ protected: DbusTestDbusMockObject * screen_obj = nullptr; DbusTestDbusMockObject * haptic_obj = nullptr; - void SetUp() + void SetUp() override { GError * error = nullptr; char * str = nullptr; @@ -269,18 +269,18 @@ protected: dbus_test_service_start_tasks(service); g_setenv("DBUS_SYSTEM_BUS_ADDRESS", g_getenv("DBUS_SESSION_BUS_ADDRESS"), TRUE); - session_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + session_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr); ASSERT_NE(nullptr, session_bus); g_dbus_connection_set_exit_on_close(session_bus, false); g_object_add_weak_pointer(G_OBJECT(session_bus), (gpointer *)&session_bus); - system_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); + system_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, nullptr); ASSERT_NE(nullptr, system_bus); g_dbus_connection_set_exit_on_close(system_bus, FALSE); g_object_add_weak_pointer(G_OBJECT(system_bus), (gpointer *)&system_bus); } - virtual void TearDown() + void TearDown() override { g_clear_object(&haptic_mock); g_clear_object(&screen_mock); diff --git a/tests/test-timezone-file.cpp b/tests/test-timezone-file.cpp index aec597c..8968429 100644 --- a/tests/test-timezone-file.cpp +++ b/tests/test-timezone-file.cpp @@ -52,12 +52,12 @@ class TimezoneFixture: public GlibFixture protected: - virtual void SetUp() + void SetUp() override { super::SetUp(); } - virtual void TearDown() + void TearDown() override { super::TearDown(); } diff --git a/tests/test-timezones.cpp b/tests/test-timezones.cpp index 3f02761..9e5c9cf 100644 --- a/tests/test-timezones.cpp +++ b/tests/test-timezones.cpp @@ -52,7 +52,7 @@ TEST_F(TimezonesFixture, ManagerTest) std::string timezone_geo = "America/Denver"; set_file(timezone_file); - std::shared_ptr settings(new Settings); + auto settings = std::make_shared(); LiveTimezones z(settings, TIMEZONE_FILE); wait_msec(500); // wait for the bus to get set up EXPECT_EQ(timezone_file, z.timezone.get()); -- cgit v1.2.3