mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:03:23 +00:00
tests: move Units test from testpreferences
Remove Units test in testpreferences add the same Units tests to testqPrefUnits Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
d9b7aaef76
commit
ccfd14211a
3 changed files with 50 additions and 39 deletions
|
@ -278,43 +278,6 @@ void TestPreferences::testPreferences()
|
||||||
|
|
||||||
TEST(planner->decoMode(), RECREATIONAL);
|
TEST(planner->decoMode(), RECREATIONAL);
|
||||||
|
|
||||||
auto units = qPrefUnits::instance();
|
|
||||||
units->set_length(units::METERS);
|
|
||||||
units->set_pressure(units::BAR);
|
|
||||||
units->set_volume(units::LITER);
|
|
||||||
units->set_temperature(units::CELSIUS);
|
|
||||||
units->set_weight(units::KG);
|
|
||||||
units->set_vertical_speed_time(units::SECONDS);
|
|
||||||
units->set_unit_system(QStringLiteral("metric"));
|
|
||||||
units->set_coordinates_traditional(false);
|
|
||||||
|
|
||||||
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(), QStringLiteral("metric"));
|
|
||||||
TEST(units->coordinates_traditional(), false);
|
|
||||||
|
|
||||||
units->set_length(units::FEET);
|
|
||||||
units->set_pressure(units::PSI);
|
|
||||||
units->set_volume(units::CUFT);
|
|
||||||
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(), 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->unit_system(), QStringLiteral("personalized"));
|
|
||||||
TEST(units->coordinates_traditional(), true);
|
|
||||||
|
|
||||||
auto general = pref->general_settings;
|
auto general = pref->general_settings;
|
||||||
general->setDefaultFilename("filename");
|
general->setDefaultFilename("filename");
|
||||||
general->setDefaultCylinder("cylinder_2");
|
general->setDefaultCylinder("cylinder_2");
|
||||||
|
|
|
@ -53,7 +53,7 @@ void TestQPrefUnits::test_set_struct()
|
||||||
tst->set_pressure(units::PSI);
|
tst->set_pressure(units::PSI);
|
||||||
tst->set_show_units_table(false);
|
tst->set_show_units_table(false);
|
||||||
tst->set_temperature(units::FAHRENHEIT);
|
tst->set_temperature(units::FAHRENHEIT);
|
||||||
tst->set_vertical_speed_time(units::MINUTES);
|
tst->set_vertical_speed_time(units::SECONDS);
|
||||||
tst->set_volume(units::CUFT);
|
tst->set_volume(units::CUFT);
|
||||||
tst->set_weight(units::LBS);
|
tst->set_weight(units::LBS);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void TestQPrefUnits::test_set_struct()
|
||||||
QCOMPARE(prefs.units.pressure, units::PSI);
|
QCOMPARE(prefs.units.pressure, units::PSI);
|
||||||
QCOMPARE(prefs.units.show_units_table, false);
|
QCOMPARE(prefs.units.show_units_table, false);
|
||||||
QCOMPARE(prefs.units.temperature, units::FAHRENHEIT);
|
QCOMPARE(prefs.units.temperature, units::FAHRENHEIT);
|
||||||
QCOMPARE(prefs.units.vertical_speed_time, units::MINUTES);
|
QCOMPARE(prefs.units.vertical_speed_time, units::SECONDS);
|
||||||
QCOMPARE(prefs.units.volume, units::CUFT);
|
QCOMPARE(prefs.units.volume, units::CUFT);
|
||||||
QCOMPARE(prefs.units.weight, units::LBS);
|
QCOMPARE(prefs.units.weight, units::LBS);
|
||||||
}
|
}
|
||||||
|
@ -186,4 +186,51 @@ void TestQPrefUnits::test_unit_system()
|
||||||
QCOMPARE(tst->unit_system(), QString("personalized"));
|
QCOMPARE(tst->unit_system(), QString("personalized"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST(METHOD, VALUE) \
|
||||||
|
QCOMPARE(METHOD, VALUE); \
|
||||||
|
units->sync(); \
|
||||||
|
units->load(); \
|
||||||
|
QCOMPARE(METHOD, VALUE);
|
||||||
|
|
||||||
|
void TestQPrefUnits::test_oldPreferences()
|
||||||
|
{
|
||||||
|
auto units = qPrefUnits::instance();
|
||||||
|
|
||||||
|
units->set_length(units::METERS);
|
||||||
|
units->set_pressure(units::BAR);
|
||||||
|
units->set_volume(units::LITER);
|
||||||
|
units->set_temperature(units::CELSIUS);
|
||||||
|
units->set_weight(units::KG);
|
||||||
|
units->set_unit_system(QStringLiteral("metric"));
|
||||||
|
units->set_coordinates_traditional(false);
|
||||||
|
units->set_vertical_speed_time(units::SECONDS);
|
||||||
|
|
||||||
|
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(), QStringLiteral("metric"));
|
||||||
|
TEST(units->coordinates_traditional(), false);
|
||||||
|
|
||||||
|
units->set_length(units::FEET);
|
||||||
|
units->set_pressure(units::PSI);
|
||||||
|
units->set_volume(units::CUFT);
|
||||||
|
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(), 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->unit_system(), QStringLiteral("personalized"));
|
||||||
|
TEST(units->coordinates_traditional(), true);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestQPrefUnits)
|
QTEST_MAIN(TestQPrefUnits)
|
||||||
|
|
|
@ -15,6 +15,7 @@ private slots:
|
||||||
void test_struct_disk();
|
void test_struct_disk();
|
||||||
void test_multiple();
|
void test_multiple();
|
||||||
void test_unit_system();
|
void test_unit_system();
|
||||||
|
void test_oldPreferences();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TESTQPREFUNITS_H
|
#endif // TESTQPREFUNITS_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue