diff --git a/tests/TestDeletedObjects.cpp b/tests/TestDeletedObjects.cpp index 765d0f4c6..5ce29cfa0 100644 --- a/tests/TestDeletedObjects.cpp +++ b/tests/TestDeletedObjects.cpp @@ -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; } diff --git a/tests/TestKeePass2Reader.cpp b/tests/TestKeePass2Reader.cpp index 39f9e0b1a..e66aa70ba 100644 --- a/tests/TestKeePass2Reader.cpp +++ b/tests/TestKeePass2Reader.cpp @@ -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) diff --git a/tests/TestKeePass2Writer.cpp b/tests/TestKeePass2Writer.cpp index 903de99be..f2b40f94d 100644 --- a/tests/TestKeePass2Writer.cpp +++ b/tests/TestKeePass2Writer.cpp @@ -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) diff --git a/tests/TestKeePass2Writer.h b/tests/TestKeePass2Writer.h index a18433cd5..dee68c290 100644 --- a/tests/TestKeePass2Writer.h +++ b/tests/TestKeePass2Writer.h @@ -31,6 +31,7 @@ private Q_SLOTS: void testBasic(); void testProtectedAttributes(); void testAttachments(); + void cleanupTestCase(); private: Database* m_dbOrg; diff --git a/tests/TestKeePass2XmlReader.cpp b/tests/TestKeePass2XmlReader.cpp index 0e36618cf..bbd53a7e9 100644 --- a/tests/TestKeePass2XmlReader.cpp +++ b/tests/TestKeePass2XmlReader.cpp @@ -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) diff --git a/tests/TestKeePass2XmlReader.h b/tests/TestKeePass2XmlReader.h index 43dce003a..415d734d1 100644 --- a/tests/TestKeePass2XmlReader.h +++ b/tests/TestKeePass2XmlReader.h @@ -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);