Whitespace cleanup tests

Again, entirely script based.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-07-25 12:39:04 -07:00 committed by Lubomir I. Ivanov
parent 128fc5f4b8
commit afe7e847d6
27 changed files with 321 additions and 313 deletions

View file

@ -4,8 +4,7 @@
#include <QTest> #include <QTest>
class TestDiveSiteDuplication : public QObject class TestDiveSiteDuplication : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void testReadV2(); void testReadV2();

View file

@ -4,8 +4,7 @@
#include <QTest> #include <QTest>
class TestGitStorage : public QObject class TestGitStorage : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -104,13 +104,13 @@ void TestGpsCoords::testPrefixNoUnitParse()
void TestGpsCoords::testOurWeb() void TestGpsCoords::testOurWeb()
{ {
testParseOK("12° 8' 0.24\" , -68° 16' 58.44\"", testParseOK("12° 8' 0.24\" , -68° 16' 58.44\"",
coord2double(12, 8, 0.24 ), -coord2double(68, 16, 58.44)); coord2double(12, 8, 0.24), -coord2double(68, 16, 58.44));
} }
void TestGpsCoords::testGoogle() void TestGpsCoords::testGoogle()
{ {
testParseOK("12.133400, -68.282900", testParseOK("12.133400, -68.282900",
coord2double(12, 8, 0.24 ), -coord2double(68, 16, 58.44)); coord2double(12, 8, 0.24), -coord2double(68, 16, 58.44));
} }
void TestGpsCoords::testParseOK(const QString &txt, double expectedLat, void TestGpsCoords::testParseOK(const QString &txt, double expectedLat,

View file

@ -5,7 +5,7 @@
#include <QtTest> #include <QtTest>
class TestGpsCoords : public QObject { class TestGpsCoords : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testISO6709DParse(); void testISO6709DParse();
void testNegativeISO6709DParse(); void testNegativeISO6709DParse();

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testmerge.h" #include "testmerge.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/file.h"
#include "core/divelist.h" #include "core/divelist.h"
#include "core/file.h"
#include <QTextStream> #include <QTextStream>
void TestMerge::initTestCase() void TestMerge::initTestCase()
@ -34,7 +34,7 @@ void TestMerge::testMergeEmpty()
QTextStream outS(&out); QTextStream outS(&out);
QStringList readin = orgS.readAll().split("\n"); QStringList readin = orgS.readAll().split("\n");
QStringList written = outS.readAll().split("\n"); QStringList written = outS.readAll().split("\n");
while(readin.size() && written.size()){ while (readin.size() && written.size()) {
QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed()); QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed());
} }
} }
@ -57,7 +57,7 @@ void TestMerge::testMergeBackwards()
QTextStream outS(&out); QTextStream outS(&out);
QStringList readin = orgS.readAll().split("\n"); QStringList readin = orgS.readAll().split("\n");
QStringList written = outS.readAll().split("\n"); QStringList written = outS.readAll().split("\n");
while(readin.size() && written.size()){ while (readin.size() && written.size()) {
QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed()); QCOMPARE(written.takeFirst().trimmed(), readin.takeFirst().trimmed());
} }
} }

View file

@ -4,7 +4,7 @@
#include <QtTest> #include <QtTest>
class TestMerge : public QObject{ class TestMerge : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -1,12 +1,12 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testparse.h" #include "testparse.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/subsurface-string.h"
#include "core/parse.h"
#include "core/file.h"
#include "core/divelist.h" #include "core/divelist.h"
#include <QTextStream> #include "core/file.h"
#include "core/parse.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/subsurface-string.h"
#include <QTextStream>
/* We have to use a macro since QCOMPARE /* We have to use a macro since QCOMPARE
* can only be called from a test method * can only be called from a test method
@ -21,10 +21,10 @@
QTextStream outS(&out); \ QTextStream outS(&out); \
QStringList readin = orgS.readAll().split("\n"); \ QStringList readin = orgS.readAll().split("\n"); \
QStringList written = outS.readAll().split("\n"); \ QStringList written = outS.readAll().split("\n"); \
while(readin.size() && written.size()){ \ while (readin.size() && written.size()) { \
QCOMPARE(written.takeFirst().trimmed(), \ QCOMPARE(written.takeFirst().trimmed(), \
readin.takeFirst().trimmed()); \ readin.takeFirst().trimmed()); \
} \ }
void TestParse::initTestCase() void TestParse::initTestCase()
{ {
@ -116,7 +116,7 @@ int TestParse::parseDivingLog()
ds->name = copy_string("Suomi - - Hälvälä"); ds->name = copy_string("Suomi - - Hälvälä");
int ret = sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql", &_sqlite3_handle); int ret = sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql", &_sqlite3_handle);
if ( ret == 0 ) if (ret == 0)
ret = parse_divinglog_buffer(_sqlite3_handle, 0, 0, 0, &dive_table); ret = parse_divinglog_buffer(_sqlite3_handle, 0, 0, 0, &dive_table);
else else
fprintf(stderr, "Can't open sqlite3 db: " SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql"); fprintf(stderr, "Can't open sqlite3 db: " SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql");
@ -215,7 +215,8 @@ void TestParse::testParseHUDC()
params[pnr++] = NULL; params[pnr++] = NULL;
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv", QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv",
params, pnr - 1, "csv"), 0); params, pnr - 1, "csv"),
0);
QCOMPARE(dive_table.nr, 1); QCOMPARE(dive_table.nr, 1);
@ -256,7 +257,11 @@ void TestParse::testParseNewFormat()
for (int i = 0; i < files.size(); ++i) { for (int i = 0; i < files.size(); ++i) {
QCOMPARE(parse_seabear_log(QString::fromLatin1(SUBSURFACE_TEST_DATA QCOMPARE(parse_seabear_log(QString::fromLatin1(SUBSURFACE_TEST_DATA
"/dives/").append(files.at(i)).toLatin1().data()), 0); "/dives/")
.append(files.at(i))
.toLatin1()
.data()),
0);
QCOMPARE(dive_table.nr, i + 1); QCOMPARE(dive_table.nr, i + 1);
} }
@ -504,7 +509,8 @@ void TestParse::parseDL7()
clear_dive_file_data(); clear_dive_file_data();
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/DL7.zxu", QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/DL7.zxu",
params, pnr - 1 , "DL7"), 0); params, pnr - 1, "DL7"),
0);
QCOMPARE(dive_table.nr, 3); QCOMPARE(dive_table.nr, 3);
QCOMPARE(save_dives("./testdl7out.ssrf"), 0); QCOMPARE(save_dives("./testdl7out.ssrf"), 0);

View file

@ -5,7 +5,7 @@
#include <QtTest> #include <QtTest>
#include <sqlite3.h> #include <sqlite3.h>
class TestParse : public QObject{ class TestParse : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testpicture.h" #include "testpicture.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/file.h"
#include "core/divelist.h" #include "core/divelist.h"
#include "core/file.h"
#include <QString> #include <QString>
#include <core/qthelper.h> #include <core/qthelper.h>

View file

@ -4,7 +4,7 @@
#include <QtTest> #include <QtTest>
class TestPicture : public QObject{ class TestPicture : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "core/dive.h"
#include "testplan.h" #include "testplan.h"
#include "core/dive.h"
#include "core/planner.h" #include "core/planner.h"
#include "core/units.h"
#include "core/subsurfacestartup.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/subsurfacestartup.h"
#include "core/units.h"
#include <QDebug> #include <QDebug>
#define DEBUG 1 #define DEBUG 1
@ -45,10 +45,10 @@ void setupPlan(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {150}, {450} }; struct gasmix bottomgas = {{150}, {450}};
struct gasmix ean36 = { {360}, {0} }; struct gasmix ean36 = {{360}, {0}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 36000; displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -58,10 +58,10 @@ void setupPlan(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75); int droptime = M_OR_FT(79, 260) * 60 / M_OR_FT(23, 75);
plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean36, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
plan_add_segment(dp, 30*60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(79, 260), 0, 0, 1, OC);
} }
void setupPlanVpmb45m30mTx(struct diveplan *dp) void setupPlanVpmb45m30mTx(struct diveplan *dp)
@ -73,10 +73,10 @@ void setupPlanVpmb45m30mTx(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {210}, {350} }; struct gasmix bottomgas = {{210}, {350}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 24000; displayed_dive.cylinder[0].type.size.mliter = 24000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -86,10 +86,10 @@ void setupPlanVpmb45m30mTx(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75); int droptime = M_OR_FT(45, 150) * 60 / M_OR_FT(23, 75);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
plan_add_segment(dp, 30*60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(45, 150), 0, 0, 1, OC);
} }
void setupPlanVpmb60m10mTx(struct diveplan *dp) void setupPlanVpmb60m10mTx(struct diveplan *dp)
@ -101,10 +101,10 @@ void setupPlanVpmb60m10mTx(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {180}, {450} }; struct gasmix bottomgas = {{180}, {450}};
struct gasmix tx50_15 = { {500}, {150} }; struct gasmix tx50_15 = {{500}, {150}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 24000; displayed_dive.cylinder[0].type.size.mliter = 24000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -114,10 +114,10 @@ void setupPlanVpmb60m10mTx(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(23, 75);
plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&tx50_15, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 10*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
} }
void setupPlanVpmb60m30minAir(struct diveplan *dp) void setupPlanVpmb60m30minAir(struct diveplan *dp)
@ -127,7 +127,7 @@ void setupPlanVpmb60m30minAir(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {210}, {0} }; struct gasmix bottomgas = {{210}, {0}};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 100000; displayed_dive.cylinder[0].type.size.mliter = 100000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -137,7 +137,7 @@ void setupPlanVpmb60m30minAir(struct diveplan *dp)
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
} }
void setupPlanVpmb60m30minEan50(struct diveplan *dp) void setupPlanVpmb60m30minEan50(struct diveplan *dp)
@ -147,9 +147,9 @@ void setupPlanVpmb60m30minEan50(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {210}, {0} }; struct gasmix bottomgas = {{210}, {0}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 36000; displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -159,9 +159,9 @@ void setupPlanVpmb60m30minEan50(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
} }
void setupPlanVpmb60m30minTx(struct diveplan *dp) void setupPlanVpmb60m30minTx(struct diveplan *dp)
@ -171,9 +171,9 @@ void setupPlanVpmb60m30minTx(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {180}, {450} }; struct gasmix bottomgas = {{180}, {450}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 36000; displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -183,9 +183,9 @@ void setupPlanVpmb60m30minTx(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 30 * 60 - droptime, M_OR_FT(60, 200), 0, 0, 1, OC);
} }
void setupPlanVpmbMultiLevelAir(struct diveplan *dp) void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
@ -195,7 +195,7 @@ void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {210}, {0} }; struct gasmix bottomgas = {{210}, {0}};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 200000; displayed_dive.cylinder[0].type.size.mliter = 200000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -205,9 +205,9 @@ void setupPlanVpmbMultiLevelAir(struct diveplan *dp)
int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
plan_add_segment(dp, 10*60 - droptime, M_OR_FT(20, 66), 0, 0, 1, OC); plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(20, 66), 0, 0, 1, OC);
plan_add_segment(dp, 1*60, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 1 * 60, M_OR_FT(60, 200), 0, 0, 1, OC);
plan_add_segment(dp, 29*60, M_OR_FT(60, 200), 0, 0, 1, OC); plan_add_segment(dp, 29 * 60, M_OR_FT(60, 200), 0, 0, 1, OC);
} }
void setupPlanVpmb100m60min(struct diveplan *dp) void setupPlanVpmb100m60min(struct diveplan *dp)
@ -217,10 +217,10 @@ void setupPlanVpmb100m60min(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {180}, {450} }; struct gasmix bottomgas = {{180}, {450}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 200000; displayed_dive.cylinder[0].type.size.mliter = 200000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -231,10 +231,10 @@ void setupPlanVpmb100m60min(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 60*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 60 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
} }
void setupPlanVpmb100m10min(struct diveplan *dp) void setupPlanVpmb100m10min(struct diveplan *dp)
@ -244,10 +244,10 @@ void setupPlanVpmb100m10min(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {180}, {450} }; struct gasmix bottomgas = {{180}, {450}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 60000; displayed_dive.cylinder[0].type.size.mliter = 60000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -258,10 +258,10 @@ void setupPlanVpmb100m10min(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 10*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 10 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
} }
void setupPlanVpmb30m20min(struct diveplan *dp) void setupPlanVpmb30m20min(struct diveplan *dp)
@ -271,7 +271,7 @@ void setupPlanVpmb30m20min(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {210}, {0} }; struct gasmix bottomgas = {{210}, {0}};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 36000; displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -281,7 +281,7 @@ void setupPlanVpmb30m20min(struct diveplan *dp)
int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60); int droptime = M_OR_FT(30, 100) * 60 / M_OR_FT(18, 60);
plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
plan_add_segment(dp, 20*60 - droptime, M_OR_FT(30, 100), 0, 0, 1, OC); plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(30, 100), 0, 0, 1, OC);
} }
void setupPlanVpmb100mTo70m30min(struct diveplan *dp) void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
@ -291,11 +291,11 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
dp->bottomsac = prefs.bottomsac; dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac; dp->decosac = prefs.decosac;
struct gasmix bottomgas = { {120}, {650} }; struct gasmix bottomgas = {{120}, {650}};
struct gasmix tx21_35 = { {210}, {350} }; struct gasmix tx21_35 = {{210}, {350}};
struct gasmix ean50 = { {500}, {0} }; struct gasmix ean50 = {{500}, {0}};
struct gasmix oxygen = { {1000}, {0} }; struct gasmix oxygen = {{1000}, {0}};
pressure_t po2 = { 1600 }; pressure_t po2 = {1600};
displayed_dive.cylinder[0].gasmix = bottomgas; displayed_dive.cylinder[0].gasmix = bottomgas;
displayed_dive.cylinder[0].type.size.mliter = 36000; displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000; displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
@ -307,12 +307,12 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
free_dps(dp); free_dps(dp);
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60); int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(18, 60);
plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3,10)).mm, 1, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&tx21_35, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 1, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, 2, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 2, 0, 1, OC);
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, 3, 0, 1, OC); plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3, 10)).mm, 3, 0, 1, OC);
plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 20*60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC); plan_add_segment(dp, 20 * 60 - droptime, M_OR_FT(100, 330), 0, 0, 1, OC);
plan_add_segment(dp, 3*60, M_OR_FT(70, 230), 0, 0, 1, OC); plan_add_segment(dp, 3 * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC); plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
} }
@ -373,7 +373,8 @@ void TestPlan::testMetric()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 148l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 148l);
// check first gas change to EAN36 at 33m // check first gas change to EAN36 at 33m
struct event *ev = displayed_dive.dc.events; struct event *ev = displayed_dive.dc.events;
@ -413,7 +414,8 @@ void TestPlan::testImperial()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 154l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 154l);
// check first gas change to EAN36 at 33m // check first gas change to EAN36 at 33m
struct event *ev = displayed_dive.dc.events; struct event *ev = displayed_dive.dc.events;
@ -453,7 +455,8 @@ void TestPlan::testVpmbMetric45m30minTx()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 108l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 108l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -483,7 +486,8 @@ void TestPlan::testVpmbMetric60m10minTx()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 162l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 162l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -513,7 +517,8 @@ void TestPlan::testVpmbMetric60m30minAir()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 180l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 180l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -543,7 +548,8 @@ void TestPlan::testVpmbMetric60m30minEan50()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 155l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 155l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -579,7 +585,8 @@ void TestPlan::testVpmbMetric60m30minTx()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 159l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 159l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -615,7 +622,8 @@ void TestPlan::testVpmbMetric100m60min()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 157l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 157l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -657,7 +665,8 @@ void TestPlan::testVpmbMetricMultiLevelAir()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 101l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 101l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -687,7 +696,8 @@ void TestPlan::testVpmbMetric100m10min()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 175l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 175l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -733,7 +743,8 @@ void TestPlan::testVpmbMetricRepeat()
// check minimum gas result // check minimum gas result
struct divedatapoint *dp = testPlan.dp; struct divedatapoint *dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -753,7 +764,8 @@ void TestPlan::testVpmbMetricRepeat()
// check minimum gas result // check minimum gas result
dp = testPlan.dp; dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 80l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 80l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));
@ -789,7 +801,8 @@ void TestPlan::testVpmbMetricRepeat()
// check minimum gas result // check minimum gas result
dp = testPlan.dp; dp = testPlan.dp;
while(!dp->minimum_gas.mbar && dp->next) dp = dp->next; while (!dp->minimum_gas.mbar && dp->next)
dp = dp->next;
QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l); QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 61l);
// print first ceiling // print first ceiling
printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001));

View file

@ -3,14 +3,14 @@
#include "core/subsurface-qt/SettingsObjectWrapper.h" #include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QtTest>
#include <QDate> #include <QDate>
#include <QtTest>
#define TEST(METHOD, VALUE) \ #define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \ QCOMPARE(METHOD, VALUE); \
pref->sync(); \ pref->sync(); \
pref->load(); \ pref->load(); \
QCOMPARE(METHOD, VALUE); QCOMPARE(METHOD, VALUE);
void TestPreferences::initTestCase() void TestPreferences::initTestCase()
{ {
@ -165,7 +165,7 @@ void TestPreferences::testPreferences()
fb->setUserId("tomaz-user-id"); fb->setUserId("tomaz-user-id");
fb->setAlbumId("album-id"); fb->setAlbumId("album-id");
TEST(fb->accessToken(),QStringLiteral("rand-access-token")); TEST(fb->accessToken(), QStringLiteral("rand-access-token"));
TEST(fb->userId(), QStringLiteral("tomaz-user-id")); TEST(fb->userId(), QStringLiteral("tomaz-user-id"));
TEST(fb->albumId(), QStringLiteral("album-id")); TEST(fb->albumId(), QStringLiteral("album-id"));
@ -173,7 +173,7 @@ void TestPreferences::testPreferences()
fb->setUserId("tomaz-user-id-2"); fb->setUserId("tomaz-user-id-2");
fb->setAlbumId("album-id-2"); fb->setAlbumId("album-id-2");
TEST(fb->accessToken(),QStringLiteral("rand-access-token-2")); TEST(fb->accessToken(), QStringLiteral("rand-access-token-2"));
TEST(fb->userId(), QStringLiteral("tomaz-user-id-2")); TEST(fb->userId(), QStringLiteral("tomaz-user-id-2"));
TEST(fb->albumId(), QStringLiteral("album-id-2")); TEST(fb->albumId(), QStringLiteral("album-id-2"));
@ -202,12 +202,12 @@ void TestPreferences::testPreferences()
proxy->setUser("unknown"); proxy->setUser("unknown");
proxy->setPass("secret"); proxy->setPass("secret");
TEST(proxy->type(),2); TEST(proxy->type(), 2);
TEST(proxy->port(),80); TEST(proxy->port(), 80);
TEST(proxy->auth(),true); TEST(proxy->auth(), true);
TEST(proxy->host(),QStringLiteral("localhost")); TEST(proxy->host(), QStringLiteral("localhost"));
TEST(proxy->user(),QStringLiteral("unknown")); TEST(proxy->user(), QStringLiteral("unknown"));
TEST(proxy->pass(),QStringLiteral("secret")); TEST(proxy->pass(), QStringLiteral("secret"));
proxy->setType(3); proxy->setType(3);
proxy->setPort(8080); proxy->setPort(8080);
@ -216,12 +216,12 @@ void TestPreferences::testPreferences()
proxy->setUser("unknown_1"); proxy->setUser("unknown_1");
proxy->setPass("secret_1"); proxy->setPass("secret_1");
TEST(proxy->type(),3); TEST(proxy->type(), 3);
TEST(proxy->port(),8080); TEST(proxy->port(), 8080);
TEST(proxy->auth(),false); TEST(proxy->auth(), false);
TEST(proxy->host(),QStringLiteral("127.0.0.1")); TEST(proxy->host(), QStringLiteral("127.0.0.1"));
TEST(proxy->user(),QStringLiteral("unknown_1")); TEST(proxy->user(), QStringLiteral("unknown_1"));
TEST(proxy->pass(),QStringLiteral("secret_1")); TEST(proxy->pass(), QStringLiteral("secret_1"));
auto planner = pref->planner_settings; auto planner = pref->planner_settings;
planner->setLastStop(true); planner->setLastStop(true);
@ -249,30 +249,30 @@ void TestPreferences::testPreferences()
planner->setDecoMode(BUEHLMANN); planner->setDecoMode(BUEHLMANN);
TEST(planner->lastStop(),true); TEST(planner->lastStop(), true);
TEST(planner->verbatimPlan(),true); TEST(planner->verbatimPlan(), true);
TEST(planner->displayRuntime(),true); TEST(planner->displayRuntime(), true);
TEST(planner->displayDuration(),true); TEST(planner->displayDuration(), true);
TEST(planner->displayTransitions(),true); TEST(planner->displayTransitions(), true);
TEST(planner->doo2breaks(),true); TEST(planner->doo2breaks(), true);
TEST(planner->dropStoneMode(),true); TEST(planner->dropStoneMode(), true);
TEST(planner->safetyStop(),true); TEST(planner->safetyStop(), true);
TEST(planner->switchAtRequiredStop(),true); TEST(planner->switchAtRequiredStop(), true);
TEST(planner->ascrate75(),1); TEST(planner->ascrate75(), 1);
TEST(planner->ascrate50(),2); TEST(planner->ascrate50(), 2);
TEST(planner->ascratestops(),3); TEST(planner->ascratestops(), 3);
TEST(planner->ascratelast6m(),4); TEST(planner->ascratelast6m(), 4);
TEST(planner->descrate(),5); TEST(planner->descrate(), 5);
TEST(planner->bottompo2(),6); TEST(planner->bottompo2(), 6);
TEST(planner->decopo2(),7); TEST(planner->decopo2(), 7);
TEST(planner->bestmixend(),8); TEST(planner->bestmixend(), 8);
TEST(planner->reserveGas(),9); TEST(planner->reserveGas(), 9);
TEST(planner->minSwitchDuration(),10); TEST(planner->minSwitchDuration(), 10);
TEST(planner->bottomSac(),11); TEST(planner->bottomSac(), 11);
TEST(planner->decoSac(),12); TEST(planner->decoSac(), 12);
TEST(planner->decoMode(),BUEHLMANN); TEST(planner->decoMode(), BUEHLMANN);
planner->setLastStop(false); planner->setLastStop(false);
planner->setVerbatimPlan(false); planner->setVerbatimPlan(false);
@ -299,30 +299,30 @@ void TestPreferences::testPreferences()
planner->setDecoMode(RECREATIONAL); planner->setDecoMode(RECREATIONAL);
TEST(planner->lastStop(),false); TEST(planner->lastStop(), false);
TEST(planner->verbatimPlan(),false); TEST(planner->verbatimPlan(), false);
TEST(planner->displayRuntime(),false); TEST(planner->displayRuntime(), false);
TEST(planner->displayDuration(),false); TEST(planner->displayDuration(), false);
TEST(planner->displayTransitions(),false); TEST(planner->displayTransitions(), false);
TEST(planner->doo2breaks(),false); TEST(planner->doo2breaks(), false);
TEST(planner->dropStoneMode(),false); TEST(planner->dropStoneMode(), false);
TEST(planner->safetyStop(),false); TEST(planner->safetyStop(), false);
TEST(planner->switchAtRequiredStop(),false); TEST(planner->switchAtRequiredStop(), false);
TEST(planner->ascrate75(),11); TEST(planner->ascrate75(), 11);
TEST(planner->ascrate50(),12); TEST(planner->ascrate50(), 12);
TEST(planner->ascratestops(),13); TEST(planner->ascratestops(), 13);
TEST(planner->ascratelast6m(),14); TEST(planner->ascratelast6m(), 14);
TEST(planner->descrate(),15); TEST(planner->descrate(), 15);
TEST(planner->bottompo2(),16); TEST(planner->bottompo2(), 16);
TEST(planner->decopo2(),17); TEST(planner->decopo2(), 17);
TEST(planner->bestmixend(),18); TEST(planner->bestmixend(), 18);
TEST(planner->reserveGas(),19); TEST(planner->reserveGas(), 19);
TEST(planner->minSwitchDuration(),110); TEST(planner->minSwitchDuration(), 110);
TEST(planner->bottomSac(),111); TEST(planner->bottomSac(), 111);
TEST(planner->decoSac(),112); TEST(planner->decoSac(), 112);
TEST(planner->decoMode(),RECREATIONAL); TEST(planner->decoMode(), RECREATIONAL);
auto units = pref->unit_settings; auto units = pref->unit_settings;
units->setLength(0); units->setLength(0);
@ -334,14 +334,14 @@ void TestPreferences::testPreferences()
units->setUnitSystem(QStringLiteral("metric")); units->setUnitSystem(QStringLiteral("metric"));
units->setCoordinatesTraditional(false); units->setCoordinatesTraditional(false);
TEST(units->length(),0); TEST(units->length(), 0);
TEST(units->pressure(),0); TEST(units->pressure(), 0);
TEST(units->volume(),0); TEST(units->volume(), 0);
TEST(units->temperature(),0); TEST(units->temperature(), 0);
TEST(units->weight(),0); TEST(units->weight(), 0);
TEST(units->verticalSpeedTime(),0); TEST(units->verticalSpeedTime(), 0);
TEST(units->unitSystem(),QStringLiteral("metric")); TEST(units->unitSystem(), QStringLiteral("metric"));
TEST(units->coordinatesTraditional(),false); TEST(units->coordinatesTraditional(), false);
units->setLength(1); units->setLength(1);
units->setPressure(1); units->setPressure(1);
@ -352,60 +352,60 @@ void TestPreferences::testPreferences()
units->setUnitSystem(QStringLiteral("fake-metric-system")); units->setUnitSystem(QStringLiteral("fake-metric-system"));
units->setCoordinatesTraditional(true); units->setCoordinatesTraditional(true);
TEST(units->length(),1); TEST(units->length(), 1);
TEST(units->pressure(),1); TEST(units->pressure(), 1);
TEST(units->volume(),1); TEST(units->volume(), 1);
TEST(units->temperature(),1); TEST(units->temperature(), 1);
TEST(units->weight(),1); TEST(units->weight(), 1);
TEST(units->verticalSpeedTime(),1); TEST(units->verticalSpeedTime(), 1);
TEST(units->unitSystem(),QStringLiteral("personalized")); TEST(units->unitSystem(), QStringLiteral("personalized"));
TEST(units->coordinatesTraditional(),true); TEST(units->coordinatesTraditional(), 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");
//TODOl: Change this to a enum. // This is 'undefined', it will need to figure out later between no_file or use_deault file. //TODOl: Change this to a enum. // This is 'undefined', it will need to figure out later between no_file or use_deault file.
general->setDefaultFileBehavior (0); general->setDefaultFileBehavior(0);
general->setDefaultSetPoint (0); general->setDefaultSetPoint(0);
general->setO2Consumption (0); general->setO2Consumption(0);
general->setPscrRatio (0); general->setPscrRatio(0);
general->setUseDefaultFile (true); general->setUseDefaultFile(true);
TEST(general->defaultFilename(), QStringLiteral("filename")); TEST(general->defaultFilename(), QStringLiteral("filename"));
TEST(general->defaultCylinder(), QStringLiteral("cylinder_2")); TEST(general->defaultCylinder(), QStringLiteral("cylinder_2"));
TEST(general->defaultFileBehavior(), (short) LOCAL_DEFAULT_FILE); // since we have a default file, here it returns TEST(general->defaultFileBehavior(), (short)LOCAL_DEFAULT_FILE); // since we have a default file, here it returns
TEST(general->defaultSetPoint(), 0); TEST(general->defaultSetPoint(), 0);
TEST(general->o2Consumption(), 0); TEST(general->o2Consumption(), 0);
TEST(general->pscrRatio(), 0); TEST(general->pscrRatio(), 0);
TEST(general->useDefaultFile(), true); TEST(general->useDefaultFile(), true);
general->setDefaultFilename ("no_file_name"); general->setDefaultFilename("no_file_name");
general->setDefaultCylinder ("cylinder_1"); general->setDefaultCylinder("cylinder_1");
//TODOl: Change this to a enum. //TODOl: Change this to a enum.
general->setDefaultFileBehavior (CLOUD_DEFAULT_FILE); general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE);
general->setDefaultSetPoint (1); general->setDefaultSetPoint(1);
general->setO2Consumption (1); general->setO2Consumption(1);
general->setPscrRatio (1); general->setPscrRatio(1);
general->setUseDefaultFile (false); general->setUseDefaultFile(false);
TEST(general->defaultFilename(), QStringLiteral("no_file_name")); TEST(general->defaultFilename(), QStringLiteral("no_file_name"));
TEST(general->defaultCylinder(), QStringLiteral("cylinder_1")); TEST(general->defaultCylinder(), QStringLiteral("cylinder_1"));
TEST(general->defaultFileBehavior(), (short) CLOUD_DEFAULT_FILE); TEST(general->defaultFileBehavior(), (short)CLOUD_DEFAULT_FILE);
TEST(general->defaultSetPoint(), 1); TEST(general->defaultSetPoint(), 1);
TEST(general->o2Consumption(), 1); TEST(general->o2Consumption(), 1);
TEST(general->pscrRatio(), 1); TEST(general->pscrRatio(), 1);
TEST(general->useDefaultFile(), false); TEST(general->useDefaultFile(), false);
auto language = pref->language_settings; auto language = pref->language_settings;
language->setLangLocale ("en_US"); language->setLangLocale("en_US");
language->setLanguage ("en"); language->setLanguage("en");
language->setTimeFormat ("hh:mm"); language->setTimeFormat("hh:mm");
language->setDateFormat ("dd/mm/yy"); language->setDateFormat("dd/mm/yy");
language->setDateFormatShort ("dd/mm"); language->setDateFormatShort("dd/mm");
language->setTimeFormatOverride (false); language->setTimeFormatOverride(false);
language->setDateFormatOverride (false); language->setDateFormatOverride(false);
language->setUseSystemLanguage (false); language->setUseSystemLanguage(false);
TEST(language->langLocale(), QStringLiteral("en_US")); TEST(language->langLocale(), QStringLiteral("en_US"));
TEST(language->language(), QStringLiteral("en")); TEST(language->language(), QStringLiteral("en"));
@ -416,22 +416,22 @@ void TestPreferences::testPreferences()
TEST(language->dateFormatOverride(), false); TEST(language->dateFormatOverride(), false);
TEST(language->useSystemLanguage(), false); TEST(language->useSystemLanguage(), false);
language->setLangLocale ("en_EN"); language->setLangLocale("en_EN");
language->setLanguage ("br"); language->setLanguage("br");
language->setTimeFormat ("mm:hh"); language->setTimeFormat("mm:hh");
language->setDateFormat ("yy/mm/dd"); language->setDateFormat("yy/mm/dd");
language->setDateFormatShort ("dd/yy"); language->setDateFormatShort("dd/yy");
language->setTimeFormatOverride (true); language->setTimeFormatOverride(true);
language->setDateFormatOverride (true); language->setDateFormatOverride(true);
language->setUseSystemLanguage (true); language->setUseSystemLanguage(true);
TEST(language->langLocale(), QStringLiteral("en_EN")); TEST(language->langLocale(), QStringLiteral("en_EN"));
TEST(language->language(), QStringLiteral("br")); TEST(language->language(), QStringLiteral("br"));
TEST(language->timeFormat(), QStringLiteral("mm:hh")); TEST(language->timeFormat(), QStringLiteral("mm:hh"));
TEST(language->dateFormat(), QStringLiteral("yy/mm/dd")); TEST(language->dateFormat(), QStringLiteral("yy/mm/dd"));
TEST(language->dateFormatShort(), QStringLiteral("dd/yy")); TEST(language->dateFormatShort(), QStringLiteral("dd/yy"));
TEST(language->timeFormatOverride(),true); TEST(language->timeFormatOverride(), true);
TEST(language->dateFormatOverride(),true); TEST(language->dateFormatOverride(), true);
TEST(language->useSystemLanguage(), true); TEST(language->useSystemLanguage(), true);
auto location = pref->location_settings; auto location = pref->location_settings;

View file

@ -5,8 +5,7 @@
#include <QTest> #include <QTest>
#include <functional> #include <functional>
class TestPreferences : public QObject class TestPreferences : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -5,7 +5,7 @@
#include <QtTest> #include <QtTest>
class TestProfile : public QObject{ class TestProfile : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testRedCeiling(); void testRedCeiling();

View file

@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testqPrefAnimations.h" #include "testqPrefAnimations.h"
#include "core/settings/qPref.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/settings/qPref.h"
#include <QDate> #include <QDate>
#include <QTest> #include <QTest>

View file

@ -4,8 +4,7 @@
#include <QObject> #include <QObject>
class TestQPrefAnimations : public QObject class TestQPrefAnimations : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testqPrefCloudStorage.h" #include "testqPrefCloudStorage.h"
#include "core/settings/qPref.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/settings/qPref.h"
#include <QTest> #include <QTest>
@ -48,7 +48,6 @@ void TestQPrefCloudStorage::test_struct_get()
QCOMPARE(tst->save_password_local(), prefs.save_password_local); QCOMPARE(tst->save_password_local(), prefs.save_password_local);
QCOMPARE(tst->save_userid_local(), prefs.save_userid_local); QCOMPARE(tst->save_userid_local(), prefs.save_userid_local);
QCOMPARE(tst->userid(), QString(prefs.userid)); QCOMPARE(tst->userid(), QString(prefs.userid));
} }
void TestQPrefCloudStorage::test_set_struct() void TestQPrefCloudStorage::test_set_struct()
@ -207,10 +206,10 @@ void TestQPrefCloudStorage::test_multiple()
} }
#define TEST(METHOD, VALUE) \ #define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \ QCOMPARE(METHOD, VALUE); \
cloud->sync(); \ cloud->sync(); \
cloud->load(); \ cloud->load(); \
QCOMPARE(METHOD, VALUE); QCOMPARE(METHOD, VALUE);
void TestQPrefCloudStorage::test_oldPreferences() void TestQPrefCloudStorage::test_oldPreferences()
{ {

View file

@ -4,8 +4,7 @@
#include <QObject> #include <QObject>
class TestQPrefCloudStorage : public QObject class TestQPrefCloudStorage : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:

View file

@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testqPrefDisplay.h" #include "testqPrefDisplay.h"
#include "core/settings/qPref.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/settings/qPref.h"
#include <QDate> #include <QDate>
#include <QTest> #include <QTest>

View file

@ -4,8 +4,7 @@
#include <QObject> #include <QObject>
class TestQPrefDisplay : public QObject class TestQPrefDisplay : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void initTestCase(); void initTestCase();

View file

@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testqPrefDiveComputer.h" #include "testqPrefDiveComputer.h"
#include "core/settings/qPref.h"
#include "core/pref.h" #include "core/pref.h"
#include "core/qthelper.h" #include "core/qthelper.h"
#include "core/settings/qPref.h"
#include <QTest> #include <QTest>
@ -121,10 +121,10 @@ void TestQPrefDiveComputer::test_multiple()
} }
#define TEST(METHOD, VALUE) \ #define TEST(METHOD, VALUE) \
QCOMPARE(METHOD, VALUE); \ QCOMPARE(METHOD, VALUE); \
dc->sync(); \ dc->sync(); \
dc->load(); \ dc->load(); \
QCOMPARE(METHOD, VALUE); QCOMPARE(METHOD, VALUE);
void TestQPrefDiveComputer::test_oldPreferences() void TestQPrefDiveComputer::test_oldPreferences()
{ {
@ -152,4 +152,3 @@ void TestQPrefDiveComputer::test_oldPreferences()
} }
QTEST_MAIN(TestQPrefDiveComputer) QTEST_MAIN(TestQPrefDiveComputer)

View file

@ -4,8 +4,7 @@
#include <QObject> #include <QObject>
class TestQPrefDiveComputer : public QObject class TestQPrefDiveComputer : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:

View file

@ -1,13 +1,12 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <QApplication>
#include <QQmlContext>
#include <QQmlEngine> #include <QQmlEngine>
#include <QtQuickTest> #include <QtQuickTest>
#include <QtTest> #include <QtTest>
#include <QQmlEngine>
#include <QQmlContext>
#include <QApplication>
#include "core/settings/qPref.h"
#include "core/qt-gui.h" #include "core/qt-gui.h"
#include "core/settings/qPref.h"
// this is the content of QUICK_TEST_MAIN amended with // this is the content of QUICK_TEST_MAIN amended with
// registration of ssrf classes // registration of ssrf classes
@ -34,7 +33,7 @@ int main(int argc, char **argv)
// save tst_dir and pass rest to Qt // save tst_dir and pass rest to Qt
const char *tst_dir = argv[1]; const char *tst_dir = argv[1];
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
argv[i] = argv[i+1]; argv[i] = argv[i + 1];
argc--; argc--;
// Register types // Register types

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "testrenumber.h" #include "testrenumber.h"
#include "core/dive.h" #include "core/dive.h"
#include "core/file.h"
#include "core/divelist.h" #include "core/divelist.h"
#include "core/file.h"
#include <QTextStream> #include <QTextStream>
void TestRenumber::setup() void TestRenumber::setup()

View file

@ -4,8 +4,7 @@
#include <QtTest> #include <QtTest>
class TestRenumber : public QObject class TestRenumber : public QObject {
{
Q_OBJECT Q_OBJECT
private slots: private slots:
void setup(); void setup();

View file

@ -10,15 +10,15 @@ void TestUnitConversion::testUnitConversions()
QCOMPARE(IS_FP_SAME(ml_to_cuft(1000), 0.0353147), true); QCOMPARE(IS_FP_SAME(ml_to_cuft(1000), 0.0353147), true);
QCOMPARE(IS_FP_SAME(cuft_to_l(1), 28.316847), true); QCOMPARE(IS_FP_SAME(cuft_to_l(1), 28.316847), true);
QCOMPARE(IS_FP_SAME(mm_to_feet(1000), 3.280840), true); QCOMPARE(IS_FP_SAME(mm_to_feet(1000), 3.280840), true);
QCOMPARE(feet_to_mm(1), (long unsigned int) 305); QCOMPARE(feet_to_mm(1), (long unsigned int)305);
QCOMPARE(to_feet((depth_t){ 1000 }), 3); QCOMPARE(to_feet((depth_t){1000}), 3);
QCOMPARE(IS_FP_SAME(mkelvin_to_C(647000), 373.85), true); QCOMPARE(IS_FP_SAME(mkelvin_to_C(647000), 373.85), true);
QCOMPARE(IS_FP_SAME(mkelvin_to_F(647000), 704.93), true); QCOMPARE(IS_FP_SAME(mkelvin_to_F(647000), 704.93), true);
QCOMPARE(F_to_mkelvin(704.93), (unsigned long)647000); QCOMPARE(F_to_mkelvin(704.93), (unsigned long)647000);
QCOMPARE(C_to_mkelvin(373.85), (unsigned long)647000); QCOMPARE(C_to_mkelvin(373.85), (unsigned long)647000);
QCOMPARE(IS_FP_SAME(psi_to_bar(14.6959488), 1.01325), true); QCOMPARE(IS_FP_SAME(psi_to_bar(14.6959488), 1.01325), true);
QCOMPARE(psi_to_mbar(14.6959488), (long)1013); QCOMPARE(psi_to_mbar(14.6959488), (long)1013);
QCOMPARE(to_PSI((pressure_t){ 1013 }), (int)15); QCOMPARE(to_PSI((pressure_t){1013}), (int)15);
QCOMPARE(IS_FP_SAME(bar_to_atm(1.013), 1.0), true); QCOMPARE(IS_FP_SAME(bar_to_atm(1.013), 1.0), true);
QCOMPARE(IS_FP_SAME(mbar_to_atm(1013), 1.0), true); QCOMPARE(IS_FP_SAME(mbar_to_atm(1013), 1.0), true);
QCOMPARE(mbar_to_PSI(1013), (int)15); QCOMPARE(mbar_to_PSI(1013), (int)15);

View file

@ -4,7 +4,7 @@
#include <QtTest> #include <QtTest>
class TestUnitConversion : public QObject{ class TestUnitConversion : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testUnitConversions(); void testUnitConversions();