From 726c9e859c60d6506b4b7c9a5a8bd909486ca9f7 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Tue, 9 May 2017 22:28:04 +0300 Subject: [PATCH] Test case for CSV profile export to imperial and back Signed-off-by: Miika Turkia --- tests/testparse.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++ tests/testparse.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/tests/testparse.cpp b/tests/testparse.cpp index 9cea8c6c8..9d2f4dea7 100644 --- a/tests/testparse.cpp +++ b/tests/testparse.cpp @@ -370,6 +370,53 @@ void TestParse::exportCSVDiveDetails() clear_dive_file_data(); } +int TestParse::parseCSVprofile(int units, std::string file) +{ + verbose = 1; + char *params[55]; + int pnr = 0; + + params[pnr++] = strdup("dateField"); + params[pnr++] = intdup(1); + params[pnr++] = strdup("datefmt"); + params[pnr++] = intdup(2); + params[pnr++] = strdup("starttimeField"); + params[pnr++] = intdup(2); + params[pnr++] = strdup("numberField"); + params[pnr++] = intdup(0); + params[pnr++] = strdup("timeField"); + params[pnr++] = intdup(3); + params[pnr++] = strdup("depthField"); + params[pnr++] = intdup(4); + params[pnr++] = strdup("tempField"); + params[pnr++] = intdup(5); + params[pnr++] = strdup("pressureField"); + params[pnr++] = intdup(6); + params[pnr++] = strdup("units"); + params[pnr++] = intdup(units); + params[pnr++] = NULL; + + return parse_csv_file(file.c_str(), params, pnr - 1, "csv"); +} + +void TestParse::exportCSVDiveProfile() +{ + parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); + + export_dives_xslt("testcsvexportprofile.csv", 0, 0, "xml2csv.xslt"); + export_dives_xslt("testcsvexportprofileimperial.csv", 0, 1, "xml2csv.xslt"); + + clear_dive_file_data(); + + parseCSVprofile(1, "testcsvexportprofileimperial.csv"); + export_dives_xslt("testcsvexportprofile2.csv", 0, 0, "xml2csv.xslt"); + + FILE_COMPARE("testcsvexportprofile2.csv", + "testcsvexportprofile.csv"); + + clear_dive_file_data(); +} + void TestParse::exportUDDF() { parse_file(SUBSURFACE_TEST_DATA "/dives/test40.xml"); @@ -390,6 +437,7 @@ void TestParse::exportUDDF() void TestParse::testExport() { exportCSVDiveDetails(); + exportCSVDiveProfile(); exportUDDF(); } diff --git a/tests/testparse.h b/tests/testparse.h index 80c4dacfb..8c64c83ce 100644 --- a/tests/testparse.h +++ b/tests/testparse.h @@ -26,6 +26,8 @@ private slots: int parseCSVmanual(int, std::string); void exportCSVDiveDetails(); + int parseCSVprofile(int, std::string); + void exportCSVDiveProfile(); void exportUDDF(); void testExport();