Add test for import, merge and renumbering

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-10-05 10:12:19 +01:00
parent f0a176149a
commit cb112f9ac5
3 changed files with 54 additions and 0 deletions

View file

@ -583,6 +583,7 @@ if(NOT NO_TESTS)
TEST(TestParse testparse.cpp)
TEST(TestPlan testplan.cpp)
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
TEST(TestRenumber testrenumber.cpp)
TEST(TestGitStorage testgitstorage.cpp)
endif()

38
tests/testrenumber.cpp Normal file
View file

@ -0,0 +1,38 @@
#include "windowtitleupdate.h"
#include "testrenumber.h"
#include "dive.h"
#include "file.h"
#include "divelist.h"
#include <QTextStream>
void TestRenumber::setup()
{
WindowTitleUpdate *wtu = new WindowTitleUpdate();
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47.xml"), 0);
process_dives(false, false);
dive_table.preexisting = dive_table.nr;
}
void TestRenumber::testMerge()
{
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47b.xml"), 0);
process_dives(true, false);
QCOMPARE(dive_table.nr, 1);
QCOMPARE(unsaved_changes(), 1);
mark_divelist_changed(false);
dive_table.preexisting = dive_table.nr;
}
void TestRenumber::testMergeAndAppend()
{
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test47c.xml"), 0);
process_dives(true, false);
QCOMPARE(dive_table.nr, 2);
QCOMPARE(unsaved_changes(), 1);
struct dive *d = get_dive(1);
QVERIFY(d != NULL);
if (d)
QCOMPARE(d->number, 2);
}
QTEST_MAIN(TestRenumber)

15
tests/testrenumber.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef TESTRENUMBER_H
#define TESTRENUMBER_H
#include <QtTest>
class TestRenumber : public QObject
{
Q_OBJECT
private slots:
void setup();
void testMerge();
void testMergeAndAppend();
};
#endif