mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Clean up objects in the tests.
This commit is contained in:
parent
5cb906c235
commit
a104e859cf
@ -45,7 +45,7 @@ void TestEntryModel::test()
|
||||
|
||||
EntryModel* model = new EntryModel(this);
|
||||
|
||||
new ModelTest(model, this);
|
||||
ModelTest* modelTest = new ModelTest(model, this);
|
||||
|
||||
model->setGroup(group1);
|
||||
|
||||
@ -87,6 +87,9 @@ void TestEntryModel::test()
|
||||
|
||||
delete group1;
|
||||
delete group2;
|
||||
|
||||
delete modelTest;
|
||||
delete model;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestEntryModel);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "TestGroup.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtTest/QSignalSpy>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
@ -32,10 +33,11 @@ void TestGroup::testParenting()
|
||||
Database* db = new Database();
|
||||
Group* tmpRoot = new Group();
|
||||
|
||||
Group* g1 = new Group();
|
||||
Group* g2 = new Group();
|
||||
Group* g3 = new Group();
|
||||
Group* g4 = new Group();
|
||||
QPointer<Group> g1 = new Group();
|
||||
QPointer<Group> g2 = new Group();
|
||||
QPointer<Group> g3 = new Group();
|
||||
QPointer<Group> g4 = new Group();
|
||||
|
||||
g1->setParent(tmpRoot);
|
||||
g2->setParent(tmpRoot);
|
||||
g3->setParent(tmpRoot);
|
||||
@ -74,12 +76,21 @@ void TestGroup::testParenting()
|
||||
g3->setIcon(Uuid::random());
|
||||
g1->setIcon(2);
|
||||
QCOMPARE(spy.count(), 6);
|
||||
|
||||
delete db;
|
||||
|
||||
QVERIFY(g1.isNull());
|
||||
QVERIFY(g2.isNull());
|
||||
QVERIFY(g3.isNull());
|
||||
QVERIFY(g4.isNull());
|
||||
|
||||
delete tmpRoot;
|
||||
}
|
||||
|
||||
void TestGroup::testSignals()
|
||||
{
|
||||
Database* db = new Database();
|
||||
Group* root = new Group();
|
||||
QPointer<Group> root = new Group();
|
||||
root->setParent(db);
|
||||
|
||||
Group* g1 = new Group();
|
||||
@ -100,16 +111,18 @@ void TestGroup::testSignals()
|
||||
QCOMPARE(spyRemoved.count(), 1);
|
||||
|
||||
delete db;
|
||||
|
||||
QVERIFY(root.isNull());
|
||||
}
|
||||
|
||||
void TestGroup::testEntries()
|
||||
{
|
||||
Group* group = new Group();
|
||||
|
||||
Entry* entry1 = new Entry();
|
||||
QPointer<Entry> entry1 = new Entry();
|
||||
entry1->setGroup(group);
|
||||
|
||||
Entry* entry2 = new Entry();
|
||||
QPointer<Entry> entry2 = new Entry();
|
||||
entry2->setGroup(group);
|
||||
|
||||
QCOMPARE(group->entries().size(), 2);
|
||||
@ -117,6 +130,9 @@ void TestGroup::testEntries()
|
||||
QVERIFY(group->entries().at(1) == entry2);
|
||||
|
||||
delete group;
|
||||
|
||||
QVERIFY(entry1.isNull());
|
||||
QVERIFY(entry2.isNull());
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGroup);
|
||||
|
@ -60,7 +60,7 @@ void TestGroupModel::test()
|
||||
|
||||
GroupModel* model = new GroupModel(db, this);
|
||||
|
||||
new ModelTest(model, this);
|
||||
ModelTest* modelTest = new ModelTest(model, this);
|
||||
|
||||
QModelIndex indexRoot = model->index(0, 0);
|
||||
QModelIndex index1 = model->index(0, 0, indexRoot);
|
||||
@ -95,6 +95,9 @@ void TestGroupModel::test()
|
||||
|
||||
delete groupRoot;
|
||||
delete db;
|
||||
|
||||
delete modelTest;
|
||||
delete model;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGroupModel);
|
||||
|
@ -41,6 +41,9 @@ void TestKeePass2Reader::testNonAscii()
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->error());
|
||||
QCOMPARE(db->metadata()->name(), QString("NonAsciiTest"));
|
||||
|
||||
delete db;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
void TestKeePass2Reader::testCompressed()
|
||||
@ -53,6 +56,9 @@ void TestKeePass2Reader::testCompressed()
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->error());
|
||||
QCOMPARE(db->metadata()->name(), QString("Compressed"));
|
||||
|
||||
delete db;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeePass2Reader);
|
||||
|
Loading…
Reference in New Issue
Block a user