From 75f3cb20272039a9651ff415a97f0f69946877c3 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 24 May 2020 16:50:56 +0300 Subject: 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 --- tests/testparse.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/testparse.cpp') 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(); } -- cgit v1.2.3-70-g09d2