mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-23 05:01:19 -05:00
Memory management fixes in tests.
This commit is contained in:
parent
ecc11d3207
commit
bf25959b68
@ -87,9 +87,9 @@ void TestDeletedObjects::createAndDelete(Database* db, int delObjectsSize)
|
||||
|
||||
void TestDeletedObjects::testDeletedObjectsFromFile()
|
||||
{
|
||||
KeePass2XmlReader* reader = new KeePass2XmlReader();
|
||||
KeePass2XmlReader reader;
|
||||
QString xmlFile = QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.xml");
|
||||
Database* db = reader->readDatabase(xmlFile);
|
||||
Database* db = reader.readDatabase(xmlFile);
|
||||
|
||||
createAndDelete(db, 2);
|
||||
|
||||
@ -154,6 +154,7 @@ void TestDeletedObjects::testDatabaseChange()
|
||||
QCOMPARE(db->deletedObjects().size(), delObjectsSize);
|
||||
QCOMPARE(db2->deletedObjects().size(), delObjectsSize2);
|
||||
|
||||
delete group;
|
||||
delete db;
|
||||
delete db2;
|
||||
}
|
||||
|
@ -38,14 +38,13 @@ void TestKeePass2Reader::testNonAscii()
|
||||
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/NonAscii.kdbx");
|
||||
CompositeKey key;
|
||||
key.addKey(PasswordKey(QString::fromUtf8("\xce\x94\xc3\xb6\xd8\xb6")));
|
||||
KeePass2Reader* reader = new KeePass2Reader();
|
||||
Database* db = reader->readDatabase(filename, key);
|
||||
KeePass2Reader reader;
|
||||
Database* db = reader.readDatabase(filename, key);
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->hasError());
|
||||
QVERIFY(!reader.hasError());
|
||||
QCOMPARE(db->metadata()->name(), QString("NonAsciiTest"));
|
||||
|
||||
delete db;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
void TestKeePass2Reader::testCompressed()
|
||||
@ -53,14 +52,13 @@ void TestKeePass2Reader::testCompressed()
|
||||
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Compressed.kdbx");
|
||||
CompositeKey key;
|
||||
key.addKey(PasswordKey(""));
|
||||
KeePass2Reader* reader = new KeePass2Reader();
|
||||
Database* db = reader->readDatabase(filename, key);
|
||||
KeePass2Reader reader;
|
||||
Database* db = reader.readDatabase(filename, key);
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->hasError());
|
||||
QVERIFY(!reader.hasError());
|
||||
QCOMPARE(db->metadata()->name(), QString("Compressed"));
|
||||
|
||||
delete db;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
void TestKeePass2Reader::testProtectedStrings()
|
||||
@ -68,10 +66,10 @@ void TestKeePass2Reader::testProtectedStrings()
|
||||
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/ProtectedStrings.kdbx");
|
||||
CompositeKey key;
|
||||
key.addKey(PasswordKey("masterpw"));
|
||||
KeePass2Reader* reader = new KeePass2Reader();
|
||||
Database* db = reader->readDatabase(filename, key);
|
||||
KeePass2Reader reader;
|
||||
Database* db = reader.readDatabase(filename, key);
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->hasError());
|
||||
QVERIFY(!reader.hasError());
|
||||
QCOMPARE(db->metadata()->name(), QString("Protected Strings Test"));
|
||||
|
||||
Entry* entry = db->rootGroup()->entries().at(0);
|
||||
@ -87,7 +85,6 @@ void TestKeePass2Reader::testProtectedStrings()
|
||||
QVERIFY(!entry->attributes()->isProtected("TestUnprotected"));
|
||||
|
||||
delete db;
|
||||
delete reader;
|
||||
}
|
||||
|
||||
void TestKeePass2Reader::testFormat200()
|
||||
@ -95,10 +92,10 @@ void TestKeePass2Reader::testFormat200()
|
||||
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/Format200.kdbx");
|
||||
CompositeKey key;
|
||||
key.addKey(PasswordKey("a"));
|
||||
KeePass2Reader* reader = new KeePass2Reader();
|
||||
Database* db = reader->readDatabase(filename, key);
|
||||
KeePass2Reader reader;
|
||||
Database* db = reader.readDatabase(filename, key);
|
||||
QVERIFY(db);
|
||||
QVERIFY(!reader->hasError());
|
||||
QVERIFY(!reader.hasError());
|
||||
|
||||
QCOMPARE(db->rootGroup()->name(), QString("Format200"));
|
||||
QVERIFY(!db->metadata()->protectTitle());
|
||||
@ -120,6 +117,8 @@ void TestKeePass2Reader::testFormat200()
|
||||
QCOMPARE(entry->historyItems().at(0)->attachments()->keys().size(), 0);
|
||||
QCOMPARE(entry->historyItems().at(1)->attachments()->keys().size(), 1);
|
||||
QCOMPARE(entry->historyItems().at(1)->attachments()->value("myattach.txt"), QByteArray("abcdefghijk"));
|
||||
|
||||
delete db;
|
||||
}
|
||||
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2Reader)
|
||||
|
@ -93,4 +93,10 @@ void TestKeePass2Writer::testAttachments()
|
||||
QCOMPARE(entry->attachments()->value("aaa.txt"), QByteArray("also an attachment"));
|
||||
}
|
||||
|
||||
void TestKeePass2Writer::cleanupTestCase()
|
||||
{
|
||||
delete m_dbOrg;
|
||||
delete m_dbTest;
|
||||
}
|
||||
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2Writer)
|
||||
|
@ -31,6 +31,7 @@ private Q_SLOTS:
|
||||
void testBasic();
|
||||
void testProtectedAttributes();
|
||||
void testAttachments();
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
Database* m_dbOrg;
|
||||
|
@ -67,11 +67,11 @@ void TestKeePass2XmlReader::initTestCase()
|
||||
{
|
||||
Crypto::init();
|
||||
|
||||
KeePass2XmlReader* reader = new KeePass2XmlReader();
|
||||
KeePass2XmlReader reader;
|
||||
QString xmlFile = QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.xml");
|
||||
m_db = reader->readDatabase(xmlFile);
|
||||
m_db = reader.readDatabase(xmlFile);
|
||||
QVERIFY(m_db);
|
||||
QVERIFY(!reader->hasError());
|
||||
QVERIFY(!reader.hasError());
|
||||
}
|
||||
|
||||
void TestKeePass2XmlReader::testMetadata()
|
||||
@ -351,4 +351,9 @@ void TestKeePass2XmlReader::testDeletedObjects()
|
||||
QVERIFY(objList.isEmpty());
|
||||
}
|
||||
|
||||
void TestKeePass2XmlReader::cleanupTestCase()
|
||||
{
|
||||
delete m_db;
|
||||
}
|
||||
|
||||
KEEPASSX_QTEST_CORE_MAIN(TestKeePass2XmlReader)
|
||||
|
@ -39,6 +39,7 @@ private Q_SLOTS:
|
||||
void testEntry2();
|
||||
void testEntryHistory();
|
||||
void testDeletedObjects();
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
QDateTime genDT(int year, int month, int day, int hour, int min, int second);
|
||||
|
Loading…
Reference in New Issue
Block a user