[PATCH 1/3] Test case: reading zip and DLD parsing

Miika Turkia miika.turkia at gmail.com
Sun Sep 13 11:30:25 PDT 2015


Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 file.c              |  2 +-
 file.h              |  1 +
 tests/testparse.cpp | 12 ++++++++++++
 tests/testparse.h   |  1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/file.c b/file.c
index 19d708f..a7a340f 100644
--- a/file.c
+++ b/file.c
@@ -85,7 +85,7 @@ static void zip_read(struct zip_file *file, const char *filename)
 	free(mem);
 }
 
-static int try_to_open_zip(const char *filename, struct memblock *mem)
+int try_to_open_zip(const char *filename, struct memblock *mem)
 {
 	int success = 0;
 	/* Grr. libzip needs to re-open the file, it can't take a buffer */
diff --git a/file.h b/file.h
index baeb8e1..8551099 100644
--- a/file.h
+++ b/file.h
@@ -16,6 +16,7 @@ extern "C" {
 #endif
 extern int readfile(const char *filename, struct memblock *mem);
 extern timestamp_t parse_date(const char *date);
+extern int try_to_open_zip(const char *filename, struct memblock *mem);
 #ifdef __cplusplus
 }
 #endif
diff --git a/tests/testparse.cpp b/tests/testparse.cpp
index 7d892fa..3490ad8 100644
--- a/tests/testparse.cpp
+++ b/tests/testparse.cpp
@@ -357,4 +357,16 @@ void TestParse::testParseCompareNewFormatOutput()
 	clear_dive_file_data();
 }
 
+void TestParse::testParseDLD()
+{
+	struct memblock mem;
+	int ret, success = 0;
+	QString filename = SUBSURFACE_SOURCE "/dives/TestDiveDivelogsDE.DLD";
+
+	QVERIFY(readfile(filename.toLatin1().data(), &mem) > 0);
+	QVERIFY(try_to_open_zip(filename.toLatin1().data(), &mem) > 0);
+
+	fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
+}
+
 QTEST_MAIN(TestParse)
diff --git a/tests/testparse.h b/tests/testparse.h
index 53cc07a..147c0e1 100644
--- a/tests/testparse.h
+++ b/tests/testparse.h
@@ -17,6 +17,7 @@ private slots:
 	void testParseCompareHUDCOutput();
 	void testParseNewFormat();
 	void testParseCompareNewFormatOutput();
+	void testParseDLD();
 };
 
 #endif
-- 
2.1.4



More information about the subsurface mailing list