aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-17 12:32:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-24 09:51:37 -0700
commita2614665942959b95eef8453730cd3ac66ac42a3 (patch)
treee8491231112634e6fa188a605ddab47910cfe8c2 /tests
parent41975435a2a93733a0e46a7e594ffba193be6e87 (diff)
downloadsubsurface-a2614665942959b95eef8453730cd3ac66ac42a3.tar.gz
parser: add device_table to parser state
If we want to avoid the parsers to directly modify global data, we have to provide a device_table to parse into. This adds such a state and the corresponding function parameters. However, for now this is unused. Adding new parameters is very painful and this commit shows that we urgently need a "struct divelog" collecting all those tables! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/testAirPressure.cpp7
-rw-r--r--tests/testdivesiteduplication.cpp4
-rw-r--r--tests/testgitstorage.cpp79
-rw-r--r--tests/testmerge.cpp11
-rw-r--r--tests/testparse.cpp56
-rw-r--r--tests/testparseperformance.cpp10
-rw-r--r--tests/testpicture.cpp3
-rw-r--r--tests/testprofile.cpp4
-rw-r--r--tests/testrenumber.cpp9
9 files changed, 120 insertions, 63 deletions
diff --git a/tests/testAirPressure.cpp b/tests/testAirPressure.cpp
index 73088df68..5bc8c5369 100644
--- a/tests/testAirPressure.cpp
+++ b/tests/testAirPressure.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testAirPressure.h"
+#include "core/device.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "core/trip.h"
@@ -19,7 +20,8 @@ void TestAirPressure::get_dives()
struct dive *dive;
verbose = 1;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TestAtmPress.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TestAtmPress.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
dive = get_dive(0);
dive->selected = true;
QVERIFY(dive != NULL);
@@ -54,7 +56,8 @@ void TestAirPressure::testWriteReadBackAirPressure()
dive->surface_pressure.mbar = ap;
QCOMPARE(save_dives("./testout.ssrf"), 0);
clear_dive_file_data();
- QCOMPARE(parse_file("./testout.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file("./testout.ssrf", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table), 0);
dive = get_dive(0);
QVERIFY(dive != NULL);
dive->selected = true;
diff --git a/tests/testdivesiteduplication.cpp b/tests/testdivesiteduplication.cpp
index ca706b618..d626e23ed 100644
--- a/tests/testdivesiteduplication.cpp
+++ b/tests/testdivesiteduplication.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testdivesiteduplication.h"
+#include "core/device.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "core/trip.h"
@@ -7,7 +8,8 @@
void TestDiveSiteDuplication::testReadV2()
{
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/TwoTimesTwo.ssrf", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(dive_site_table.nr, 2);
}
diff --git a/tests/testgitstorage.cpp b/tests/testgitstorage.cpp
index fb864f2a8..9aa9a97ee 100644
--- a/tests/testgitstorage.cpp
+++ b/tests/testgitstorage.cpp
@@ -2,6 +2,7 @@
#include "testgitstorage.h"
#include "git2.h"
+#include "core/device.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "core/file.h"
@@ -153,7 +154,8 @@ void TestGitStorage::initTestCase()
// cleanup local and remote branches
localRemoteCleanup();
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
}
void TestGitStorage::cleanupTestCase()
@@ -185,7 +187,8 @@ void TestGitStorage::testGitStorageLocal()
{
// test writing and reading back from local git storage
git_repository *repo;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QFETCH(QString, testDirName);
QFETCH(QString, prefixRead);
QFETCH(QString, prefixWrite);
@@ -198,7 +201,8 @@ void TestGitStorage::testGitStorageLocal()
QCOMPARE(save_dives(qPrintable(repoNameWrite + "[test]")), 0);
QCOMPARE(save_dives("./SampleDivesV3.ssrf"), 0);
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]"), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(repoNameRead + "[test]"), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesV3viagit.ssrf"), 0);
QFile org("./SampleDivesV3.ssrf");
org.open(QFile::ReadOnly);
@@ -216,10 +220,12 @@ void TestGitStorage::testGitStorageCloud()
// test writing and reading back from cloud storage
// connect to the ssrftest repository on the cloud server
// and repeat the same test as before with the local git storage
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/SampleDivesV2.ssrf", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesV3viacloud.ssrf"), 0);
QFile org("./SampleDivesV3.ssrf");
org.open(QFile::ReadOnly);
@@ -237,8 +243,10 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
// make a change to local cache repo (pretending that we did some offline changes)
// and then open the remote one again and check that things were propagated correctly
// read the local repo from the previous test and add dive 10
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test10.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
// calling process_loaded_dives() sorts the table, but calling add_imported_dives()
// causes it to try to update the window title... let's not do that
process_loaded_dives();
@@ -249,7 +257,8 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
clear_dive_file_data();
// now pretend that we are online again and open the cloud storage and compare
git_local_only = false;
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesV3plus10viacloud.ssrf"), 0);
QFile org("./SampleDivesV3plus10local.ssrf");
org.open(QFile::ReadOnly);
@@ -264,7 +273,8 @@ void TestGitStorage::testGitStorageCloudOfflineSync()
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
moveDir(localCacheDir, localCacheDir + "save");
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesV3plus10fromcloud.ssrf"), 0);
org.close();
org.open(QFile::ReadOnly);
@@ -293,8 +303,10 @@ void TestGitStorage::testGitStorageCloudMerge()
// (1) open the repo, add dive test11 and save to the cloud
git_local_only = false;
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
@@ -305,27 +317,34 @@ void TestGitStorage::testGitStorageCloudMerge()
// (3) open the repo from the old cache and add dive test12 while offline
git_local_only = true;
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
clear_dive_file_data();
// (4) now take things back online
git_local_only = false;
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
clear_dive_file_data();
// (5) now we should have all the dives in our repo on the second client
// first create the reference data from the xml files:
- QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file("./SampleDivesV3plus10local.ssrf", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test11.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test12.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12.ssrf"), 0);
// then load from the cloud
clear_dive_file_data();
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged.ssrf"), 0);
// finally compare what we have
@@ -342,7 +361,8 @@ void TestGitStorage::testGitStorageCloudMerge()
// (6) move ourselves back to the first client and compare data there
moveDir(localCacheDir + "client1", localCacheDir);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QCOMPARE(save_dives("./SampleDivesV3plus10-11-12-merged-client1.ssrf"), 0);
QFile client1("./SampleDivesV3plus10-11-12-merged-client1.ssrf");
@@ -358,7 +378,8 @@ void TestGitStorage::testGitStorageCloudMerge2()
// edit the same dive in the cloud repo
// merge
// (1) open repo, delete second dive, save offline
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
struct dive *dive = get_dive(1);
delete_single_dive(1);
@@ -372,7 +393,8 @@ void TestGitStorage::testGitStorageCloudMerge2()
moveDir(localCacheDir, localCacheDir + "save");
// (3) now we open the cloud storage repo and modify that second dive
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
dive = get_dive(1);
QVERIFY(dive != NULL);
@@ -384,7 +406,8 @@ void TestGitStorage::testGitStorageCloudMerge2()
// (4) move the saved local cache backinto place and try to open the cloud repo
// -> this forces a merge
moveDir(localCacheDir + "save", localCacheDir);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesMinus1-merged.ssrf"), 0);
QCOMPARE(save_dives(qPrintable(cloudTestRepo)), 0);
QFile org("./SampleDivesMinus1-merged.ssrf");
@@ -407,7 +430,8 @@ void TestGitStorage::testGitStorageCloudMerge3()
// (1) open repo, edit notes of first three dives
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
struct dive *dive;
QVERIFY((dive = get_dive(0)) != 0);
@@ -423,7 +447,8 @@ void TestGitStorage::testGitStorageCloudMerge3()
clear_dive_file_data();
// (2) make different edits offline
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QVERIFY((dive = get_dive(0)) != 0);
free(dive->notes);
@@ -442,7 +467,8 @@ void TestGitStorage::testGitStorageCloudMerge3()
// (3) simulate a second system by moving the cache away and open the cloud storage repo and modify
// those first dive notes differently while online
moveDir(localCacheDir, localCacheDir + "save");
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
QVERIFY((dive = get_dive(0)) != 0);
free(dive->notes);
@@ -458,7 +484,8 @@ void TestGitStorage::testGitStorageCloudMerge3()
// (4) move the saved local cache back into place and open the cloud repo -> this forces a merge
moveDir(localCacheDir + "save", localCacheDir);
- QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(qPrintable(cloudTestRepo), &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./SampleDivesMerge3.ssrf"), 0);
// we are not trying to compare this to a pre-determined result... what this test
// checks is that there are no parsing errors with the merge
diff --git a/tests/testmerge.cpp b/tests/testmerge.cpp
index 6055cfacd..b71bb0955 100644
--- a/tests/testmerge.cpp
+++ b/tests/testmerge.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testmerge.h"
+#include "core/device.h"
#include "core/dive.h" // for save_dives()
#include "core/divesite.h"
#include "core/file.h"
@@ -25,10 +26,11 @@ void TestMerge::testMergeEmpty()
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
+ struct device_table devices;
struct filter_preset_table filter_presets;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
QFile org(SUBSURFACE_TEST_DATA "/dives/test47+48.xml");
@@ -52,10 +54,11 @@ void TestMerge::testMergeBackwards()
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
+ struct device_table devices;
struct filter_preset_table filter_presets;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test48.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
QCOMPARE(save_dives("./testmerge47+48.ssrf"), 0);
QFile org(SUBSURFACE_TEST_DATA "/dives/test48+47.xml");
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index 58bb6a153..c0ffaeb36 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testparse.h"
+#include "core/device.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/trip.h"
@@ -82,7 +83,8 @@ int TestParse::parseCSV(int units, std::string file)
xml_params_add_int(&params, "airtempField", -1);
xml_params_add_int(&params, "watertempField", -1);
- return parse_manual_file(file.c_str(), &params, &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ return parse_manual_file(file.c_str(), &params, &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
int TestParse::parseDivingLog()
@@ -93,7 +95,7 @@ int TestParse::parseDivingLog()
int ret = sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql", &_sqlite3_handle);
if (ret == 0)
- ret = parse_divinglog_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table);
+ ret = parse_divinglog_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table, &device_table);
else
fprintf(stderr, "Can't open sqlite3 db: " SUBSURFACE_TEST_DATA "/dives/TestDivingLog4.1.1.sql");
@@ -103,13 +105,15 @@ int TestParse::parseDivingLog()
int TestParse::parseV2NoQuestion()
{
// parsing of a V2 file should work
- return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ return parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
int TestParse::parseV3()
{
// parsing of a V3 files should succeed
- return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ return parse_file(SUBSURFACE_TEST_DATA "/dives/test42.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
void TestParse::testParse()
@@ -134,7 +138,7 @@ void TestParse::testParse()
void TestParse::testParseDM4()
{
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.db", &_sqlite3_handle), 0);
- QCOMPARE(parse_dm4_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table), 0);
+ QCOMPARE(parse_dm4_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table, &device_table), 0);
QCOMPARE(save_dives("./testdm4out.ssrf"), 0);
FILE_COMPARE("./testdm4out.ssrf",
@@ -144,7 +148,7 @@ void TestParse::testParseDM4()
void TestParse::testParseDM5()
{
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM5.db", &_sqlite3_handle), 0);
- QCOMPARE(parse_dm5_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table), 0);
+ QCOMPARE(parse_dm5_buffer(_sqlite3_handle, 0, 0, 0, &dive_table, &trip_table, &dive_site_table, &device_table), 0);
QCOMPARE(save_dives("./testdm5out.ssrf"), 0);
FILE_COMPARE("./testdm5out.ssrf",
@@ -173,7 +177,8 @@ void TestParse::testParseHUDC()
xml_params_add(&params, "hw", "\"DC text\"");
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.csv",
- &params, "csv", &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
+ &params, "csv", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table),
0);
QCOMPARE(dive_table.nr, 1);
@@ -218,7 +223,8 @@ void TestParse::testParseNewFormat()
"/dives/")
.append(files.at(i))
.toLatin1()
- .data(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
+ .data(), &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table),
0);
QCOMPARE(dive_table.nr, i + 1);
}
@@ -237,7 +243,7 @@ void TestParse::testParseDLD()
QString filename = SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.DLD";
QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
- QVERIFY(try_to_open_zip(filename.toLatin1().data(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table) > 0);
+ QVERIFY(try_to_open_zip(filename.toLatin1().data(), &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table) > 0);
fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
@@ -252,8 +258,10 @@ void TestParse::testParseMerge()
/*
* check that we correctly merge mixed cylinder dives
*/
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table), 0);
QCOMPARE(save_dives("./testmerge.ssrf"), 0);
FILE_COMPARE("./testmerge.ssrf",
SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml");
@@ -293,15 +301,16 @@ int TestParse::parseCSVmanual(int units, std::string file)
xml_params_add_int(&params, "datefmt", 2);
xml_params_add_int(&params, "durationfmt", 2);
xml_params_add_int(&params, "units", units);
-
- return parse_manual_file(file.c_str(), &params, &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ return parse_manual_file(file.c_str(), &params, &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
void TestParse::exportCSVDiveDetails()
{
int saved_sac = 0;
- parse_file(SUBSURFACE_TEST_DATA "/dives/test25.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(SUBSURFACE_TEST_DATA "/dives/test25.xml", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table);
export_dives_xslt("testcsvexportmanual.csv", 0, 0, "xml2manualcsv.xslt", false);
export_dives_xslt("testcsvexportmanualimperial.csv", 0, 1, "xml2manualcsv.xslt", false);
@@ -336,7 +345,8 @@ void TestParse::exportSubsurfaceCSV()
xml_params params;
/* Test SubsurfaceCSV with multiple cylinders */
- parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
export_dives_xslt("testcsvexportmanual-cyl.csv", 0, 0, "xml2manualcsv.xslt", false);
export_dives_xslt("testcsvexportmanualimperial-cyl.csv", 0, 1, "xml2manualcsv.xslt", false);
@@ -350,7 +360,8 @@ void TestParse::exportSubsurfaceCSV()
xml_params_add_int(&params, "separatorIndex", 0);
xml_params_add_int(&params, "units", 1);
- parse_csv_file("testcsvexportmanualimperial-cyl.csv", &params, "SubsurfaceCSV", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_csv_file("testcsvexportmanualimperial-cyl.csv", &params, "SubsurfaceCSV", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
// We do not currently support reading SAC, thus faking it
if (dive_table.nr > 0) {
@@ -383,12 +394,14 @@ int TestParse::parseCSVprofile(int units, std::string file)
xml_params_add_int(&params, "datefmt", 2);
xml_params_add_int(&params, "units", units);
- return parse_csv_file(file.c_str(), &params, "csv", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ return parse_csv_file(file.c_str(), &params, "csv", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
void TestParse::exportCSVDiveProfile()
{
- parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
export_dives_xslt("testcsvexportprofile.csv", 0, 0, "xml2csv.xslt", false);
export_dives_xslt("testcsvexportprofileimperial.csv", 0, 1, "xml2csv.xslt", false);
@@ -406,13 +419,14 @@ void TestParse::exportCSVDiveProfile()
void TestParse::exportUDDF()
{
- parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
export_dives_xslt("testuddfexport.uddf", 0, 1, "uddf-export.xslt", false);
clear_dive_file_data();
- parse_file("testuddfexport.uddf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file("testuddfexport.uddf", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table);
export_dives_xslt("testuddfexport2.uddf", 0, 1, "uddf-export.xslt", false);
FILE_COMPARE("testuddfexport.uddf",
@@ -456,7 +470,7 @@ void TestParse::parseDL7()
clear_dive_file_data();
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/DL7.zxu",
- &params, "DL7", &dive_table, &trip_table, &dive_site_table, &filter_preset_table),
+ &params, "DL7", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table),
0);
QCOMPARE(dive_table.nr, 3);
diff --git a/tests/testparseperformance.cpp b/tests/testparseperformance.cpp
index 8ca850918..32ca27a6d 100644
--- a/tests/testparseperformance.cpp
+++ b/tests/testparseperformance.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testparseperformance.h"
+#include "core/device.h"
#include "core/divesite.h"
#include "core/trip.h"
#include "core/file.h"
@@ -63,7 +64,8 @@ void TestParsePerformance::parseSsrf()
return;
}
QBENCHMARK {
- parse_file(SUBSURFACE_TEST_DATA "/dives/large-anon.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(SUBSURFACE_TEST_DATA "/dives/large-anon.ssrf", &dive_table, &trip_table,
+ &dive_site_table, &device_table, &filter_preset_table);
}
}
@@ -74,12 +76,14 @@ void TestParsePerformance::parseGit()
// first parse this once to populate the local cache - this way network
// effects don't dominate the parse time
- parse_file(LARGE_TEST_REPO "[git]", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(LARGE_TEST_REPO "[git]", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table);
cleanup();
QBENCHMARK {
- parse_file(LARGE_TEST_REPO "[git]", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file(LARGE_TEST_REPO "[git]", &dive_table, &trip_table, &dive_site_table,
+ &device_table, &filter_preset_table);
}
}
diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp
index c8215a09e..2833a8144 100644
--- a/tests/testpicture.cpp
+++ b/tests/testpicture.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testpicture.h"
+#include "core/device.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
@@ -26,7 +27,7 @@ void TestPicture::addPicture()
struct picture *pic1, *pic2;
verbose = 1;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test44.xml", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table), 0);
dive = get_dive(0);
// Pictures will be added to selected dives
dive->selected = true;
diff --git a/tests/testprofile.cpp b/tests/testprofile.cpp
index 22edb24de..c40c3083a 100644
--- a/tests/testprofile.cpp
+++ b/tests/testprofile.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testprofile.h"
+#include "core/device.h"
#include "core/divesite.h"
#include "core/trip.h"
#include "core/file.h"
@@ -12,10 +13,9 @@
// ..dives/exportprofilereference.csv) and copy the former over the later and commit that change
// as well.
-
void TestProfile::testProfileExport()
{
- parse_file("../dives/abitofeverything.ssrf", &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
+ parse_file("../dives/abitofeverything.ssrf", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table);
save_profiledata("exportprofile.csv", false);
QFile org("../dives/exportprofilereference.csv");
org.open(QFile::ReadOnly);
diff --git a/tests/testrenumber.cpp b/tests/testrenumber.cpp
index 36c9f36cd..af5bd0203 100644
--- a/tests/testrenumber.cpp
+++ b/tests/testrenumber.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "testrenumber.h"
+#include "core/device.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "core/trip.h"
@@ -8,7 +9,7 @@
void TestRenumber::setup()
{
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table, &trip_table, &dive_site_table, &filter_preset_table), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47.xml", &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table), 0);
process_loaded_dives();
}
@@ -17,8 +18,9 @@ void TestRenumber::testMerge()
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
+ struct device_table devices;
struct filter_preset_table filter_presets;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
QCOMPARE(dive_table.nr, 1);
QCOMPARE(unsaved_changes(), 1);
@@ -30,8 +32,9 @@ void TestRenumber::testMergeAndAppend()
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
+ struct device_table devices;
struct filter_preset_table filter_presets;
- QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml", &table, &trips, &sites, &filter_presets), 0);
+ QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47c.xml", &table, &trips, &sites, &devices, &filter_presets), 0);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
QCOMPARE(dive_table.nr, 2);
QCOMPARE(unsaved_changes(), 1);