diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-18 16:06:41 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-11-20 20:56:13 +0100 |
commit | dd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6 (patch) | |
tree | 5bf0f8872a35f71430733c9766bc70ad65cea499 /tests/testpreferences.cpp | |
parent | e762fd2d416cbe77669a83e302709aa3fbda68f7 (diff) | |
download | subsurface-dd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'tests/testpreferences.cpp')
-rw-r--r-- | tests/testpreferences.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
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"); |