File indexing completed on 2024-05-12 16:45:25
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file is a test script. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 #include "skgtestmacro.h" 0012 #include "skgbankincludes.h" 0013 0014 /** 0015 * The main function of the unit test 0016 * @param argc the number of arguments 0017 * @param argv the list of arguments 0018 */ 0019 int main(int argc, char** argv) 0020 { 0021 Q_UNUSED(argc) 0022 Q_UNUSED(argv) 0023 0024 // Init test 0025 SKGINITTEST(true) 0026 0027 { 0028 // Test restore 0029 SKGDocumentBank document1; 0030 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0031 SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true) 0032 SKGTESTERROR(QStringLiteral("document1.load(pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/pwd.skg", QLatin1String(""), true), false) 0033 SKGTESTERROR(QStringLiteral("document1.load(pwd.skg, a)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/pwd.skg", QStringLiteral("a"), true), true) 0034 0035 QFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/.nopwd.skg.wrk").remove(); 0036 SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true) 0037 } 0038 0039 { 0040 // Test load file 0041 SKGDocumentBank document1; 0042 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0043 SKGTESTERROR(QStringLiteral("document1.load(sqlite_no_pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlite_no_pwd.skg", QLatin1String(""), true), true) 0044 SKGTESTERROR(QStringLiteral("document1.load(sqlite_pwd_ABC.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlite_pwd_ABC.skg", QStringLiteral("ABC"), true), true) 0045 SKGTESTERROR(QStringLiteral("document1.load(sqlcipher_no_pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlcipher_no_pwd.skg", QLatin1String(""), true), true) 0046 SKGTESTERROR(QStringLiteral("document1.load(sqlcipher_pwd_ABC.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlcipher_pwd_ABC.skg", QStringLiteral("ABC"), true), true) 0047 } 0048 0049 { 0050 // Test load (sqlite mode) + save + load 0051 SKGDocumentBank document1; 0052 SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true) 0053 SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true) 0054 SKGTESTERROR(QStringLiteral("document1.saveas(nopwd2.skg)"), document1.saveAs(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd2.skg", true), true) 0055 SKGTESTERROR(QStringLiteral("document1.load(nopwd2.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd2.skg", QLatin1String(""), true), true) 0056 } 0057 0058 { 0059 SKGDocumentBank document1; 0060 SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % QStringLiteral("skgtestrestore/recovery.skg"), QLatin1String(""), true), true) 0061 } 0062 // End test 0063 SKGENDTEST() 0064 }