summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2020-05-24 16:50:56 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-26 11:33:10 -0700
commit75f3cb20272039a9651ff415a97f0f69946877c3 (patch)
tree2e1b1518d27567bc7251e9bfe06cca6b911ce87c /tests
parente8f97cbc3f6d16bd3bb2688d5b6086383d2bfaf7 (diff)
downloadsubsurface-75f3cb20272039a9651ff415a97f0f69946877c3.tar.gz
Test case for multicylinder support on CSV import
Test for importing Subsurface generated CSV dive details, with multiple cylinders support. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/testparse.cpp41
-rw-r--r--tests/testparse.h1
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index 982a269d2..8e366a6fc 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -402,6 +402,46 @@ void TestParse::exportCSVDiveDetails()
clear_dive_file_data();
}
+void TestParse::exportSubsurfaceCSV()
+{
+ int saved_sac = 0;
+ char *params[59];
+ int pnr = 0;
+
+ /* Test SubsurfaceCSV with multiple cylinders */
+ parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml", &dive_table, &trip_table, &dive_site_table);
+
+ export_dives_xslt("testcsvexportmanual-cyl.csv", 0, 0, "xml2manualcsv.xslt", false);
+ export_dives_xslt("testcsvexportmanualimperial-cyl.csv", 0, 1, "xml2manualcsv.xslt", false);
+
+ if (dive_table.nr > 0) {
+ struct dive *dive = dive_table.dives[dive_table.nr - 1];
+ saved_sac = dive->sac;
+ }
+
+ clear_dive_file_data();
+
+ params[pnr++] = strdup("separatorIndex");
+ params[pnr++] = intdup(0);
+ params[pnr++] = strdup("units");
+ params[pnr++] = intdup(1);
+ params[pnr++] = 0;
+ parse_csv_file("testcsvexportmanualimperial-cyl.csv", params, pnr - 1, "SubsurfaceCSV", &dive_table, &trip_table, &dive_site_table);
+
+ // We do not currently support reading SAC, thus faking it
+ if (dive_table.nr > 0) {
+ struct dive *dive = dive_table.dives[dive_table.nr - 1];
+ dive->sac = saved_sac;
+ }
+
+ export_dives_xslt("testcsvexportmanual2-cyl.csv", 0, 0, "xml2manualcsv.xslt", false);
+
+ FILE_COMPARE("testcsvexportmanual2-cyl.csv",
+ "testcsvexportmanual-cyl.csv");
+
+ clear_dive_file_data();
+}
+
int TestParse::parseCSVprofile(int units, std::string file)
{
verbose = 1;
@@ -471,6 +511,7 @@ void TestParse::exportUDDF()
void TestParse::testExport()
{
exportCSVDiveDetails();
+ exportSubsurfaceCSV();
exportCSVDiveProfile();
exportUDDF();
}
diff --git a/tests/testparse.h b/tests/testparse.h
index c62349022..d1c1c9ded 100644
--- a/tests/testparse.h
+++ b/tests/testparse.h
@@ -26,6 +26,7 @@ private slots:
void testParseMerge();
int parseCSVmanual(int, std::string);
+ void exportSubsurfaceCSV();
void exportCSVDiveDetails();
int parseCSVprofile(int, std::string);
void exportCSVDiveProfile();