From dd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 18 Nov 2017 16:06:41 +0100 Subject: Make handling of booleans consistent on the C++-side of preferences In general, the C++-side of the preferences code consistently uses the bool data type for boolean settings. There are five exceptions, which use short instead: showPo2 showPn2 showPhe saveUserIdLocal displayInvalidDives This patch attempts to make the code more consistent by turning these into bools as well. Tests showed that writing as short and reading as bool is handled gracefully by the Qt variant code. Therefore, an upgrade should not cause user-visible changes to their settings. As a bonus, two extern declarations of the set_save_userid_local() function, which is not defined anywhere, were removed. Signed-off-by: Berthold Stoeger --- tests/testpreferences.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tests/testpreferences.cpp') diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index ae8ad6132..bc6e90213 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -61,11 +61,10 @@ void TestPreferences::testPreferences() cloud->setSavePasswordLocal(false); TEST(cloud->savePasswordLocal(), false); - // Why this is short and not bool? cloud->setSaveUserIdLocal(1); - TEST(cloud->saveUserIdLocal(), (short)1); + TEST(cloud->saveUserIdLocal(), true); cloud->setSaveUserIdLocal(0); - TEST(cloud->saveUserIdLocal(), (short)0); + TEST(cloud->saveUserIdLocal(), false); cloud->setUserId("Tomaz"); TEST(cloud->userId(), QStringLiteral("Tomaz")); @@ -189,9 +188,9 @@ void TestPreferences::testPreferences() pp->setPn2Threshold(3.0); pp->setPheThreshold(4.0); - TEST(pp->showPn2(), (short) false); - TEST(pp->showPhe(), (short) false); - TEST(pp->showPo2(), (short) false); + TEST(pp->showPn2(), false); + TEST(pp->showPhe(), false); + TEST(pp->showPo2(), false); TEST(pp->pn2Threshold(), 3.0); TEST(pp->pheThreshold(), 4.0); TEST(pp->po2ThresholdMin(), 1.0); @@ -205,9 +204,9 @@ void TestPreferences::testPreferences() pp->setPn2Threshold(6.0); pp->setPheThreshold(7.0); - TEST(pp->showPn2(), (short) true); - TEST(pp->showPhe(), (short) true); - TEST(pp->showPo2(), (short) true); + TEST(pp->showPn2(), true); + TEST(pp->showPhe(), true); + TEST(pp->showPo2(), true); TEST(pp->pn2Threshold(), 6.0); TEST(pp->pheThreshold(), 7.0); TEST(pp->po2ThresholdMin(), 4.0); @@ -457,7 +456,7 @@ void TestPreferences::testPreferences() TEST(display->divelistFont(),QStringLiteral("comic")); TEST(display->fontSize(), 10.0); - TEST(display->displayInvalidDives(),(short) true); //TODO: this is true / false. + TEST(display->displayInvalidDives(), true); display->setDivelistFont("helvetica"); display->setFontSize(14.0); @@ -465,7 +464,7 @@ void TestPreferences::testPreferences() TEST(display->divelistFont(),QStringLiteral("helvetica")); TEST(display->fontSize(), 14.0); - TEST(display->displayInvalidDives(),(short) false); + TEST(display->displayInvalidDives(), false); auto language = pref->language_settings; language->setLangLocale ("en_US"); -- cgit v1.2.3-70-g09d2