mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
tests: add qPrefPartialPressureGas testcases
add test cases to secure struct preferences and qPrefPartialPressureGas work together Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
9d005888fb
commit
1e8e9f345a
3 changed files with 165 additions and 0 deletions
|
@ -110,6 +110,7 @@ TEST(TestQPrefFacebook testqPrefFacebook.cpp)
|
|||
TEST(TestQPrefGeocoding testqPrefGeocoding.cpp)
|
||||
TEST(TestQPrefLanguage testqPrefLanguage.cpp)
|
||||
TEST(TestQPrefLocationService testqPrefLocationService.cpp)
|
||||
TEST(TestQPrefPartialPressureGas testqPrefPartialPressureGas.cpp)
|
||||
TEST(TestQPrefProxy testqPrefProxy.cpp)
|
||||
TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp)
|
||||
TEST(TestQPrefUnits testqPrefUnits.cpp)
|
||||
|
@ -141,6 +142,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
|||
TestQPrefGeocoding
|
||||
TestQPrefLanguage
|
||||
TestQPrefLocationService
|
||||
TestQPrefPartialPressureGas
|
||||
TestQPrefProxy
|
||||
TestQPrefTechnicalDetails
|
||||
TestQPrefUnits
|
||||
|
|
144
tests/testqPrefPartialPressureGas.cpp
Normal file
144
tests/testqPrefPartialPressureGas.cpp
Normal file
|
@ -0,0 +1,144 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "testqPrefPartialPressureGas.h"
|
||||
|
||||
#include "core/pref.h"
|
||||
#include "core/qthelper.h"
|
||||
#include "core/settings/qPref.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
void TestQPrefPartialPressureGas::initTestCase()
|
||||
{
|
||||
QCoreApplication::setOrganizationName("Subsurface");
|
||||
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
||||
QCoreApplication::setApplicationName("SubsurfaceTestQPrefPartialPressureGas");
|
||||
}
|
||||
|
||||
void TestQPrefPartialPressureGas::test_struct_get()
|
||||
{
|
||||
// Test struct pref -> get func.
|
||||
|
||||
auto tst = qPrefPartialPressureGas::instance();
|
||||
|
||||
prefs.pp_graphs.phe = true;
|
||||
prefs.pp_graphs.phe_threshold = 21.2;
|
||||
prefs.pp_graphs.pn2 = true;
|
||||
prefs.pp_graphs.pn2_threshold = 21.3;
|
||||
prefs.pp_graphs.po2 = true;
|
||||
prefs.pp_graphs.po2_threshold_max = 21.4;
|
||||
prefs.pp_graphs.po2_threshold_min = 21.5;
|
||||
|
||||
QCOMPARE(tst->phe(), prefs.pp_graphs.phe);
|
||||
QCOMPARE(tst->phe_threshold(), prefs.pp_graphs.phe_threshold);
|
||||
QCOMPARE(tst->pn2(), prefs.pp_graphs.pn2);
|
||||
QCOMPARE(tst->pn2_threshold(), prefs.pp_graphs.pn2_threshold);
|
||||
QCOMPARE(tst->po2(), prefs.pp_graphs.po2);
|
||||
QCOMPARE(tst->po2_threshold_max(), prefs.pp_graphs.po2_threshold_max);
|
||||
QCOMPARE(tst->po2_threshold_min(), prefs.pp_graphs.po2_threshold_min);
|
||||
}
|
||||
|
||||
void TestQPrefPartialPressureGas::test_set_struct()
|
||||
{
|
||||
// Test set func -> struct pref
|
||||
|
||||
auto tst = qPrefPartialPressureGas::instance();
|
||||
|
||||
tst->set_phe(false);
|
||||
tst->set_phe_threshold(22.2);
|
||||
tst->set_pn2(false);
|
||||
tst->set_pn2_threshold(22.3);
|
||||
tst->set_po2(false);
|
||||
tst->set_po2_threshold_max(22.4);
|
||||
tst->set_po2_threshold_min(22.5);
|
||||
|
||||
QCOMPARE(prefs.pp_graphs.phe, false);
|
||||
QCOMPARE(prefs.pp_graphs.phe_threshold, 22.2);
|
||||
QCOMPARE(prefs.pp_graphs.pn2, false);
|
||||
QCOMPARE(prefs.pp_graphs.pn2_threshold, 22.3);
|
||||
QCOMPARE(prefs.pp_graphs.po2, false);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_max, 22.4);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_min, 22.5);
|
||||
}
|
||||
|
||||
void TestQPrefPartialPressureGas::test_set_load_struct()
|
||||
{
|
||||
// test set func -> load -> struct pref
|
||||
|
||||
auto tst = qPrefPartialPressureGas::instance();
|
||||
|
||||
tst->set_phe(true);
|
||||
tst->set_phe_threshold(23.2);
|
||||
tst->set_pn2(true);
|
||||
tst->set_pn2_threshold(23.3);
|
||||
tst->set_po2(true);
|
||||
tst->set_po2_threshold_max(23.4);
|
||||
tst->set_po2_threshold_min(23.5);
|
||||
|
||||
prefs.pp_graphs.phe = false;
|
||||
prefs.pp_graphs.phe_threshold = 21.2;
|
||||
prefs.pp_graphs.pn2 = false;
|
||||
prefs.pp_graphs.pn2_threshold = 21.3;
|
||||
prefs.pp_graphs.po2 = false;
|
||||
prefs.pp_graphs.po2_threshold_max = 21.4;
|
||||
prefs.pp_graphs.po2_threshold_min = 21.5;
|
||||
|
||||
tst->load();
|
||||
QCOMPARE(prefs.pp_graphs.phe, true);
|
||||
QCOMPARE(prefs.pp_graphs.phe_threshold, 23.2);
|
||||
QCOMPARE(prefs.pp_graphs.pn2, true);
|
||||
QCOMPARE(prefs.pp_graphs.pn2_threshold, 23.3);
|
||||
QCOMPARE(prefs.pp_graphs.po2, true);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_max, 23.4);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_min, 23.5);
|
||||
}
|
||||
|
||||
void TestQPrefPartialPressureGas::test_struct_disk()
|
||||
{
|
||||
// test struct prefs -> disk
|
||||
|
||||
auto tst = qPrefPartialPressureGas::instance();
|
||||
|
||||
prefs.pp_graphs.phe = false;
|
||||
prefs.pp_graphs.phe_threshold = 24.2;
|
||||
prefs.pp_graphs.pn2 = false;
|
||||
prefs.pp_graphs.pn2_threshold = 24.3;
|
||||
prefs.pp_graphs.po2 = false;
|
||||
prefs.pp_graphs.po2_threshold_max = 24.4;
|
||||
prefs.pp_graphs.po2_threshold_min = 24.5;
|
||||
|
||||
tst->sync();
|
||||
prefs.pp_graphs.phe = true;
|
||||
prefs.pp_graphs.phe_threshold = 1.2;
|
||||
prefs.pp_graphs.pn2 = true;
|
||||
prefs.pp_graphs.pn2_threshold = 1.3;
|
||||
prefs.pp_graphs.po2 = true;
|
||||
prefs.pp_graphs.po2_threshold_max = 1.4;
|
||||
prefs.pp_graphs.po2_threshold_min = 1.5;
|
||||
|
||||
tst->load();
|
||||
QCOMPARE(prefs.pp_graphs.phe, false);
|
||||
QCOMPARE(prefs.pp_graphs.phe_threshold, 24.2);
|
||||
QCOMPARE(prefs.pp_graphs.pn2, false);
|
||||
QCOMPARE(prefs.pp_graphs.pn2_threshold, 24.3);
|
||||
QCOMPARE(prefs.pp_graphs.po2, false);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_max, 24.4);
|
||||
QCOMPARE(prefs.pp_graphs.po2_threshold_min, 24.5);
|
||||
}
|
||||
|
||||
void TestQPrefPartialPressureGas::test_multiple()
|
||||
{
|
||||
// test multiple instances have the same information
|
||||
|
||||
prefs.pp_graphs.phe_threshold = 2.2;
|
||||
auto tst_direct = new qPrefPartialPressureGas;
|
||||
|
||||
prefs.pp_graphs.pn2_threshold = 2.3;
|
||||
auto tst = qPrefPartialPressureGas::instance();
|
||||
|
||||
QCOMPARE(tst->phe_threshold(), tst_direct->phe_threshold());
|
||||
QCOMPARE(tst->pn2_threshold(), tst_direct->pn2_threshold());
|
||||
QCOMPARE(tst_direct->phe_threshold(), 2.2);
|
||||
QCOMPARE(tst_direct->pn2_threshold(), 2.3);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestQPrefPartialPressureGas)
|
19
tests/testqPrefPartialPressureGas.h
Normal file
19
tests/testqPrefPartialPressureGas.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef TESTQPREFPARTIALPRESSUREGAS_H
|
||||
#define TESTQPREFPARTIALPRESSUREGAS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class TestQPrefPartialPressureGas : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void test_struct_get();
|
||||
void test_set_struct();
|
||||
void test_set_load_struct();
|
||||
void test_struct_disk();
|
||||
void test_multiple();
|
||||
};
|
||||
|
||||
#endif // TESTQPREFPARTIALPRESSUREGAS_H
|
Loading…
Add table
Reference in a new issue