diff options
author | jan Iversen <jan@casacondor.com> | 2020-01-07 14:31:49 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-20 09:55:26 -0800 |
commit | 6e065506317e2595a0df19dba147576d392c9506 (patch) | |
tree | 9061a855826df17a5acf6cb4b207c205694db7dd /tests | |
parent | 13b2b9f19c3f9ecb41565c5eab07d590071dede6 (diff) | |
download | subsurface-6e065506317e2595a0df19dba147576d392c9506.tar.gz |
core/settings:: remove string functions for units
Remove string version of unit_system, duration_units, length, pressure,
temperature, vertical_speed_time, and volume, including tests and make signals
strongly typed in C++
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testplannershared.cpp | 8 | ||||
-rw-r--r-- | tests/testqPrefUnits.cpp | 68 |
2 files changed, 38 insertions, 38 deletions
diff --git a/tests/testplannershared.cpp b/tests/testplannershared.cpp index a0af6dc37..d9b03c247 100644 --- a/tests/testplannershared.cpp +++ b/tests/testplannershared.cpp @@ -61,7 +61,7 @@ void TestPlannerShared::test_rates() { // Set system to use meters - qPrefUnits::set_unit_system(QStringLiteral("metric")); + qPrefUnits::set_unit_system(METRIC); plannerShared::set_ascratelast6m(16); QCOMPARE(qPrefDivePlanner::ascratelast6m(), 267); @@ -109,7 +109,7 @@ void TestPlannerShared::test_rates() QCOMPARE(plannerShared::descrate(), 10); // Set system to use feet - qPrefUnits::set_unit_system(QStringLiteral("imperial")); + qPrefUnits::set_unit_system(IMPERIAL); plannerShared::set_ascratelast6m(33); QCOMPARE(qPrefDivePlanner::ascratelast6m(), 168); @@ -197,7 +197,7 @@ void TestPlannerShared::test_gas() QCOMPARE(plannerShared::problemsolvingtime(), 6); // Set system to use meters - qPrefUnits::set_unit_system(QStringLiteral("metric")); + qPrefUnits::set_unit_system(METRIC); plannerShared::set_bottomsac(30); QCOMPARE(qPrefDivePlanner::bottomsac(), 30000); @@ -245,7 +245,7 @@ void TestPlannerShared::test_gas() QCOMPARE(plannerShared::bestmixend(), 10); // Set system to use feet - qPrefUnits::set_unit_system(QStringLiteral("imperial")); + qPrefUnits::set_unit_system(IMPERIAL); plannerShared::set_bottomsac(0.9); QCOMPARE(qPrefDivePlanner::bottomsac(), 25485); diff --git a/tests/testqPrefUnits.cpp b/tests/testqPrefUnits.cpp index c5635732b..81f9f2f24 100644 --- a/tests/testqPrefUnits.cpp +++ b/tests/testqPrefUnits.cpp @@ -34,14 +34,14 @@ void TestQPrefUnits::test_struct_get() prefs.units.weight = units::KG; QCOMPARE(tst->coordinates_traditional(), true); - QCOMPARE(tst->duration_units(), QStringLiteral("mixed")); - QCOMPARE(tst->length(), QStringLiteral("meters")); - QCOMPARE(tst->pressure(), QStringLiteral("bar")); + QCOMPARE(tst->duration_units(), units::MIXED); + QCOMPARE(tst->length(), units::METERS); + QCOMPARE(tst->pressure(), units::BAR); QCOMPARE(tst->show_units_table(), true); - QCOMPARE(tst->temperature(), QStringLiteral("celcius")); - QCOMPARE(tst->vertical_speed_time(), QStringLiteral("seconds")); - QCOMPARE(tst->volume(), QStringLiteral("liter")); - QCOMPARE(tst->weight(), QStringLiteral("kg")); + QCOMPARE(tst->temperature(), units::CELSIUS); + QCOMPARE(tst->vertical_speed_time(), units::SECONDS); + QCOMPARE(tst->volume(), units::LITER); + QCOMPARE(tst->weight(), units::KG); } void TestQPrefUnits::test_set_struct() @@ -159,9 +159,9 @@ void TestQPrefUnits::test_multiple() auto tst = qPrefUnits::instance(); QCOMPARE(tst->length(), qPrefUnits::length()); - QCOMPARE(tst->length(), QStringLiteral("meters")); + QCOMPARE(tst->length(), units::METERS); QCOMPARE(tst->pressure(), qPrefUnits::pressure()); - QCOMPARE(tst->pressure(), QStringLiteral("bar")); + QCOMPARE(tst->pressure(), units::BAR); } void TestQPrefUnits::test_unit_system() @@ -170,22 +170,22 @@ void TestQPrefUnits::test_unit_system() auto tst = qPrefUnits::instance(); - tst->set_unit_system("metric"); + tst->set_unit_system(METRIC); QCOMPARE(prefs.unit_system, METRIC); - QCOMPARE(tst->unit_system(), QStringLiteral("metric")); - tst->set_unit_system("imperial"); + QCOMPARE(tst->unit_system(), METRIC); + tst->set_unit_system(IMPERIAL); QCOMPARE(prefs.unit_system, IMPERIAL); - QCOMPARE(tst->unit_system(), QStringLiteral("imperial")); - tst->set_unit_system("personalized"); + QCOMPARE(tst->unit_system(), IMPERIAL); + tst->set_unit_system(PERSONALIZE); QCOMPARE(prefs.unit_system, PERSONALIZE); - QCOMPARE(tst->unit_system(), QStringLiteral("personalized")); + QCOMPARE(tst->unit_system(), PERSONALIZE); prefs.unit_system = METRIC; - QCOMPARE(tst->unit_system(), QStringLiteral("metric")); + QCOMPARE(tst->unit_system(), METRIC); prefs.unit_system = IMPERIAL; - QCOMPARE(tst->unit_system(), QStringLiteral("imperial")); + QCOMPARE(tst->unit_system(), IMPERIAL); prefs.unit_system = PERSONALIZE; - QCOMPARE(tst->unit_system(), QStringLiteral("personalized")); + QCOMPARE(tst->unit_system(), PERSONALIZE); } #define TEST(METHOD, VALUE) \ @@ -203,17 +203,19 @@ void TestQPrefUnits::test_oldPreferences() units->set_volume(units::LITER); units->set_temperature(units::CELSIUS); units->set_weight(units::KG); - units->set_unit_system(QStringLiteral("metric")); + units->set_unit_system(METRIC); units->set_coordinates_traditional(false); units->set_vertical_speed_time(units::SECONDS); - TEST(units->length(), QStringLiteral("meters")); - TEST(units->pressure(), QStringLiteral("bar")); - TEST(units->volume(), QStringLiteral("liter")); - TEST(units->temperature(), QStringLiteral("celcius")); - TEST(units->weight(), QStringLiteral("kg")); - TEST(units->vertical_speed_time(), QStringLiteral("seconds")); - TEST(units->unit_system(), QStringLiteral("metric")); + TEST(units->length(), units::METERS); + TEST(units->pressure(), units::BAR); + TEST(units->volume(), units::LITER); + TEST(units->temperature(), units::CELSIUS); + TEST(units->weight(), units::KG); + TEST(units->vertical_speed_time(), units::SECONDS); + TEST(units->unit_system(), METRIC); + TEST(units->vertical_speed_time(), units::SECONDS); + TEST(units->unit_system(), METRIC); TEST(units->coordinates_traditional(), false); units->set_length(units::FEET); @@ -222,16 +224,14 @@ void TestQPrefUnits::test_oldPreferences() units->set_temperature(units::FAHRENHEIT); units->set_weight(units::LBS); units->set_vertical_speed_time(units::MINUTES); - units->set_unit_system(QStringLiteral("fake-metric-system")); units->set_coordinates_traditional(true); - TEST(units->length(), QStringLiteral("feet")); - TEST(units->pressure(), QStringLiteral("psi")); - TEST(units->volume(), QStringLiteral("cuft")); - TEST(units->temperature(), QStringLiteral("fahrenheit")); - TEST(units->weight(), QStringLiteral("lbs")); - TEST(units->vertical_speed_time(), QStringLiteral("minutes")); - TEST(units->unit_system(), QStringLiteral("personalized")); + TEST(units->length(), units::FEET); + TEST(units->pressure(), units::PSI); + TEST(units->volume(), units::CUFT); + TEST(units->temperature(), units::FAHRENHEIT); + TEST(units->weight(), units::LBS); + TEST(units->vertical_speed_time(), units::MINUTES); TEST(units->coordinates_traditional(), true); } |