summaryrefslogtreecommitdiffstats
path: root/tests/testparse.cpp
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2017-05-07 16:32:11 +0300
committerGravatar Miika Turkia <miika.turkia@gmail.com>2017-05-07 16:32:11 +0300
commit0829d601c692c80d92858c8bd9ccf9dbde1416f3 (patch)
tree019cb25fe24d4e83f96fe669c1039900f8a927e0 /tests/testparse.cpp
parentc832973df5a8b22ea58bafba088835592aca632e (diff)
downloadsubsurface-0829d601c692c80d92858c8bd9ccf9dbde1416f3.tar.gz
Change test case to use new Seabear parsing function
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'tests/testparse.cpp')
-rw-r--r--tests/testparse.cpp110
1 files changed, 2 insertions, 108 deletions
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index cb98e051f..f9947fe95 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -244,116 +244,10 @@ void TestParse::testParseNewFormat()
*/
for (int i = 0; i < files.size(); ++i) {
- QString delta;
- QStringList currColumns;
- QStringList headers;
- QString file = QString::fromLatin1(SUBSURFACE_TEST_DATA "/dives/").append(files.at(i));
- QFile f(file);
-
- /*
- * Parse the sample interval if available from CSV
- * header.
- */
-
- f.open(QFile::ReadOnly);
- while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) {
- if (firstLine.contains("//Log interval: "))
- delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s"));
- }
- firstLine = f.readLine().trimmed();
-
- /*
- * Parse the field configuration from the CSV header.
- */
-
- currColumns = firstLine.split(';');
- Q_FOREACH (QString columnText, currColumns) {
- if (columnText == "Time") {
- headers.append("Sample time");
- } else if (columnText == "Depth") {
- headers.append("Sample depth");
- } else if (columnText == "Temperature") {
- headers.append("Sample temperature");
- } else if (columnText == "NDT") {
- headers.append("Sample NDL");
- } else if (columnText == "TTS") {
- headers.append("Sample TTS");
- } else if (columnText == "pO2_1") {
- headers.append("Sample sensor1 pO₂");
- } else if (columnText == "pO2_2") {
- headers.append("Sample sensor2 pO₂");
- } else if (columnText == "pO2_3") {
- headers.append("Sample sensor3 pO₂");
- } else if (columnText == "Ceiling") {
- headers.append("Sample ceiling");
- } else if (columnText == "Tank pressure") {
- headers.append("Sample pressure");
- } else {
- // We do not know about this value
- qDebug() << "Seabear import found an un-handled field: " << columnText;
- headers.append("");
- }
- f.close();
- }
-
- /*
- * Validate the parsing routine returns success.
- */
-
- char *params[42];
- int pnr = 0;
-
- params[pnr++] = strdup("timeField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample time")));
- params[pnr++] = strdup("depthField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample depth")));
- params[pnr++] = strdup("tempField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample temperature")));
- params[pnr++] = strdup("po2Field");
- params[pnr++] = intdup(headers.indexOf(tr("Sample pO₂")));
- params[pnr++] = strdup("o2sensor1Field");
- params[pnr++] = intdup(headers.indexOf(tr("Sample sensor1 pO₂")));
- params[pnr++] = strdup("o2sensor2Field");
- params[pnr++] = intdup(headers.indexOf(tr("Sample sensor2 pO₂")));
- params[pnr++] = strdup("o2sensor3Field");
- params[pnr++] = intdup(headers.indexOf(tr("Sample sensor3 pO₂")));
- params[pnr++] = strdup("cnsField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample CNS")));
- params[pnr++] = strdup("ndlField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample NDL")));
- params[pnr++] = strdup("ttsField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample TTS")));
- params[pnr++] = strdup("stopdepthField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample stopdepth")));
- params[pnr++] = strdup("pressureField");
- params[pnr++] = intdup(headers.indexOf(tr("Sample pressure")));
- params[pnr++] = strdup("setpointField");
- params[pnr++] = intdup(-1);
- params[pnr++] = strdup("numberField");
- params[pnr++] = intdup(-1);
- params[pnr++] = strdup("separatorIndex");
- params[pnr++] = intdup(2);
- params[pnr++] = strdup("units");
- params[pnr++] = intdup(0);
- params[pnr++] = strdup("delta");
- params[pnr++] = strdup(delta.toUtf8().data());
- params[pnr++] = NULL;
-
- QCOMPARE(parse_seabear_csv_file(file.toUtf8().data(),
- params, pnr - 1, "csv"), 0);
+ QCOMPARE(parse_seabear_log(QString::fromLatin1(SUBSURFACE_TEST_DATA
+ "/dives/").append(files.at(i)).toLatin1().data()), 0);
QCOMPARE(dive_table.nr, i + 1);
-
- /*
- * Set artificial but static dive times so the result
- * can be compared to saved one.
- */
-
- if (dive_table.nr > 0) {
- dive = dive_table.dives[dive_table.nr - 1];
- dive->when = 1255152761 + 7200 * i;
- dive->dc.when = 1255152761 + 7200 * i;
- }
}
fprintf(stderr, "number of dives %d \n", dive_table.nr);