Test case: reading zip and DLD parsing

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2015-09-13 21:30:25 +03:00 committed by Dirk Hohndel
parent 3fb017a1c3
commit 0160e58e7d
4 changed files with 15 additions and 1 deletions

2
file.c
View file

@ -85,7 +85,7 @@ static void zip_read(struct zip_file *file, const char *filename)
free(mem); 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; int success = 0;
/* Grr. libzip needs to re-open the file, it can't take a buffer */ /* Grr. libzip needs to re-open the file, it can't take a buffer */

1
file.h
View file

@ -16,6 +16,7 @@ extern "C" {
#endif #endif
extern int readfile(const char *filename, struct memblock *mem); extern int readfile(const char *filename, struct memblock *mem);
extern timestamp_t parse_date(const char *date); extern timestamp_t parse_date(const char *date);
extern int try_to_open_zip(const char *filename, struct memblock *mem);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -357,4 +357,16 @@ void TestParse::testParseCompareNewFormatOutput()
clear_dive_file_data(); 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) QTEST_MAIN(TestParse)

View file

@ -17,6 +17,7 @@ private slots:
void testParseCompareHUDCOutput(); void testParseCompareHUDCOutput();
void testParseNewFormat(); void testParseNewFormat();
void testParseCompareNewFormatOutput(); void testParseCompareNewFormatOutput();
void testParseDLD();
}; };
#endif #endif