mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 15:59:50 -05:00
Merge pull request #66 from JosefVitu/fix-tests
Fix memory leaks and typos in various tests
This commit is contained in:
commit
3f80134f07
@ -42,7 +42,7 @@ void TestCsvExporter::initTestCase()
|
|||||||
Crypto::init();
|
Crypto::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestCsvExporter::cleanUp()
|
void TestCsvExporter::cleanup()
|
||||||
{
|
{
|
||||||
delete m_db;
|
delete m_db;
|
||||||
delete m_csvExporter;
|
delete m_csvExporter;
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void init();
|
void init();
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void cleanUp();
|
void cleanup();
|
||||||
void testExport();
|
void testExport();
|
||||||
void testEmptyDatabase();
|
void testEmptyDatabase();
|
||||||
void testNestedGroups();
|
void testNestedGroups();
|
||||||
|
@ -79,6 +79,8 @@ void TestEntry::testCopyDataFrom()
|
|||||||
QCOMPARE(entry2->autoTypeAssociations()->size(), 2);
|
QCOMPARE(entry2->autoTypeAssociations()->size(), 2);
|
||||||
QCOMPARE(entry2->autoTypeAssociations()->get(0).window, QString("1"));
|
QCOMPARE(entry2->autoTypeAssociations()->get(0).window, QString("1"));
|
||||||
QCOMPARE(entry2->autoTypeAssociations()->get(1).window, QString("3"));
|
QCOMPARE(entry2->autoTypeAssociations()->get(1).window, QString("3"));
|
||||||
|
|
||||||
|
delete entry2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestEntry::testClone()
|
void TestEntry::testClone()
|
||||||
@ -101,6 +103,7 @@ void TestEntry::testClone()
|
|||||||
QCOMPARE(entryCloneNone->title(), QString("New Title"));
|
QCOMPARE(entryCloneNone->title(), QString("New Title"));
|
||||||
QCOMPARE(entryCloneNone->historyItems().size(), 0);
|
QCOMPARE(entryCloneNone->historyItems().size(), 0);
|
||||||
QCOMPARE(entryCloneNone->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
QCOMPARE(entryCloneNone->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
||||||
|
delete entryCloneNone;
|
||||||
|
|
||||||
Entry* entryCloneNewUuid = entryOrg->clone(Entry::CloneNewUuid);
|
Entry* entryCloneNewUuid = entryOrg->clone(Entry::CloneNewUuid);
|
||||||
QVERIFY(entryCloneNewUuid->uuid() != entryOrg->uuid());
|
QVERIFY(entryCloneNewUuid->uuid() != entryOrg->uuid());
|
||||||
@ -108,17 +111,22 @@ void TestEntry::testClone()
|
|||||||
QCOMPARE(entryCloneNewUuid->title(), QString("New Title"));
|
QCOMPARE(entryCloneNewUuid->title(), QString("New Title"));
|
||||||
QCOMPARE(entryCloneNewUuid->historyItems().size(), 0);
|
QCOMPARE(entryCloneNewUuid->historyItems().size(), 0);
|
||||||
QCOMPARE(entryCloneNewUuid->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
QCOMPARE(entryCloneNewUuid->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
||||||
|
delete entryCloneNewUuid;
|
||||||
|
|
||||||
Entry* entryCloneResetTime = entryOrg->clone(Entry::CloneResetTimeInfo);
|
Entry* entryCloneResetTime = entryOrg->clone(Entry::CloneResetTimeInfo);
|
||||||
QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid());
|
QCOMPARE(entryCloneResetTime->uuid(), entryOrg->uuid());
|
||||||
QCOMPARE(entryCloneResetTime->title(), QString("New Title"));
|
QCOMPARE(entryCloneResetTime->title(), QString("New Title"));
|
||||||
QCOMPARE(entryCloneResetTime->historyItems().size(), 0);
|
QCOMPARE(entryCloneResetTime->historyItems().size(), 0);
|
||||||
QVERIFY(entryCloneResetTime->timeInfo().creationTime() != entryOrg->timeInfo().creationTime());
|
QVERIFY(entryCloneResetTime->timeInfo().creationTime() != entryOrg->timeInfo().creationTime());
|
||||||
|
delete entryCloneResetTime;
|
||||||
|
|
||||||
Entry* entryCloneHistory = entryOrg->clone(Entry::CloneIncludeHistory);
|
Entry* entryCloneHistory = entryOrg->clone(Entry::CloneIncludeHistory);
|
||||||
QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid());
|
QCOMPARE(entryCloneHistory->uuid(), entryOrg->uuid());
|
||||||
QCOMPARE(entryCloneHistory->title(), QString("New Title"));
|
QCOMPARE(entryCloneHistory->title(), QString("New Title"));
|
||||||
QCOMPARE(entryCloneHistory->historyItems().size(), 1);
|
QCOMPARE(entryCloneHistory->historyItems().size(), 1);
|
||||||
QCOMPARE(entryCloneHistory->historyItems().at(0)->title(), QString("Original Title"));
|
QCOMPARE(entryCloneHistory->historyItems().at(0)->title(), QString("Original Title"));
|
||||||
QCOMPARE(entryCloneHistory->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
QCOMPARE(entryCloneHistory->timeInfo().creationTime(), entryOrg->timeInfo().creationTime());
|
||||||
|
delete entryCloneHistory;
|
||||||
|
|
||||||
|
delete entryOrg;
|
||||||
}
|
}
|
||||||
|
@ -445,4 +445,7 @@ void TestGroup::testCopyCustomIcons()
|
|||||||
|
|
||||||
QCOMPARE(metaTarget->customIcon(group1Icon).pixel(0, 0), qRgb(1, 2, 3));
|
QCOMPARE(metaTarget->customIcon(group1Icon).pixel(0, 0), qRgb(1, 2, 3));
|
||||||
QCOMPARE(metaTarget->customIcon(group2Icon).pixel(0, 0), qRgb(4, 5, 6));
|
QCOMPARE(metaTarget->customIcon(group2Icon).pixel(0, 0), qRgb(4, 5, 6));
|
||||||
|
|
||||||
|
delete dbTarget;
|
||||||
|
delete dbSource;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ void TestWildcardMatcher::testMatcher()
|
|||||||
|
|
||||||
initMatcher(text);
|
initMatcher(text);
|
||||||
verifyMatchResult(pattern, match);
|
verifyMatchResult(pattern, match);
|
||||||
|
cleanupMatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWildcardMatcher::initMatcher(QString text)
|
void TestWildcardMatcher::initMatcher(QString text)
|
||||||
@ -62,6 +63,11 @@ void TestWildcardMatcher::initMatcher(QString text)
|
|||||||
m_matcher = new WildcardMatcher(text);
|
m_matcher = new WildcardMatcher(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestWildcardMatcher::cleanupMatcher()
|
||||||
|
{
|
||||||
|
delete m_matcher;
|
||||||
|
}
|
||||||
|
|
||||||
void TestWildcardMatcher::verifyMatchResult(QString pattern, bool expected)
|
void TestWildcardMatcher::verifyMatchResult(QString pattern, bool expected)
|
||||||
{
|
{
|
||||||
if (expected) {
|
if (expected) {
|
||||||
|
@ -35,6 +35,7 @@ private:
|
|||||||
static const QString AlternativeText;
|
static const QString AlternativeText;
|
||||||
|
|
||||||
void initMatcher(QString text);
|
void initMatcher(QString text);
|
||||||
|
void cleanupMatcher();
|
||||||
void verifyMatchResult(QString pattern, bool expected);
|
void verifyMatchResult(QString pattern, bool expected);
|
||||||
void verifyMatch(QString pattern);
|
void verifyMatch(QString pattern);
|
||||||
void verifyNoMatch(QString pattern);
|
void verifyNoMatch(QString pattern);
|
||||||
|
Loading…
Reference in New Issue
Block a user