diff --git a/tests/skgbankmodelertest/skgtestautoreconcile.cpp b/tests/skgbankmodelertest/skgtestautoreconcile.cpp index ae3fc3ea9..88f4223b3 100644 --- a/tests/skgbankmodelertest/skgtestautoreconcile.cpp +++ b/tests/skgbankmodelertest/skgtestautoreconcile.cpp @@ -1,141 +1,141 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import bankperfect SKGError err; SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BP_CSV"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsv/bankperfect.csv")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } { SKGBEGINTRANSACTION(document1, QStringLiteral("AUTORECONCILE"), err); SKGAccountObject account1(&document1); SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account1.setName(QStringLiteral("bankperfect")), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account1.load(), true); auto soluces = account1.getPossibleReconciliations(3547.14); SKGTEST(QStringLiteral("ACCOUNT.getPossibleReconciliations"), soluces.count(), 1); SKGTESTERROR(QStringLiteral("ACCOUNT.autoReconcile"), account1.autoReconcile(3547.14), true); } } { // Test import bankperfect SKGError err; SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestautoreconcile/complex.skg"), true); { SKGBEGINTRANSACTION(document1, QStringLiteral("AUTORECONCILE"), err); { SKGAccountObject account1(&document1); SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account1.setName(QStringLiteral("EURO")), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account1.load(), true); auto soluces = account1.getPossibleReconciliations(3699.67); SKGTEST(QStringLiteral("ACCOUNT.getPossibleReconciliations"), soluces.count(), 1); SKGTESTERROR(QStringLiteral("ACCOUNT.autoReconcile"), account1.autoReconcile(3699.67), true); soluces = account1.getPossibleReconciliations(3699.67); SKGTEST(QStringLiteral("ACCOUNT.getPossibleReconciliations"), soluces.count(), 1); SKGTESTERROR(QStringLiteral("ACCOUNT.autoReconcile"), account1.autoReconcile(3699.67), true); } { SKGAccountObject account1(&document1); SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account1.setName(QStringLiteral("DOLLAR")), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account1.load(), true); auto soluces = account1.getPossibleReconciliations(3699.67); SKGTEST(QStringLiteral("ACCOUNT.getPossibleReconciliations"), soluces.count(), 1); SKGTESTERROR(QStringLiteral("ACCOUNT.autoReconcile"), account1.autoReconcile(3699.67), true); SKGTESTERROR(QStringLiteral("ACCOUNT.autoReconcile"), account1.autoReconcile(3699.67), true); } } } { // Test many combinations SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestautoreconcile/many_combinations.csv")); SKGTESTERROR(QStringLiteral("CSV.importFile"), imp1.importFile(), true); document1.dump(DUMPOPERATION | DUMPACCOUNT); } { SKGAccountObject account1(&document1); SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account1.setName(QStringLiteral("many combinations")), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account1.load(), true); auto soluces = account1.getPossibleReconciliations(53, true); SKGTEST(QStringLiteral("ACCOUNT.getPossibleReconciliations"), soluces.count(), 1); SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE OPERATIONS"), err); double oBalance; SKGUnitObject oUnit; QDate now = QDate::currentDate(); account1.getInitialBalance(oBalance, oUnit); int nb = 38; for (int i = 1; i <= nb; ++i) { SKGOperationObject op; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op.setUnit(oUnit), true); SKGTESTERROR(QStringLiteral("OPE:setImported"), op.setImported(true), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); SKGSubOperationObject subop; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op.addSubOperation(subop), true); SKGTESTERROR(QStringLiteral("OPE:setQuantity"), subop.setQuantity(10), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop.save(), true); } // Test performance soluces = account1.getPossibleReconciliations(-23 + 10 * nb, true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestbankandaccount.cpp b/tests/skgbankmodelertest/skgtestbankandaccount.cpp index dfd644a35..cfbad2aa2 100644 --- a/tests/skgbankmodelertest/skgtestbankandaccount.cpp +++ b/tests/skgbankmodelertest/skgtestbankandaccount.cpp @@ -1,249 +1,249 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ // Init { // Test bank1 document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation unit SKGUnitObject unit_euro(&document1); SKGTESTERROR(QStringLiteral("BANK:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("BANK:setSymbol"), unit_euro.setSymbol(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("BANK:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("BANK:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("BANK:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("BANK:setDate"), unit_euro_val1.setDate(QDate::currentDate()), true); SKGTESTERROR(QStringLiteral("BANK:save"), unit_euro_val1.save(), true); // Creation bank1 SKGBankObject bank1(&document1); SKGAccountObject account1; SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank1.addAccount(account1), false); SKGTESTERROR(QStringLiteral("BANK:setName"), bank1.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:setIcon"), bank1.setIcon(QStringLiteral("credit cooperatif")), true); SKGTESTERROR(QStringLiteral("BANK:setNumber"), bank1.setNumber(QStringLiteral("111111")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank1.save(), true); SKGTEST(QStringLiteral("BANK:getIcon"), bank1.getIcon(), QStringLiteral("credit cooperatif")); SKGTEST(QStringLiteral("BANK:getNumber"), bank1.getNumber(), QStringLiteral("111111")); SKGBankObject bank11(bank1); // For coverage SKGTESTBOOL("BANK:comparison", (bank11 == bank1), true); SKGBankObject bank12 = bank1; // For coverage SKGTESTBOOL("BANK:comparison", (bank12 == bank1), true); SKGBankObject bank13((SKGNamedObject(bank1))); // For coverage SKGTESTBOOL("BANK:comparison", (bank12 == SKGNamedObject(bank1)), true); SKGNamedObject bank1n(bank1); SKGBankObject bank14(bank1n); // For coverage SKGBankObject bank15(SKGObjectBase(bank1.getDocument(), QStringLiteral("xxx"), bank1.getID())); // For coverage SKGBankObject bank16(SKGNamedObject(bank1.getDocument(), QStringLiteral("xxx"), bank1.getID())); // For coverage // Creation account1 SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank1.addAccount(account1), true); SKGOperationObject op; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op), false); SKGInterestObject it; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addInterest(it), false); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account1.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account1.setNumber(QStringLiteral("12345P")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setAgencyNumber"), account1.setAgencyNumber(QStringLiteral("99999")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setAgencyAddress"), account1.setAgencyAddress(QStringLiteral("10 rue Albert CAMUS\n31000 TOULOUSE")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::CURRENT), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setComment"), account1.setComment(QStringLiteral("bla bla")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setMaxLimitAmount"), account1.setMaxLimitAmount(15000.0), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setMinLimitAmount"), account1.setMinLimitAmount(-500.0), true); SKGTESTERROR(QStringLiteral("ACCOUNT:maxLimitAmountEnabled"), account1.maxLimitAmountEnabled(true), true); SKGTESTERROR(QStringLiteral("ACCOUNT:minLimitAmountEnabled"), account1.minLimitAmountEnabled(false), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account1.save(), true); SKGTEST(QStringLiteral("ACCOUNT:getNumber"), account1.getNumber(), QStringLiteral("12345P")); SKGTEST(QStringLiteral("ACCOUNT:getAgencyNumber"), account1.getAgencyNumber(), QStringLiteral("99999")); SKGTEST(QStringLiteral("ACCOUNT:getAgencyAddress"), account1.getAgencyAddress(), QStringLiteral("10 rue Albert CAMUS\n31000 TOULOUSE")); SKGTEST(QStringLiteral("ACCOUNT:getMaxLimitAmount"), account1.getMaxLimitAmount(), 15000.0); SKGTEST(QStringLiteral("ACCOUNT:getMinLimitAmount"), account1.getMinLimitAmount(), -500.0); SKGTESTERROR(QStringLiteral("ACCOUNT:setMaxLimitAmount"), account1.setMaxLimitAmount(-1000.0), true); SKGTEST(QStringLiteral("ACCOUNT:getMaxLimitAmount"), account1.getMaxLimitAmount(), -1000.0); SKGTEST(QStringLiteral("ACCOUNT:getMinLimitAmount"), account1.getMinLimitAmount(), -1000.0); SKGTESTBOOL("ACCOUNT:isMaxLimitAmountEnabled", account1.isMaxLimitAmountEnabled(), true); SKGTESTBOOL("ACCOUNT:isMinLimitAmountEnabled", account1.isMinLimitAmountEnabled(), false); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::CURRENT)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::CREDITCARD), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::CREDITCARD)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::ASSETS), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::ASSETS)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::INVESTMENT), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::INVESTMENT)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::WALLET), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::WALLET)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::LOAN), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::LOAN)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::SAVING), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::SAVING)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::OTHER), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::OTHER)); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::PENSION), true); SKGTEST(QStringLiteral("ACCOUNT:getType"), static_cast(account1.getType()), static_cast(SKGAccountObject::PENSION)); SKGTEST(QStringLiteral("ACCOUNT:getComment"), account1.getComment(), QStringLiteral("bla bla")); QDate n = QDate::currentDate(); SKGTESTERROR(QStringLiteral("ACCOUNT:setReconciliationDate"), account1.setReconciliationDate(n), true); SKGTEST(QStringLiteral("ACCOUNT:getReconciliationDate"), SKGServices::dateToSqlString(QDateTime(account1.getReconciliationDate())), SKGServices::dateToSqlString(QDateTime(n))); SKGTESTERROR(QStringLiteral("ACCOUNT:setReconciliationBalance"), account1.setReconciliationBalance(125), true); SKGTEST(QStringLiteral("ACCOUNT:getReconciliationBalance"), SKGServices::doubleToString(account1.getReconciliationBalance()), SKGServices::doubleToString(125)); SKGTESTERROR(QStringLiteral("ACCOUNT:setInitialBalance"), account1.setInitialBalance(125, unit_euro), true); double init = 0; SKGUnitObject unit; SKGTESTERROR(QStringLiteral("ACCOUNT:getInitialBalance"), account1.getInitialBalance(init, unit), true); SKGTESTBOOL("ACCOUNT:getInitialBalance", (unit == unit_euro), true); SKGTEST(QStringLiteral("ACCOUNT:getInitialBalance"), init, 125); SKGAccountObject account11(account1); // For coverage SKGTESTBOOL("BANK:comparison", (account11 == account1), true); SKGAccountObject account12(static_cast(account1)); // For coverage SKGTESTBOOL("BANK:comparison", (account12 == account1), true); SKGAccountObject account13(static_cast(account1)); // For coverage SKGTESTBOOL("BANK:comparison", (account13 == account1), true); SKGAccountObject account14(SKGObjectBase(account1.getDocument(), QStringLiteral("xxx"), account1.getID())); // For coverage SKGAccountObject account15(SKGNamedObject(account1.getDocument(), QStringLiteral("xxx"), account1.getID())); // For coverage // Creation bank2 SKGBankObject bank2(&document1); SKGTESTERROR(QStringLiteral("BANK:setName"), bank2.setName(QStringLiteral("NEF")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank2.save(), true); // Creation account2 SKGAccountObject account2; SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank2.addAccount(account2), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account2.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account2.setNumber(QStringLiteral("98765A")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account2.save(false), false); SKGAccountObject account3; SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank2.addAccount(account3), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account3.setName(QStringLiteral("Courant vero")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account3.setNumber(QStringLiteral("98765A")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account3.save(), true); QStringList oResult; SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("bank"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("account"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); SKGObjectBase::SKGListSKGObjectBase oAccountList; SKGTESTERROR(QStringLiteral("BANK:getAccounts"), bank1.getAccounts(oAccountList), true); SKGTEST(QStringLiteral("ACCOUNT:count"), oAccountList.count(), 1); SKGTESTERROR(QStringLiteral("BANK:getAccounts"), bank2.getAccounts(oAccountList), true); SKGTEST(QStringLiteral("ACCOUNT:count"), oAccountList.count(), 1); // Modification account1 SKGBankObject tmpBank; SKGTESTERROR(QStringLiteral("ACCOUNT:getBank"), account3.getBank(tmpBank), true); SKGTESTBOOL("BANK:tmpBank==bank2", (tmpBank == bank2), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setBank"), account3.setBank(bank1), true); SKGTESTERROR(QStringLiteral("ACCOUNT:getBank"), account3.getBank(tmpBank), true); SKGTESTBOOL("BANK:tmpBank==bank2", (tmpBank == bank1), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account3.save(), true); SKGTESTERROR(QStringLiteral("BANK:getAccounts"), bank1.getAccounts(oAccountList), true); SKGTEST(QStringLiteral("ACCOUNT:count"), oAccountList.count(), 2); SKGTESTERROR(QStringLiteral("BANK:getAccounts"), bank2.getAccounts(oAccountList), true); SKGTEST(QStringLiteral("ACCOUNT:count"), oAccountList.count(), 0); SKGTESTBOOL("ACCOUNT:isBookmarked", account3.isBookmarked(), false); SKGTESTERROR(QStringLiteral("ACCOUNT:bookmark"), account3.bookmark(true), true); SKGTESTBOOL("ACCOUNT:isBookmarked", account3.isBookmarked(), true); SKGTESTBOOL("ACCOUNT:isClosed", account3.isClosed(), false); SKGTESTERROR(QStringLiteral("ACCOUNT:setClosed"), account3.setClosed(true), true); SKGTESTBOOL("ACCOUNT:isClosed", account3.isClosed(), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account3.save(), true); // Merge SKGTESTERROR(QStringLiteral("ACCOUNT:merge"), account2.merge(account3, true), true); // interest SKGObjectBase::SKGListSKGObjectBase oInterestList; SKGTESTERROR(QStringLiteral("ACCOUNT:getInterests"), account2.getInterests(oInterestList), true); SKGInterestObject oInterest; SKGTESTERROR(QStringLiteral("ACCOUNT:getInterests"), account2.getInterest(QDate::currentDate(), oInterest), false); SKGObjectBase account4(&document1, QStringLiteral("account"), account1.getID()); SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account4.load(), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setAttribute"), account4.setAttribute(QStringLiteral("t_BANK"), QStringLiteral("bankname")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account4.save(), true); SKGTESTERROR(QStringLiteral("BANK:load"), bank1.load(), true); SKGTEST(QStringLiteral("BANK:getName"), bank1.getName(), QStringLiteral("bankname")); SKGTESTERROR(QStringLiteral("DOC:dump"), document1.dump(DUMPACCOUNT), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestbankreport.cpp b/tests/skgbankmodelertest/skgtestbankreport.cpp index 2ee93ce94..62b9718f6 100644 --- a/tests/skgbankmodelertest/skgtestbankreport.cpp +++ b/tests/skgbankmodelertest/skgtestbankreport.cpp @@ -1,85 +1,85 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgreportbank.h" #include "skgtestmacro.h" /** * The main function of the bank report test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test unit et unitvalue SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % QStringLiteral("/advice.skg")), true); auto* rep = qobject_cast(document1.getReport()); rep->setPeriod(QStringLiteral("2013")); rep->get5MainCategoriesVariation(); rep->getAlarms(); rep->getInterests(); rep->getAccountTable(); rep->getBankTable(); rep->getBudgetTable(); rep->getIncomeVsExpenditure(); rep->getIncomeVsExpenditure(); rep->getMainCategoriesForPeriod(); rep->getMainCategoriesForPreviousPeriod(); rep->get5MainCategoriesVariationIssue(); rep->getPortfolio(); rep->getScheduledOperations(); rep->getUnitTable(); rep->getNetWorth(); rep->getAnnualSpending(); rep->getPersonalFinanceScore(); rep->getPrevious(); rep->getTipOfDay(); rep->getTipsOfDay(); rep->setTipsOfDay(QStringList() << QStringLiteral("Hello") << QStringLiteral("world")); rep->getTipOfDay(); rep->getTipsOfDay(); rep->setPointSize(10); SKGTEST(QStringLiteral("REP:getPointSize"), rep->getPointSize(), 10); QString html; SKGTESTERROR(QStringLiteral("SKGReportBank::getReportFromTemplate"), SKGReportBank::getReportFromTemplate(rep, SKGTest::getTestPath(QStringLiteral("IN")) % QStringLiteral("/template.txt"), html), true); delete rep; } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestbigdocument.cpp b/tests/skgbankmodelertest/skgtestbigdocument.cpp index 4bcb84feb..41ac98cfa 100644 --- a/tests/skgbankmodelertest/skgtestbigdocument.cpp +++ b/tests/skgbankmodelertest/skgtestbigdocument.cpp @@ -1,203 +1,203 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgtestmacro.h" #include "skgtraces.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QDate now = QDate::currentDate(); // ============================================================================ // Init QString filename = SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestbigdocument/skgtestbigdocument.skg"; { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGUnitValueObject unit_euro_val1; SKGBankObject bank(&document1); SKGAccountObject account; SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account.setNumber(QStringLiteral("12345P")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGUnitObject unit_euro(&document1); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(now), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation categories auto cats = new SKGCategoryObject[30]; for (int i = 0; i < 10; ++i) { cats[i] = SKGCategoryObject(&document1); SKGTESTERROR(QStringLiteral("CAT:setName"), cats[i].setName("cat_" % SKGServices::intToString(i)), true); SKGTESTERROR(QStringLiteral("CAT:save"), cats[i].save(), true); for (int j = 0; j < 2; ++j) { int indexSubCat = 10 * (j + 1) + i; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cats[i].addCategory(cats[indexSubCat]), true); SKGTESTERROR(QStringLiteral("CAT:setName"), cats[indexSubCat].setName("cat_" % SKGServices::intToString(i) % '_' % SKGServices::intToString(j)), true); SKGTESTERROR(QStringLiteral("CAT:save"), cats[indexSubCat].save(), true); } } // Creation payees auto payees = new SKGPayeeObject[10]; for (int i = 0; i < 10; ++i) { payees[i] = SKGPayeeObject(&document1); SKGTESTERROR(QStringLiteral("PAY:setName"), payees[i].setName("pay_" % SKGServices::intToString(i)), true); SKGTESTERROR(QStringLiteral("PAY:save"), payees[i].save(), true); } // Mode auto modes = new QString[5]; modes[0] = QStringLiteral("cheque"); modes[1] = QStringLiteral("carte"); modes[2] = QStringLiteral("tip"); modes[3] = QStringLiteral("virement"); modes[4] = QStringLiteral("espece"); // Comments auto comments = new QString[3]; comments[0] = QStringLiteral("bla bla"); comments[1] = QStringLiteral("hello world"); comments[2] = QStringLiteral("youpi"); // Creation operation SKGOperationObject mainOperation; for (int i = 1; i <= 365 * 10; ++i) { SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setNumber"), op_1.setNumber(SKGServices::intToString(1000 + i)), true); SKGTESTERROR(QStringLiteral("OPE:setMode"), op_1.setMode(modes[i % 5]), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), op_1.setComment(comments[i % 3]), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(now.addDays(-i)), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:setStatus"), op_1.setStatus((i < 20 ? SKGOperationObject::NONE : (i < 40 ? SKGOperationObject::POINTED : SKGOperationObject::CHECKED))), true); SKGTESTERROR(QStringLiteral("OPE:bookmark"), op_1.bookmark(i % 2 == 0), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); if (i == 1) { mainOperation = op_1; mainOperation.setGroupOperation(mainOperation); SKGTESTERROR(QStringLiteral("OPE:save"), mainOperation.save(), true); } else { if (!op_1.isBookmarked()) { op_1.setGroupOperation(mainOperation); } SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); } // Creation suboperation for (int j = 1; j <= 2; ++j) { SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setCategory"), subop_1.setCategory(cats[i % 30]), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(((i * j) % 60) - 10), true); SKGTESTERROR(QStringLiteral("SUBOPE:setOrder"), subop_1.setOrder(i), true); SKGTEST(QStringLiteral("SUBOPE:getOrder"), subop_1.getOrder(), i); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); } } cats[0].merge(cats[1]); payees[0].merge(payees[1]); // Delete delete [] cats; delete [] modes; delete [] comments; delete [] payees; } // A commit is done here because the scope is close SKGTESTERROR(QStringLiteral("ACCOUNT:getCurrentAmount"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 140165); QFile(filename).remove(); SKGTESTERROR(QStringLiteral("DOC:saveAs"), document1.saveAs(filename), true); } // ============================================================================ { SKGTraces::SKGPerfo = true; SKGTRACEIN(0, "openTest"); // Test bank document SKGDocumentBank document1; { SKGTRACEIN(0, "openTest-Load"); SKGTESTERROR(QStringLiteral("document1.load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestbigdocument/skgtestbigdocument.skg"), true); } { SKGTRACEIN(0, "openTest-Get"); SKGAccountObject account; SKGTESTERROR(QStringLiteral("SKGAccountObject::getObjectByName"), SKGAccountObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("Courant steph"), account), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 140165); SKGAccountObject::SKGListSKGObjectBase objects; SKGTESTERROR(QStringLiteral("SKGAccountObject::getObjects"), document1.getObjects(QStringLiteral("v_operation"), QLatin1String(""), objects), true); int nbobj = 0; SKGTESTERROR(QStringLiteral("SKGAccountObject::getNbObjects"), document1.getNbObjects(QStringLiteral("v_operation"), QLatin1String(""), nbobj), true); } { SKGTRACEIN(0, "openTest-Save"); SKGTESTERROR(QStringLiteral("document1.save"), document1.save(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestbudget.cpp b/tests/skgbankmodelertest/skgtestbudget.cpp index 488adab01..c62c62455 100644 --- a/tests/skgbankmodelertest/skgtestbudget.cpp +++ b/tests/skgbankmodelertest/skgtestbudget.cpp @@ -1,159 +1,159 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "skgtestbudget/budget.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BUDGET_CREATION"), err); SKGTESTERROR(QStringLiteral("BUDGET.createAutomaticBudget"), SKGBudgetObject::createAutomaticBudget(&document1, 2010, 2010, true, true), true); SKGTESTERROR(QStringLiteral("BUDGET.balanceBudget"), SKGBudgetObject::balanceBudget(&document1, 2010), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BUDGETRULE_CREATION"), err); SKGBudgetRuleObject br(&document1); SKGTESTERROR(QStringLiteral("BUDGETRULE.enableYearCondition"), br.enableYearCondition(true), true); SKGTESTBOOL("BUDGETRULE.isYearConditionEnabled", br.isYearConditionEnabled(), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.enableYearCondition"), br.enableYearCondition(false), true); SKGTESTBOOL("BUDGETRULE.isYearConditionEnabled", br.isYearConditionEnabled(), false); SKGTESTERROR(QStringLiteral("BUDGETRULE.setBudgetYear"), br.setBudgetYear(2010), true); SKGTEST(QStringLiteral("BUDGETRULE.getBudgetYear"), br.getBudgetYear(), 2010); SKGTESTERROR(QStringLiteral("BUDGETRULE.enableMonthCondition"), br.enableMonthCondition(true), true); SKGTESTBOOL("BUDGETRULE.isMonthConditionEnabled", br.isMonthConditionEnabled(), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.enableMonthCondition"), br.enableMonthCondition(false), true); SKGTESTBOOL("BUDGETRULE.isMonthConditionEnabled", br.isMonthConditionEnabled(), false); SKGTESTERROR(QStringLiteral("BUDGETRULE.setBudgetMonth"), br.setBudgetMonth(10), true); SKGTEST(QStringLiteral("BUDGETRULE.getBudgetMonth"), br.getBudgetMonth(), 10); SKGTESTERROR(QStringLiteral("BUDGETRULE.setOrder"), br.setOrder(1.0), true); SKGTEST(QStringLiteral("BUDGETRULE.getOrder"), br.getOrder(), 1.0); SKGTESTERROR(QStringLiteral("BUDGETRULE.setOrder"), br.setOrder(-1), true); SKGTEST(QStringLiteral("BUDGETRULE.getOrder"), br.getOrder(), 1.0); SKGTESTERROR(QStringLiteral("BUDGETRULE.enableCategoryCondition"), br.enableCategoryCondition(true), true); SKGTESTBOOL("BUDGETRULE.isCategoryConditionEnabled", br.isCategoryConditionEnabled(), true); SKGCategoryObject cat; SKGTESTERROR(QStringLiteral("BUDGETRULE.enableCategoryChange"), br.enableCategoryChange(br.isCategoryChangeEnabled()), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.getBudgetCategory"), br.getBudgetCategory(cat), false); SKGTESTERROR(QStringLiteral("BUDGETRULE.createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("category_55 > category_57"), cat), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.removeBudgetCategory"), br.removeBudgetCategory(), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.setBudgetCategory"), br.setBudgetCategory(cat), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.setCondition"), br.setCondition(SKGBudgetRuleObject::NEGATIVE), true); SKGTEST(QStringLiteral("BUDGETRULE.getCondition"), static_cast(br.getCondition()), static_cast(SKGBudgetRuleObject::NEGATIVE)); SKGTESTERROR(QStringLiteral("BUDGETRULE.setCondition"), br.setCondition(SKGBudgetRuleObject::POSITIVE), true); SKGTEST(QStringLiteral("BUDGETRULE.getCondition"), static_cast(br.getCondition()), static_cast(SKGBudgetRuleObject::POSITIVE)); SKGTESTERROR(QStringLiteral("BUDGETRULE.setCondition"), br.setCondition(SKGBudgetRuleObject::ALL), true); SKGTEST(QStringLiteral("BUDGETRULE.getCondition"), static_cast(br.getCondition()), static_cast(SKGBudgetRuleObject::ALL)); SKGTESTERROR(QStringLiteral("BUDGETRULE.setQuantity"), br.setQuantity(100, false), true); SKGTEST(QStringLiteral("BUDGETRULE.getQuantity"), br.getQuantity(), 100); SKGTESTBOOL("BUDGETRULE.isAbolute", br.isAbolute(), false); SKGTESTERROR(QStringLiteral("BUDGETRULE.setTransfer"), br.setTransfer(SKGBudgetRuleObject::CURRENT), true); SKGTEST(QStringLiteral("BUDGETRULE.getTransferMode"), static_cast(br.getTransferMode()), static_cast(SKGBudgetRuleObject::CURRENT)); SKGTESTERROR(QStringLiteral("BUDGETRULE.setTransfer"), br.setTransfer(SKGBudgetRuleObject::NEXT), true); SKGTEST(QStringLiteral("BUDGETRULE.getTransferMode"), static_cast(br.getTransferMode()), static_cast(SKGBudgetRuleObject::NEXT)); SKGTESTERROR(QStringLiteral("BUDGETRULE.save"), br.save(), true); SKGBudgetRuleObject br2 = br; SKGBudgetRuleObject br3(br); SKGBudgetRuleObject br4(static_cast(br)); SKGBudgetRuleObject br5(SKGObjectBase(&document1, QStringLiteral("xxx"), br.getID())); SKGTESTERROR(QStringLiteral("BUDGETRULE.processAllRules"), SKGBudgetRuleObject::processAllRules(&document1), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.setTransfer"), br.setTransfer(SKGBudgetRuleObject::YEAR), true); SKGTEST(QStringLiteral("BUDGETRULE.getTransferMode"), static_cast(br.getTransferMode()), static_cast(SKGBudgetRuleObject::YEAR)); SKGTESTERROR(QStringLiteral("BUDGETRULE.save"), br.save(), true); SKGTESTERROR(QStringLiteral("BUDGETRULE.processAllRules"), SKGBudgetRuleObject::processAllRules(&document1), true); } SKGTESTERROR(QStringLiteral("document1.saveAs()"), document1.saveAs(SKGTest::getTestPath(QStringLiteral("OUT")) % "skgtestbudget/budget.skg", true), true); } // ============================================================================ { // Import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "skgtestbudget/320323.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BUDGET_PROCESS"), err); SKGTESTERROR(QStringLiteral("BUDGETRULE.processAllRules"), SKGBudgetRuleObject::processAllRules(&document1), true); } document1.dump(DUMPBUDGET); bool check = false; document1.existObjects(QStringLiteral("v_budget_display"), QStringLiteral("t_PERIOD='2013-02' AND t_CATEGORY='Alimentation' AND f_budgeted_modified=300"), check); SKGTESTBOOL("BUDGETRULE.Alimentation 2013-02 300", check, true); document1.existObjects(QStringLiteral("v_budget_display"), QStringLiteral("t_PERIOD='2013-02' AND t_CATEGORY='Loisirs' AND f_budgeted_modified=2100"), check); SKGTESTBOOL("BUDGETRULE.Loisirs 2013-02 2100", check, true); SKGObjectBase bo; SKGTESTERROR(QStringLiteral("document1.getObject()"), document1.getObject(QStringLiteral("v_budget_display"), QStringLiteral("t_PERIOD='2013-02' AND t_CATEGORY='Loisirs' AND f_budgeted_modified=2100"), bo), true); SKGBudgetObject b(bo); SKGTEST(QStringLiteral("BUDGET.getBudgetedAmount"), b.getBudgetedAmount(), 300); SKGCategoryObject cat; SKGTESTERROR(QStringLiteral("BUDGET.getCategory"), b.getCategory(cat), true); SKGTEST(QStringLiteral("BUDGET.getModificationReasons"), b.getModificationReasons(), QStringLiteral("Transfer of -1800 from ' 2013-01 2000.0' to 'Loisirs 2013-02 300.0' due to the rule 'All 100.0% Next Loisirs'")); SKGTESTERROR(QStringLiteral("BUDGET.removeCategory"), b.removeCategory(), true); SKGTESTERROR(QStringLiteral("BUDGET.enableSubCategoriesInclusion"), b.enableSubCategoriesInclusion(true), true); SKGTESTBOOL(QStringLiteral("BUDGET.isSubCategoriesInclusionEnabled"), b.isSubCategoriesInclusionEnabled(), true); SKGTESTERROR(QStringLiteral("BUDGET.enableSubCategoriesInclusion"), b.enableSubCategoriesInclusion(false), true); SKGTESTBOOL(QStringLiteral("BUDGET.isSubCategoriesInclusionEnabled"), b.isSubCategoriesInclusionEnabled(), false); SKGBudgetObject bu; } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestcategory.cpp b/tests/skgbankmodelertest/skgtestcategory.cpp index 42439f750..a7f8f2ab1 100644 --- a/tests/skgbankmodelertest/skgtestcategory.cpp +++ b/tests/skgbankmodelertest/skgtestcategory.cpp @@ -1,287 +1,287 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test category SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGCategoryObject parent2; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("CAT_T1"), err); // Create category 0 SKGCategoryObject cat0(&document1); SKGTESTERROR(QStringLiteral("CAT:setName+invalid name"), cat0.setName('a' % OBJECTSEPARATOR % 'b'), false); SKGTESTBOOL("CAT:exist", cat0.exist(), false); SKGTESTERROR(QStringLiteral("CAT:save"), cat0.save(), false); // Create category 1 SKGCategoryObject cat1(&document1); SKGCategoryObject cat1_1; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat1.addCategory(cat1_1), false); SKGTESTERROR(QStringLiteral("CAT:setParentCategory"), cat1.setParentCategory(cat1_1), false); SKGTESTERROR(QStringLiteral("CAT:setName"), cat1.setName(QStringLiteral("root1")), true); SKGTESTBOOL("CAT:getFullName", cat1.isBookmarked(), false); SKGTESTERROR(QStringLiteral("CAT:bookmark"), cat1.bookmark(true), true); SKGTESTBOOL("CAT:getFullName", cat1.isBookmarked(), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1.getFullName(), QStringLiteral("root1")); SKGTESTERROR(QStringLiteral("CAT:load"), cat1.load(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1.getFullName(), QStringLiteral("root1")); SKGTESTBOOL("REF:isClosed", cat1.isClosed(), false); SKGTESTERROR(QStringLiteral("REF:setClosed"), cat1.setClosed(true), true); SKGTESTBOOL("REF:isClosed", cat1.isClosed(), true); SKGObjectBase obj1 = static_cast(cat1); SKGCategoryObject cat11(obj1); // Update with bad name SKGTESTERROR(QStringLiteral("CAT:setName"), cat1.setName("root1" % OBJECTSEPARATOR % 'A'), false); SKGTESTERROR(QStringLiteral("CAT:load"), cat1.load(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1.getFullName(), QStringLiteral("root1")); // Create category 1.1 SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat1.addCategory(cat1_1), true); SKGTESTERROR(QStringLiteral("CAT:setName"), cat1_1.setName(QStringLiteral("cat1")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat1_1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1_1.getFullName(), "root1" % OBJECTSEPARATOR % "cat1"); // Update cat1_1 SKGTESTERROR(QStringLiteral("CAT:setName"), cat1_1.setName(QStringLiteral("CAT1")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat1_1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1_1.getFullName(), "root1" % OBJECTSEPARATOR % "CAT1"); // Update cat1 SKGTESTERROR(QStringLiteral("CAT:setName"), cat1.setName(QStringLiteral("ROOT1")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1.getFullName(), QStringLiteral("ROOT1")); SKGTESTERROR(QStringLiteral("CAT:load"), cat1_1.load(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1_1.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT1"); // Create category 1.2 SKGCategoryObject cat1_2; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat1.addCategory(cat1_2), true); SKGTESTERROR(QStringLiteral("CAT:setName"), cat1_2.setName(QStringLiteral("CAT2")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat1_2.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), cat1_2.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT2"); // Create category end SKGCategoryObject end1; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat1_1.addCategory(end1), true); SKGTESTERROR(QStringLiteral("CAT:setName"), end1.setName(QStringLiteral("END")), true); SKGTESTERROR(QStringLiteral("CAT:save"), end1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), end1.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT1" % OBJECTSEPARATOR % "END"); // Create category end SKGCategoryObject end2; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat1_2.addCategory(end2), true); SKGTESTERROR(QStringLiteral("CAT:setName"), end2.setName(QStringLiteral("END")), true); SKGTESTERROR(QStringLiteral("CAT:save"), end2.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), end2.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT2" % OBJECTSEPARATOR % "END"); SKGCategoryObject end2_1; SKGTESTERROR(QStringLiteral("CAT:addCategory"), end2.addCategory(end2_1), true); SKGTESTERROR(QStringLiteral("CAT:setName"), end2_1.setName(QStringLiteral("REALEND")), true); SKGTESTERROR(QStringLiteral("CAT:save"), end2_1.save(), true); SKGTEST(QStringLiteral("CAT:getFullName"), end2_1.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT2" % OBJECTSEPARATOR % "END" % OBJECTSEPARATOR % "REALEND"); // Get parent SKGCategoryObject parent1; SKGTESTERROR(QStringLiteral("CAT:getParentCategory"), end2.getParentCategory(parent1), true); SKGTEST(QStringLiteral("CAT:getFullName"), parent1.getFullName(), "ROOT1" % OBJECTSEPARATOR % "CAT2"); // Get parent SKGTESTERROR(QStringLiteral("CAT:getParentCategory"), parent1.getParentCategory(parent2), true); SKGTEST(QStringLiteral("CAT:getFullName"), parent2.getFullName(), QStringLiteral("ROOT1")); SKGCategoryObject root; SKGTESTERROR(QStringLiteral("CAT:getRootCategory"), end2_1.getRootCategory(root), true); SKGTEST(QStringLiteral("CAT:getFullName"), root.getFullName(), QStringLiteral("ROOT1")); // Get children SKGObjectBase::SKGListSKGObjectBase CategoryList; SKGTESTERROR(QStringLiteral("CAT:getCategories"), parent2.getCategories(CategoryList), true); SKGTEST(QStringLiteral("CAT:nb categories"), CategoryList.size(), 2); // Simple delete SKGTESTERROR(QStringLiteral("CAT:delete"), end1.remove(), true); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 5); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("CAT_T2"), err); // Cascading delete SKGTESTERROR(QStringLiteral("CAT:delete"), parent2.remove(), true); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 0); } // Undo SKGTESTERROR(QStringLiteral("CAT:undoRedoTransaction"), document1.undoRedoTransaction(), true); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 5); SKGTESTERROR(QStringLiteral("CAT:undoRedoTransaction"), document1.undoRedoTransaction(), true); SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 0); // Redo SKGTESTERROR(QStringLiteral("CAT:undoRedoTransaction(SKGDocument::REDO)"), document1.undoRedoTransaction(SKGDocument::REDO), true); SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 5); SKGTESTERROR(QStringLiteral("CAT:undoRedoTransaction(SKGDocument::REDO)"), document1.undoRedoTransaction(SKGDocument::REDO), true); SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 0); } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("CAT_T1"), err); SKGCategoryObject cat; SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QLatin1String(""), cat), true); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'A', cat, true), true); SKGTEST(QStringLiteral("CAT:getName"), cat.getName(), QStringLiteral("A")); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 2); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'B', cat, true, true), true); SKGTEST(QStringLiteral("CAT:getName"), cat.getName(), QStringLiteral("B")); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'B', cat, true, true), true); SKGTEST(QStringLiteral("CAT:getName"), cat.getName(), QStringLiteral("B (2)")); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("C"), cat, true, true), true); SKGTEST(QStringLiteral("CAT:getName"), cat.getName(), QStringLiteral("C")); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("C"), cat, true, true), true); SKGTEST(QStringLiteral("CAT:getName"), cat.getName(), QStringLiteral("C (2)")); } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("NODE_T1"), err); SKGCategoryObject categoryB; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'B', categoryB), true); SKGCategoryObject categoryC; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("C"), categoryC), true); SKGCategoryObject categoryA; SKGTESTERROR(QStringLiteral("NOD:getParentCategory"), categoryB.getParentCategory(categoryA), true); SKGTESTERROR(QStringLiteral("NOD:setParentCategory"), categoryA.setParentCategory(categoryB), false); SKGTESTERROR(QStringLiteral("NOD:setParentCategory"), categoryA.setParentCategory(categoryA), false); SKGTESTERROR(QStringLiteral("NOD:setParentCategory"), categoryB.setParentCategory(categoryB), false); SKGTESTERROR(QStringLiteral("NOD:setParentCategory"), categoryC.setParentCategory(categoryB), true); SKGTESTERROR(QStringLiteral("NOD:removeParentCategory"), categoryB.removeParentCategory(), true); } } // Bug 245254 { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("NODE_T1"), err); SKGCategoryObject categoryB; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'B', categoryB), true); SKGCategoryObject categoryC; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("C"), categoryC), true); SKGCategoryObject categoryA; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'C' % OBJECTSEPARATOR % 'A', categoryA), true); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 4); // Merge SKGTESTERROR(QStringLiteral("CAT:merge"), categoryB.merge(categoryA), true); } } // Cascading delete { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("NODE_T1"), err); SKGCategoryObject categoryA; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("A"), categoryA), true); SKGCategoryObject categoryC; SKGTESTERROR(QStringLiteral("NOD:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, 'A' % OBJECTSEPARATOR % 'B' % OBJECTSEPARATOR % 'C', categoryC), true); QStringList oResult; SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 3); // Delete SKGTESTERROR(QStringLiteral("CAT:remove"), categoryA.remove(), true); SKGTESTERROR(QStringLiteral("CAT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("category"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("CAT:oResult.size"), oResult.size(), 0); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestdocparameter.cpp b/tests/skgbankmodelertest/skgtestdocparameter.cpp index b24491e41..3527cfc71 100644 --- a/tests/skgbankmodelertest/skgtestdocparameter.cpp +++ b/tests/skgbankmodelertest/skgtestdocparameter.cpp @@ -1,126 +1,126 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // test class SKGDocument / PARAMETERS { SKGDocument document1; SKGTESTERROR(QStringLiteral("PARAM:initialize"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("PARAM:beginTransaction"), document1.beginTransaction(QStringLiteral("t1")), true); SKGTESTERROR(QStringLiteral("PARAM:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL1")), true); SKGTEST(QStringLiteral("PARAM:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1")); SKGTESTERROR(QStringLiteral("PARAM:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL1UPDATED")), true); SKGTEST(QStringLiteral("PARAM:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1UPDATED")); SKGTESTERROR(QStringLiteral("PARAM:setParameter"), document1.setParameter(QStringLiteral("ATT2"), QStringLiteral("VAL2")), true); SKGTEST(QStringLiteral("PARAM:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1UPDATED")); SKGTEST(QStringLiteral("PARAM:getParameter"), document1.getParameter(QStringLiteral("ATT2")), QStringLiteral("VAL2")); SKGTEST(QStringLiteral("PARAM:getParameter"), document1.getParameter(QStringLiteral("NOTFOUND")), QLatin1String("")); SKGTESTERROR(QStringLiteral("PARAM:setParameter+sql injection"), document1.setParameter(QStringLiteral("'"), QStringLiteral("VAL3")), true); SKGTEST(QStringLiteral("PARAM:getParameter+sql injection"), document1.getParameter(QStringLiteral("'")), QStringLiteral("VAL3")); SKGTESTERROR(QStringLiteral("PARAM:endTransaction"), document1.endTransaction(true), true); } // Test parameters on object { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("PROP:initialize"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("PROP:beginTransaction"), document1.beginTransaction(QStringLiteral("t1")), true); SKGTESTERROR(QStringLiteral("PROP:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL1")), true); SKGObjectBase obj1(&document1, QStringLiteral("bank")); SKGTESTERROR(QStringLiteral("PROP:setAttribute"), obj1.setAttribute(QStringLiteral("t_name"), QStringLiteral("CL")), true); SKGTESTERROR(QStringLiteral("PROP:Replace"), obj1.save(), true); SKGTESTERROR(QStringLiteral("PROP:setProperty"), obj1.setProperty(QStringLiteral("ATT1"), QStringLiteral("VAL2"), QVariant(145)), true); // Check SKGTEST(QStringLiteral("PROP:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1")); SKGTEST(QStringLiteral("PROP:getProperty"), obj1.getProperty(QStringLiteral("ATT1")), QStringLiteral("VAL2")); SKGTEST(QStringLiteral("PROP:getProperty"), obj1.getPropertyBlob(QStringLiteral("ATT1")).toInt(), 145); QStringList oResult; SKGTESTERROR(QStringLiteral("PROP:getDistinctValues"), document1.getDistinctValues(QStringLiteral("parameters"), QStringLiteral("t_value"), QStringLiteral("t_value like 'VAL%'"), oResult), true); SKGTEST(QStringLiteral("PROP:oResult.size"), oResult.size(), 2); // delete cascade SKGTESTERROR(QStringLiteral("PROP:Replace"), obj1.remove(), true); SKGTESTERROR(QStringLiteral("PROP:getDistinctValues"), document1.getDistinctValues(QStringLiteral("parameters"), QStringLiteral("t_value"), QStringLiteral("t_value like 'VAL%'"), oResult), true); SKGTEST(QStringLiteral("PROP:oResult.size"), oResult.size(), 1); SKGTESTERROR(QStringLiteral("PROP:setProperty"), obj1.setProperty(QStringLiteral("ATT4"), QStringLiteral("VAL4"), SKGTest::getTestPath(QStringLiteral("IN")) % "/dates.txt"), true); SKGTESTERROR(QStringLiteral("PROP:setProperty"), obj1.setProperty(QStringLiteral("ATT5"), QStringLiteral("VAL5"), SKGTest::getTestPath(QStringLiteral("IN"))), true); { // Scope of the transaction SKGError err; SKGBEGINTRANSACTION(document1, QStringLiteral("T1"), err); SKGPropertyObject propAdded1; SKGTESTERROR(QStringLiteral("PROP.setProperty"), obj1.setProperty(QStringLiteral("normal"), QStringLiteral("value"), QVariant(), &propAdded1), true); SKGTEST(QStringLiteral("PROP.getUrl"), propAdded1.getUrl().toDisplayString(), QLatin1String("")); SKGPropertyObject propAdded2; SKGTESTERROR(QStringLiteral("PROP.setProperty"), obj1.setProperty(QStringLiteral("url"), QStringLiteral("https://skrooge.org/"), QVariant(), &propAdded2), true); SKGTEST(QStringLiteral("PROP.getUrl"), propAdded2.getUrl().toDisplayString(), QStringLiteral("https://skrooge.org/")); SKGPropertyObject propAdded3; SKGTESTERROR(QStringLiteral("PROP.setProperty"), obj1.setProperty(QStringLiteral("file copied"), SKGTest::getTestPath(QStringLiteral("IN")) % "dates.txt", QVariant(), &propAdded3), true); SKGTEST(QStringLiteral("PROP.getUrl"), propAdded3.getUrl().toDisplayString(), "file://" % SKGTest::getTestPath(QStringLiteral("IN")) % "dates.txt"); SKGPropertyObject propAdded4; SKGTESTERROR(QStringLiteral("PROP.setProperty"), obj1.setProperty(QStringLiteral("file moved"), QStringLiteral("test.txt"), QVariant("ABC"), &propAdded4), true); SKGTESTBOOL("PROP.getUrl", propAdded4.getUrl().toDisplayString().startsWith(QLatin1String("file://")), true); SKGTESTBOOL("PROP.getUrl", propAdded4.getUrl().toDisplayString().endsWith(QLatin1String("test.txt")), true); SKGTESTBOOL("PROP.getUrl", propAdded4.getUrl(true).toDisplayString().startsWith(QLatin1String("file://")), true); SKGTESTBOOL("PROP.getUrl", propAdded4.getUrl(true).toDisplayString().endsWith(QLatin1String("test.txt")), true); } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("DOC:initialize"), document1.initialize(), true); QStringList listTables; SKGTESTERROR(QStringLiteral("DOC::getTablesList"), document1.getTablesList(listTables), true); for (const auto& table : qAsConst(listTables)) { document1.getDisplaySchemas(table); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportafb120.cpp b/tests/skgbankmodelertest/skgtestimportafb120.cpp index 6f61064bf..00a11cd1b 100644 --- a/tests/skgbankmodelertest/skgtestimportafb120.cpp +++ b/tests/skgbankmodelertest/skgtestimportafb120.cpp @@ -1,106 +1,106 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import AFB120 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTERROR(QStringLiteral("DOC:changePassword"), document1.changePassword(QStringLiteral("test")), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_AFB120"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.cfo"))); SKGTESTERROR(QStringLiteral("AFB120.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportafb120/gs_01139_021239S.cfo")); SKGTESTERROR(QStringLiteral("AFB120.importFile"), imp1.importFile(), true); document1.dump(DUMPOPERATION | DUMPACCOUNT); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("AFB120.setName"), account.setName(QStringLiteral("0000021239S")), true); SKGTESTERROR(QStringLiteral("AFB120.load"), account.load(), true); SKGTEST(QStringLiteral("AFB120:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("2555.48")); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_AFB120"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportafb120/gs_01139_021239S.cfo")); SKGTESTERROR(QStringLiteral("AFB120.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("AFB120.setName"), account.setName(QStringLiteral("0000021239S")), true); SKGTESTERROR(QStringLiteral("AFB120.load"), account.load(), true); SKGTEST(QStringLiteral("AFB120:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("2555.48")); } QString fano; { QString f = SKGTest::getTestPath(QStringLiteral("OUT")) % QStringLiteral("/skgtestimportafb120/anonymize.skg"); QFile(f).remove(); SKGImportExportManager imp1(&document1); SKGTESTERROR(QStringLiteral("AFB120:anonymize"), imp1.anonymize(QLatin1String("")), false); SKGTESTERROR(QStringLiteral("AFB120.saveAs"), document1.saveAs(f), true); SKGTESTERROR(QStringLiteral("AFB120:anonymize"), imp1.anonymize(QLatin1String("")), true); fano = document1.getCurrentFileName(); SKGTEST(QStringLiteral("AFB120:getCurrentFileName"), static_cast(fano != f), static_cast(true)); document1.close(); } { // Load anonymized file SKGDocumentBank document2; SKGTESTERROR(QStringLiteral("DOC:load"), document2.load(fano), true); SKGImportExportManager imp1(&document2); SKGTESTERROR(QStringLiteral("AFB120:anonymize"), imp1.anonymize(QStringLiteral("KEY")), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportcsvrule.cpp b/tests/skgbankmodelertest/skgtestimportcsvrule.cpp index c295d8317..9d835877b 100644 --- a/tests/skgbankmodelertest/skgtestimportcsvrule.cpp +++ b/tests/skgbankmodelertest/skgtestimportcsvrule.cpp @@ -1,69 +1,69 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the import rule test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) SKGError err; { // Test import SKGImportExportManager::CSV skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvrule/notfound.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_rule")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), false); // FILE NOT FOUND } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvrule/test1.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_rule")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } int nb = 0; SKGTESTERROR(QStringLiteral("imp1.getNbObjects"), document1.getNbObjects(QStringLiteral("rule"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("imp1.nb"), nb, 3); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportcsvunit.cpp b/tests/skgbankmodelertest/skgtestimportcsvunit.cpp index f08e09727..3ec432101 100644 --- a/tests/skgbankmodelertest/skgtestimportcsvunit.cpp +++ b/tests/skgbankmodelertest/skgtestimportcsvunit.cpp @@ -1,105 +1,105 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) SKGError err; { // Test import SKGImportExportManager::CSV skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvunit/notfound.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_unit")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), false); // FILE NOT FOUND } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvunit/test.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_unit")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvunit/test2.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_unit")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } document1.dump(DUMPUNIT); { SKGUnitObject unit(&document1); SKGTESTERROR(QStringLiteral("UNIT.setName"), unit.setName(QStringLiteral("test")), true); SKGTESTERROR(QStringLiteral("UNIT.load"), unit.load(), true); SKGUnitValueObject UnitValue; SKGTESTERROR(QStringLiteral("UNIT.getLastUnitValue"), unit.getLastUnitValue(UnitValue), true); SKGTEST(QStringLiteral("UNIT:getQuantity"), SKGServices::doubleToString(UnitValue.getQuantity()), QStringLiteral("50")); } { SKGUnitObject unit(&document1); SKGTESTERROR(QStringLiteral("UNIT.setName"), unit.setName(QStringLiteral("test2")), true); SKGTESTERROR(QStringLiteral("UNIT.load"), unit.load(), true); SKGUnitValueObject UnitValue; SKGTESTERROR(QStringLiteral("UNIT.getLastUnitValue"), unit.getLastUnitValue(UnitValue), true); SKGTEST(QStringLiteral("UNIT:getQuantity"), SKGServices::doubleToString(UnitValue.getQuantity()), QStringLiteral("25.16")); } } { // Test import SKGImportExportManager::CSV skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportcsvunit/coma.csv")); QMap parameters = imp1.getImportParameters(); parameters[QStringLiteral("mode_csv_unit")] = 'Y'; imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportgnucash.cpp b/tests/skgbankmodelertest/skgtestimportgnucash.cpp index 285555b6b..a11d6399d 100644 --- a/tests/skgbankmodelertest/skgtestimportgnucash.cpp +++ b/tests/skgbankmodelertest/skgtestimportgnucash.cpp @@ -1,594 +1,594 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("/not-existing/missingfile.uncompressed"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/test_data.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Accounts Receivable")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("231.11")); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/all.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("COMPTE COURANT")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-700")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("COMPTE EPARGNE")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("250")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Actif")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-420")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("TITRE")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("520")); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/initial_balance.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100")); } int nb = 0; SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects(unit, PRIMARY)"), document1.getNbObjects(QStringLiteral("unit"), QStringLiteral("t_type='1'"), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects(unit, PRIMARY)"), nb, 1); SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects(unit, SHARE)"), document1.getNbObjects(QStringLiteral("unit"), QStringLiteral("t_type='S'"), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects(unit, SHARE)"), nb, 13); } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/transfer-CPP-vers-PEE.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("750")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CEL Donald")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("150")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("PEEs")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("190")); } { int nb = 0; SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects"), document1.getNbObjects(QStringLiteral("category"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects"), nb, 27); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/transfer-PEE-vers-CCP.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1140")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CEL Donald")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("150")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("PEEs")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100")); } { SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGCategoryObject cat; SKGTESTERROR(QStringLiteral("GNUCASH.createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("Depenses > Frais bancaires"), cat), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(cat.getCurrentAmount()), QStringLiteral("-10")); } SKGTESTERROR(QStringLiteral("DOC:dump"), document1.dump(DUMPCATEGORY), true); } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/interet-revenue-frais.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("750")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CEL Donald")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("150")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("PEEs")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("640")); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/interet-revenue-frais-emprunt.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("250")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Emprunts")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-99620")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Maison")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100000")); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/rapprochement-incorrect.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { int nb = 0; SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QStringLiteral("t_status='Y'"), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects"), nb, 7); } } { // Test import GNUCASH SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/scheduled-action.uncompressed")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGObjectBase::SKGListSKGObjectBase recurrentoperations; SKGTESTERROR(QStringLiteral("GNUCASH:SKGListSKGObjectBase"), document1.getObjects(QStringLiteral("recurrentoperation"), QLatin1String(""), recurrentoperations), true); SKGTEST(QStringLiteral("GNUCASH:nb"), recurrentoperations.count(), 1); if (recurrentoperations.count() == 1) { SKGRecurrentOperationObject recu(recurrentoperations.at(0)); SKGTEST(QStringLiteral("GNUCASH:getDate"), recu.getDate().toString(), QDate(2010, 03, 02).toString()); SKGTEST(QStringLiteral("GNUCASH:getAutoWriteDays"), recu.getAutoWriteDays(), 10); SKGTEST(QStringLiteral("GNUCASH:getPeriodIncrement"), recu.getPeriodIncrement(), 1); SKGTEST(QStringLiteral("GNUCASH:getPeriodUnit"), static_cast(recu.getPeriodUnit()), static_cast(SKGRecurrentOperationObject::MONTH)); SKGTEST(QStringLiteral("GNUCASH:getWarnDays"), recu.getWarnDays(), 0); SKGTESTBOOL("GNUCASH:isAutoWriteEnabled", recu.isAutoWriteEnabled(), false); SKGTESTBOOL("GNUCASH:isWarnEnabled", recu.isWarnEnabled(), false); SKGTESTBOOL("GNUCASH:hasTimeLimit", recu.hasTimeLimit(), false); } } } { // Test import GNUCASH - bug 228808 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/228808.gnc")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGObjectBase::SKGListSKGObjectBase recurrentoperations; SKGTESTERROR(QStringLiteral("GNUCASH:SKGListSKGObjectBase"), document1.getObjects(QStringLiteral("recurrentoperation"), QStringLiteral("1=1 ORDER BY d_date"), recurrentoperations), true); SKGTEST(QStringLiteral("GNUCASH:nb"), recurrentoperations.count(), 2); if (recurrentoperations.count() == 2) { SKGRecurrentOperationObject recu(recurrentoperations.at(0)); SKGOperationObject op; SKGTESTERROR(QStringLiteral("GNUCASH:getParentOperation"), recu.getParentOperation(op), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), op.getCurrentAmount(), -50); recu = recurrentoperations.at(1); SKGTESTERROR(QStringLiteral("GNUCASH:getParentOperation"), recu.getParentOperation(op), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), op.getCurrentAmount(), -18.75); } } } { // Test import GNUCASH - bug 228904 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/228904.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGObjectBase::SKGListSKGObjectBase recurrentoperations; SKGTESTERROR(QStringLiteral("GNUCASH:SKGListSKGObjectBase"), document1.getObjects(QStringLiteral("recurrentoperation"), QStringLiteral("1=1 ORDER BY d_date"), recurrentoperations), true); SKGTEST(QStringLiteral("GNUCASH:nb"), recurrentoperations.count(), 3); } } { // Test import 228901 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/228901.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Compte emprunt")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-9476.01")); } // Test second import { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/228901.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } } { // Test import 234608 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/234608.gnc")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } } { // Test import 234597 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/234597.gnc")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { int nb = 0; SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects"), document1.getNbObjects(QStringLiteral("account"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects"), nb, 11); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Compte cheques")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-260")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Compte cheques (2)")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-40")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Argent du porte-monnaie")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("0")); } } { // Test import 243738 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/243738.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } } { // Test import without book SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/without_book.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } } { // Test import 302388 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/302388.gnc")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), false); } } { // Test import 325174 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/325174.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } int nb = 0; SKGTESTERROR(QStringLiteral("GNUCASH:getNbObjects(account)"), document1.getNbObjects(QStringLiteral("account"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("GNUCASH:getNbObjects(account)"), nb, 11); } { // Test import wallet SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/wallet.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Espece")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("GNUCASH:getName"), bank.getName(), QLatin1String("")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Courant")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("GNUCASH:getName"), bank.getName(), QStringLiteral("GNUCASH")); } } { // 407257 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GNUCASH"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgnucash/407257.gnucash")); SKGTESTERROR(QStringLiteral("GNUCASH.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("AccountName (Nom de compte)")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); SKGTEST(QStringLiteral("GNUCASH:getNumber"), account.getNumber(), QStringLiteral("123_AccountCode(CodeCompte)")); SKGTEST(QStringLiteral("GNUCASH:getComment"), account.getComment(), QStringLiteral("DescriptionAccount(Compte123)")); SKGUnitObject unit; SKGTESTERROR(QStringLiteral("GNUCASH.getUnit"), account.getUnit(unit), true); SKGTEST(QStringLiteral("GNUCASH:getName"), unit.getName(), QStringLiteral("Canadian Dollar (CAD)")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GNUCASH.setName"), account.setName(QStringLiteral("Account2Name(no transaction)")), true); SKGTESTERROR(QStringLiteral("GNUCASH.load"), account.load(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportgsb.cpp b/tests/skgbankmodelertest/skgtestimportgsb.cpp index 272235abd..15d77d136 100644 --- a/tests/skgbankmodelertest/skgtestimportgsb.cpp +++ b/tests/skgbankmodelertest/skgtestimportgsb.cpp @@ -1,176 +1,176 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgimportexportmanager.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import GSK SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.gsb"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/test-obfuscated.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Account 0")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1029")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Account 4")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("7.5")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Account 1")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("757.5")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Account 3")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("43.5")); } } { // Test import GSK SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/version_0.5.9.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), false); } } { // Double import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/essai.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/essai.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), true); } } { // Split SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/split.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Compte banque A")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("350")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("GSB.setName"), account.setName(QStringLiteral("Compte banque B")), true); SKGTESTERROR(QStringLiteral("GSB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-9400")); } } { // Budget SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_GSB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportgsb/imputations_budgetaires.gsb")); SKGTESTERROR(QStringLiteral("GSB.importFile"), imp1.importFile(), true); } { SKGObjectBase::SKGListSKGObjectBase operations; SKGTESTERROR(QStringLiteral("GSB.getObjects"), document1.getObjects(QStringLiteral("v_operation_display"), QStringLiteral("d_date='2013-08-11'"), operations), true); SKGTEST(QStringLiteral("GSB:count"), operations.count(), 1); SKGOperationObject op(operations[0]); SKGTEST(QStringLiteral("GSB:Budgetary allocation"), op.getProperty(i18nc("Noun", "Budgetary allocation")), QStringLiteral("imputation1")); SKGTEST(QStringLiteral("GSB:Fiscal year"), op.getProperty(i18nc("Noun", "Fiscal year")), QStringLiteral("2013")); SKGTEST(QStringLiteral("GSB:category"), op.getAttribute(QStringLiteral("t_CATEGORY")), QStringLiteral("categorie1")); } { SKGObjectBase::SKGListSKGObjectBase operations; SKGTESTERROR(QStringLiteral("GSB.getObjects"), document1.getObjects(QStringLiteral("v_operation_display"), QStringLiteral("d_date='2013-08-12'"), operations), true); SKGTEST(QStringLiteral("GSB:count"), operations.count(), 1); SKGOperationObject op(operations[0]); SKGTEST(QStringLiteral("GSB:Budgetary allocation"), op.getProperty(i18nc("Noun", "Budgetary allocation")), "imputation1" % OBJECTSEPARATOR % "subimputation1"); SKGTEST(QStringLiteral("GSB:Fiscal year"), op.getProperty(i18nc("Noun", "Fiscal year")), QStringLiteral("2013")); SKGTEST(QStringLiteral("GSB:category"), op.getAttribute(QStringLiteral("t_CATEGORY")), "categorie1" % OBJECTSEPARATOR % "subcategorie1"); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportiif.cpp b/tests/skgbankmodelertest/skgtestimportiif.cpp index 3ce14e3cc..5237914f0 100644 --- a/tests/skgbankmodelertest/skgtestimportiif.cpp +++ b/tests/skgbankmodelertest/skgtestimportiif.cpp @@ -1,235 +1,235 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import full_check.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_check.iif")); imp1.setCodec(QStringLiteral("UTF-8")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Checking")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-36.15")); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportiif/full_check.iif")); imp1.setCodec(QStringLiteral("UTF-8")); SKGTESTERROR(QStringLiteral("IIF.exportFile"), imp1.exportFile(), true); } } { // Test import full_deposit.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_deposit.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Checking")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("10000")); } } { // Test import full_bill.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_bill.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Accounts Payable")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-59.25")); } } { // Test import full_cash_sale.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_cash_sale.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Undeposited Funds")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1969.98")); } } { // Test import full_transfer.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_transfer.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Checking")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-500")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Savings")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("500")); } } { // Test import full_bill_payment.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_bill_payment.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Checking")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-35")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Accounts Payable")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("35")); } } { // Test import full_customer_payment.iif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_IIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportiif/full_customer_payment.iif")); SKGTESTERROR(QStringLiteral("IIF.importFile"), imp1.importFile(), true); } SKGAccountObject la; { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Undeposited Funds")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("53.5")); la = account; } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("IIF.setName"), account.setName(QStringLiteral("Accounts Receivable")), true); SKGTESTERROR(QStringLiteral("IIF.load"), account.load(), true); SKGTEST(QStringLiteral("IIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-53.5")); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_IIF"), err); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportiif/export_all.iif")); SKGTESTERROR(QStringLiteral("IIF.exportFile"), exp1.exportFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_IIF"), err); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportiif/export_la.iif")); QMap params; params[QStringLiteral("uuid_of_selected_accounts_or_operations")] = la.getUniqueID(); exp1.setExportParameters(params); SKGTESTERROR(QStringLiteral("IIF.exportFile"), exp1.exportFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportkmy1.cpp b/tests/skgbankmodelertest/skgtestimportkmy1.cpp index 74f6e75ff..893e94291 100644 --- a/tests/skgbankmodelertest/skgtestimportkmy1.cpp +++ b/tests/skgbankmodelertest/skgtestimportkmy1.cpp @@ -1,188 +1,188 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import KMY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.kmy"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/rapprochement-incorrect.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGTEST(QStringLiteral("KMY:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("750")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("CEL Donald")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGTEST(QStringLiteral("KMY:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("150")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("PEEs")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGTEST(QStringLiteral("KMY:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("640")); } { // Scope of the transaction SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy1/rapprochement-incorrect.kmy")); SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true); } } { // Test import KMY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/mytest.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } int nb = 0; SKGTESTERROR(QStringLiteral("KMY:getNbObjects(recurrentoperation)"), document1.getNbObjects(QStringLiteral("recurrentoperation"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("KMY:getNbObjects(recurrentoperation)"), nb, 8); } { // Test import KMY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/action.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("courant")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGTEST(QStringLiteral("KMY:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-600")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("actions")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGTEST(QStringLiteral("KMY:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100")); } // test multi import { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/action.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } } { // Test import KMY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/252869.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } int nb = 0; SKGTESTERROR(QStringLiteral("KMY:getNbObjects(recurrentoperation)"), document1.getNbObjects(QStringLiteral("bank"), QStringLiteral("t_name='Test Bank'"), nb), true); SKGTEST(QStringLiteral("KMY:getNbObjects(recurrentoperation)"), nb, 1); } { // 384119 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/384119.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } int nb = 0; SKGTESTERROR(QStringLiteral("KMY:getNbObjects(operations without suboperation)"), document1.getNbObjects(QStringLiteral("operation"), QStringLiteral("NOT EXISTS (SELECT 1 FROM suboperation where rd_operation_id=operation.id)"), nb), true); SKGTEST(QStringLiteral("KMY:getNbObjects(operations without suboperation)"), nb, 0); } { // Non utf8 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/non_utf8.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportkmy2.cpp b/tests/skgbankmodelertest/skgtestimportkmy2.cpp index fb3bd4899..69e62d888 100644 --- a/tests/skgbankmodelertest/skgtestimportkmy2.cpp +++ b/tests/skgbankmodelertest/skgtestimportkmy2.cpp @@ -1,55 +1,55 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import KMY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy2/to_skrooge.anon.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportkmy3.cpp b/tests/skgbankmodelertest/skgtestimportkmy3.cpp index 8df7dab56..4eb210c2d 100644 --- a/tests/skgbankmodelertest/skgtestimportkmy3.cpp +++ b/tests/skgbankmodelertest/skgtestimportkmy3.cpp @@ -1,103 +1,103 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import 304313 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy/304313.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } } { // Test import SKG SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/advice.skg")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } { // Scope of the transaction SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy3/advice.kmy")); SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true); } } { // Test import wallet SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy3/wallet.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Espece")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QLatin1String("")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("KMY.setName"), account.setName(QStringLiteral("Courant")), true); SKGTESTERROR(QStringLiteral("KMY.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("KMY.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("KMY:getName"), bank.getName(), QStringLiteral("KMYMONEY")); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportkmy4.cpp b/tests/skgbankmodelertest/skgtestimportkmy4.cpp index d11786202..0ea5dec66 100644 --- a/tests/skgbankmodelertest/skgtestimportkmy4.cpp +++ b/tests/skgbankmodelertest/skgtestimportkmy4.cpp @@ -1,144 +1,144 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) int nboperation = 0; { // Test export 320066 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/320066.skg"), true); SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("v_operation_display"), QLatin1String(""), nboperation), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy4/320066.kmy")); SKGTESTERROR(QStringLiteral("KMY.exportFile"), imp1.exportFile(), true); } } { // Test import 320066 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportkmy4/320066.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); int nboperation2 = 0; SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("v_operation_display"), QLatin1String(""), nboperation2), true); SKGTEST(QStringLiteral("document1:nb operations"), nboperation2, nboperation); } } { // Test import randy1 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/randy1.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } // Actif SKGTESTACCOUNT(document1, QStringLiteral("A000290"), 23182500.00); // Action /*SKGTESTACCOUNT(document1, QStringLiteral("A000014"), 2432032.27); SKGTESTACCOUNT(document1, QStringLiteral("A000016"), 236769.78); SKGTESTACCOUNT(document1, QStringLiteral("A000018"), 0.00); SKGTESTACCOUNT(document1, QStringLiteral("A000020"), 0.00); SKGTESTACCOUNT(document1, QStringLiteral("A000022"), 326254.23); SKGTESTACCOUNT(document1, QStringLiteral("A000023"), 459915.34); SKGTESTACCOUNT(document1, QStringLiteral("A000025"), 618975.84); SKGTESTACCOUNT(document1, QStringLiteral("A000027"), 301501.09); SKGTESTACCOUNT(document1, QStringLiteral("A000032"), 12358550.29); SKGTESTACCOUNT(document1, QStringLiteral("A000294"), 1193772.30); SKGTESTACCOUNT(document1, QStringLiteral("A000300"), 12304427.59); SKGTESTACCOUNT(document1, QStringLiteral("A000312"), 2822127.36); SKGTESTACCOUNT(document1, QStringLiteral("A000366"), 14150464.39); SKGTESTACCOUNT(document1, QStringLiteral("A000371"), 2160798.86);*/ // Carte de credit SKGTESTACCOUNT(document1, QStringLiteral("A000120"), -316721.001); SKGTESTACCOUNT(document1, QStringLiteral("A000407"), -1438.158); SKGTESTACCOUNT(document1, QStringLiteral("A000409"), 0.00); // Cheques SKGTESTACCOUNT(document1, QStringLiteral("A000030"), -6371673.033); SKGTESTACCOUNT(document1, QStringLiteral("A000040"), 429856.659); SKGTESTACCOUNT(document1, QStringLiteral("A000273"), 2479805.892); SKGTESTACCOUNT(document1, QStringLiteral("A000378"), 845357.871); // Especes SKGTESTACCOUNT(document1, QStringLiteral("A000314"), 0.00); SKGTESTACCOUNT(document1, QStringLiteral("A000354"), 863.232); // Epargne SKGTESTACCOUNT(document1, QStringLiteral("A000041"), 402257.682); SKGTESTACCOUNT(document1, QStringLiteral("A000301"), 951074.286); SKGTESTACCOUNT(document1, QStringLiteral("A000330"), 0.00); SKGTESTACCOUNT(document1, QStringLiteral("A000353"), 1753.44); SKGTESTACCOUNT(document1, QStringLiteral("A000379"), 4955771.076); SKGTESTACCOUNT(document1, QStringLiteral("A000387"), 849701.007); SKGTESTACCOUNT(document1, QStringLiteral("A000388"), 4681634.22); SKGTESTACCOUNT(document1, QStringLiteral("A000400"), 255912.039); } { // Test import cat SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/bug_import_cat.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy4/bug_import_cat.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); int nb = 0; SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("category"), QStringLiteral("t_name='Cantine'"), nb), true); SKGTEST(QStringLiteral("document1:nb category"), nb, 1); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportkmy5.cpp b/tests/skgbankmodelertest/skgtestimportkmy5.cpp index 22d4976a9..a65dbd748 100644 --- a/tests/skgbankmodelertest/skgtestimportkmy5.cpp +++ b/tests/skgbankmodelertest/skgtestimportkmy5.cpp @@ -1,102 +1,102 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import solde initial SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy5/solde_initial.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } SKGTESTACCOUNT(document1, QStringLiteral("AAA"), 123456.00); int nboperation = 0; SKGTESTERROR(QStringLiteral("document1.getNbObjects()"), document1.getNbObjects(QStringLiteral("v_operation_display"), QLatin1String(""), nboperation), true); SKGTEST(QStringLiteral("document1:nb operations"), nboperation, 0); } { // Test import steffy SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportkmy5/steffie.kmy")); SKGTESTERROR(QStringLiteral("KMY.importFile"), imp1.importFile(), true); } SKGTESTACCOUNT(document1, QStringLiteral("A000007"), 2695.00); SKGTESTACCOUNT(document1, QStringLiteral("A000548"), 175494.48); SKGTESTACCOUNT(document1, QStringLiteral("A000549"), 1186034.71); SKGTESTACCOUNT(document1, QStringLiteral("A000573"), 30968132.93); SKGTESTACCOUNT(document1, QStringLiteral("A000584"), 2493455.65); SKGTESTACCOUNT(document1, QStringLiteral("A000429"), -3723.51); SKGTESTACCOUNT(document1, QStringLiteral("A000433"), -12809.09); // Closed accounts SKGTESTACCOUNT(document1, QStringLiteral("A000004"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000005"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000006"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000490"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000430"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000431"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000432"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000533"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000435"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000436"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000437"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000487"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000492"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000495"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000497"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000499"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000526"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000543"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000553"), 0.0); SKGTESTACCOUNT(document1, QStringLiteral("A000560"), 0.0); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportledger.cpp b/tests/skgbankmodelertest/skgtestimportledger.cpp index 5db77afbc..8b0755f62 100644 --- a/tests/skgbankmodelertest/skgtestimportledger.cpp +++ b/tests/skgbankmodelertest/skgtestimportledger.cpp @@ -1,57 +1,57 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgimportexportmanager.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import GSB SKGDocumentBank document1; SKGError err; SKGTESTERROR(QStringLiteral("DOC.load"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportskg/all_types.skg"), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_LEDGE"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportledger/test-obfuscated.ledger")); SKGTESTERROR(QStringLiteral("LEDGE.exportFile"), imp1.exportFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportmmb.cpp b/tests/skgbankmodelertest/skgtestimportmmb.cpp index e5c4cfcad..5c3c53154 100644 --- a/tests/skgbankmodelertest/skgtestimportmmb.cpp +++ b/tests/skgbankmodelertest/skgtestimportmmb.cpp @@ -1,102 +1,102 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import GSK SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MMB"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.mmb"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmmb/test.mmb")); SKGTESTERROR(QStringLiteral("MMB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MMB.setName"), account.setName(QStringLiteral("COURANT")), true); SKGTESTERROR(QStringLiteral("MMB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-144.05")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MMB.setName"), account.setName(QStringLiteral("CPT2")), true); SKGTESTERROR(QStringLiteral("MMB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("40")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MMB.setName"), account.setName(QStringLiteral("NOTFAVORITE")), true); SKGTESTERROR(QStringLiteral("MMB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("150")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MMB.setName"), account.setName(QStringLiteral("LEP")), true); SKGTESTERROR(QStringLiteral("MMB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("6000")); } } { // Test import GSK SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MMB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmmb/jd.mmb")); SKGTESTERROR(QStringLiteral("MMB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MMB.setName"), account.setName(QStringLiteral("credit")), true); SKGTESTERROR(QStringLiteral("MMB.load"), account.load(), true); SKGTEST(QStringLiteral("GSB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-974.04")); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportmny1.cpp b/tests/skgbankmodelertest/skgtestimportmny1.cpp index 7362167a2..68026f982 100644 --- a/tests/skgbankmodelertest/skgtestimportmny1.cpp +++ b/tests/skgbankmodelertest/skgtestimportmny1.cpp @@ -1,174 +1,174 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" struct test { QString fileName; QString password; QMap expectedAccountAmount; }; /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import MNY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("/not-existing/missingfile.mny"))); { QMap params = impmissing.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; impmissing.setImportParameters(params); } SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager impwrong(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/wrongfile.mny")); { QMap params = impwrong.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; impwrong.setImportParameters(params); } SKGTESTERROR(QStringLiteral("imp1.importFile"), impwrong.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/money2004-pwd:123@ABC!.mny")); { QMap params = imp1.getImportParameters(); params[QStringLiteral("password")] = QStringLiteral("wrong password"); params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); } SKGTEST(QStringLiteral("imp1.importFile"), imp1.importFile().getReturnCode(), ERR_ENCRYPTION); } } QVector listTests; { test t1; t1.fileName = QStringLiteral("A B/money2002.mny"); QMap accounts; accounts[QStringLiteral("None Investment (Cash)")] = 0.0; accounts[QStringLiteral("Investments to Watch")] = 0.0; accounts[QStringLiteral("None Investment")] = 1.49; t1.expectedAccountAmount = accounts; listTests << t1; } { test t1; t1.fileName = QStringLiteral("money2001.mny"); QMap accounts; accounts[QStringLiteral("Investments to Watch")] = 0.0; t1.expectedAccountAmount = accounts; listTests << t1; } { test t1; t1.fileName = QStringLiteral("money2004-pwd:123@ABC!.mny"); t1.password = QStringLiteral("123@ABC!"); QMap accounts; accounts[QStringLiteral("Investments to Watch")] = 0.0; t1.expectedAccountAmount = accounts; listTests << t1; } { test t1; t1.fileName = QStringLiteral("money2005-pwd:123@ABC!.mny"); t1.password = QStringLiteral("123@ABC!"); QMap accounts; accounts[QStringLiteral("George's Pension Plan")] = 250.0; accounts[QStringLiteral("Investments to Watch")] = 0.0; accounts[QStringLiteral("Invoice Sales Ledger")] = 1780.71; accounts[QStringLiteral("Stocks and Shares")] = 830.5; accounts[QStringLiteral("Stocks and Shares (Cash)")] = -178.0; accounts[QStringLiteral("Woodgrove Bank Credit Card")] = 1013.0; accounts[QStringLiteral("Woodgrove Bank Current")] = 20280.14; accounts[QStringLiteral("Woodgrove Bank Savings")] = 800.0; t1.expectedAccountAmount = accounts; listTests << t1; } { test t1; t1.fileName = QStringLiteral("money2008-pwd:TEST12345.mny"); t1.password = QStringLiteral("TEST12345"); QMap accounts; accounts[QStringLiteral("Investments to Watch")] = 0.0; t1.expectedAccountAmount = accounts; listTests << t1; } for (const auto& t : qAsConst(listTests)) { // Test import MNY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/" % t.fileName)); QMap params = imp1.getImportParameters(); params[QStringLiteral("password")] = t.password; params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTESTERROR(t.fileName % ".importFile", imp1.importFile(), true); } QStringList keys = t.expectedAccountAmount.keys(); for (const auto& k : qAsConst(keys)) { SKGAccountObject account(&document1); SKGTESTERROR(t.fileName % ".setName(QStringLiteral(" % k % "))", account.setName(k), true); SKGTESTERROR(t.fileName % ".load(QStringLiteral(" % k % "))", account.load(), true); SKGTEST(t.fileName % ".getCurrentAmount(" % k % ")", SKGServices::doubleToString(account.getCurrentAmount()), SKGServices::doubleToString(t.expectedAccountAmount[k])); } if (t.fileName == QStringLiteral("money2005-pwd:123@ABC!.mny")) { bool check = false; SKGTESTERROR(t.fileName % ".existObjects", document1.existObjects(QStringLiteral("v_operation"), QStringLiteral("t_TRANSFER='Y'"), check), true); SKGTESTBOOL(t.fileName % ".existObjects", check, true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportmny2.cpp b/tests/skgbankmodelertest/skgtestimportmny2.cpp index 8c97b0155..7c02eb724 100644 --- a/tests/skgbankmodelertest/skgtestimportmny2.cpp +++ b/tests/skgbankmodelertest/skgtestimportmny2.cpp @@ -1,133 +1,133 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" class SKGTestImportMny2 { public: /** * To check the progress */ static QString previousProgress; /** * To test progress * @param iPos the current position * @return 0 */ static int progress1(int iPos, qint64 iTime, const QString& iName, void* /*iData*/) { if (SKGTestImportMny2::previousProgress != iName) { SKGTRACE << iPos << "-" << iTime << ":" << iName << endl; SKGTestImportMny2::previousProgress = iName; } return 0; } }; QString SKGTestImportMny2::previousProgress = QLatin1String(""); struct test { QString fileName; QString password; QMap expectedAccountAmount; }; /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QVector listTests; { test t1; t1.fileName = QStringLiteral("sunset-sample-5-pwd:12@a!.mny"); t1.password = QStringLiteral("12@a!"); QMap accounts; // TODO(Stephane MANKOWSKI): accounts["Charlie & May’s Joint Inv (Cash)"] = -10004.15; accounts[QStringLiteral("Charlie's 401(k)")] = 24749.18; accounts[QStringLiteral("Charlie's 401(k) (Contributions)")] = 13192.68; accounts[QStringLiteral("Commodities")] = 8745.0000; accounts[QStringLiteral("Commodities (Cash)")] = 255.0; accounts[QStringLiteral("ETF Brokerage Account")] = 690.0; accounts[QStringLiteral("ETF Brokerage Account (Cash)")] = 2310.0; accounts[QStringLiteral("Escrow Account")] = 28100.0; accounts[QStringLiteral("Home Loan")] = -149122.08; accounts[QStringLiteral("Investments to Watch")] = 0.0; accounts[QStringLiteral("Previous card (No longer used)")] = -984.25; accounts[QStringLiteral("Primary Residence")] = 355000.0; accounts[QStringLiteral("WoodGrove Finance Stock Options")] = 0.0; accounts[QStringLiteral("WoodGrove Finance Stock Options (Cash)")] = 0.0; accounts[QStringLiteral("Woodgrove Bank Checking")] = 22871.06; accounts[QStringLiteral("Woodgrove Bank Credit Card")] = 19305.74; accounts[QStringLiteral("Woodgrove Bank Savings")] = 22946.30; accounts[QStringLiteral("Woodgrove Bond Account")] = 57916.20; accounts[QStringLiteral("Woodgrove Bond Account (Cash)")] = -57916.20; accounts[QStringLiteral("Woodgrove Investments")] = 1574.62; accounts[QStringLiteral("Woodgrove Investments (Cash)")] = -1594.62; accounts[QStringLiteral("Woodgrove Platinum Card")] = -836.0; t1.expectedAccountAmount = accounts; listTests << t1; } for (const auto& t : qAsConst(listTests)) { // Test import MNY SKGTRACE << "Filename:" << t.fileName << endl; SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGTRACE << "SKG_SQLITE_LAST_VERSION:" << document1.getParameter(QStringLiteral("SKG_SQLITE_LAST_VERSION")) << endl; SKGTESTERROR(QStringLiteral("document1.setProgressCallback"), document1.setProgressCallback(&SKGTestImportMny2::progress1, nullptr), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny2/" % t.fileName)); QMap params = imp1.getImportParameters(); params[QStringLiteral("password")] = t.password; params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTESTERROR(t.fileName % ".importFile", imp1.importFile(), true); } QStringList keys = t.expectedAccountAmount.keys(); for (const auto& k : qAsConst(keys)) { SKGAccountObject account(&document1); SKGTESTERROR(t.fileName % ".setName(QStringLiteral(" % k % "))", account.setName(k), true); SKGTESTERROR(t.fileName % ".load(QStringLiteral(" % k % "))", account.load(), true); SKGTEST(t.fileName % ".getCurrentAmount(" % k % ")", SKGServices::doubleToString(account.getCurrentAmount()), SKGServices::doubleToString(t.expectedAccountAmount[k])); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportmny3.cpp b/tests/skgbankmodelertest/skgtestimportmny3.cpp index 896c503d3..d353fdc6e 100644 --- a/tests/skgbankmodelertest/skgtestimportmny3.cpp +++ b/tests/skgbankmodelertest/skgtestimportmny3.cpp @@ -1,129 +1,129 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" struct test { QString fileName; QString password; QMap expectedAccountAmount; }; /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import MNY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/A B/money2002.mny")); QMap params = imp1.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MNY.setName"), account.setName(QStringLiteral("None Investment")), true); SKGTESTERROR(QStringLiteral("MNY.load"), account.load(), true); SKGTEST(QStringLiteral("MNY.getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1.49")); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/A B/money2002.mny")); QMap params = imp1.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MNY.setName"), account.setName(QStringLiteral("None Investment")), true); SKGTESTERROR(QStringLiteral("MNY.load"), account.load(), true); SKGTEST(QStringLiteral("MNY.getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1.49")); } } { // Test import MNY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny1/notreadable.mny")); QMap params = imp1.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTEST(QStringLiteral("imp1.importFile"), imp1.importFile().getReturnCode(), ERR_READACCESS); } } { // Test import MNY SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MNY"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmny3/transfer_and_mode.mny")); QMap params = imp1.getImportParameters(); params[QStringLiteral("install_sunriise")] = 'Y'; imp1.setImportParameters(params); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } bool test2 = false; SKGTESTERROR(QStringLiteral("MNY.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("t_comment='Mode should be ''text''' AND t_mode='text'"), test2), true); SKGTEST(QStringLiteral("MNY.existObjects-test"), static_cast(test2), static_cast(true)); SKGTESTERROR(QStringLiteral("MNY.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("t_comment='Number should be 123456' AND t_number='123456'"), test2), true); SKGTEST(QStringLiteral("MNY.existObjects-test"), static_cast(test2), static_cast(true)); SKGTESTERROR(QStringLiteral("MNY.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("t_comment='True transfert' AND i_group_id<>0"), test2), true); SKGTEST(QStringLiteral("MNY.existObjects-test"), static_cast(test2), static_cast(true)); SKGTESTERROR(QStringLiteral("MNY.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("t_comment='Not a transfert, just same date/amount' AND i_group_id=0"), test2), true); SKGTEST(QStringLiteral("MNY.existObjects-test"), static_cast(test2), static_cast(true)); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportmt940.cpp b/tests/skgbankmodelertest/skgtestimportmt940.cpp index 35ad865ea..6419b9066 100644 --- a/tests/skgbankmodelertest/skgtestimportmt940.cpp +++ b/tests/skgbankmodelertest/skgtestimportmt940.cpp @@ -1,174 +1,174 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import MT940 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.mt940"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("NUMERO DE COMPTE IBAN 2")), true); SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true); SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("11.4")); } } { // Test import MT940 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/583501.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("12345.12")), true); SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true); SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("12145.12")); } } { // Test import MT940 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/341076.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("2602272001")), true); SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true); SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-12.56")); } } { // Test import MT940 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/267442_1.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("55555.55")), true); SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true); SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1972.1")); } } { // Test import MT940 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/267442_2.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("MT940.setName"), account.setName(QStringLiteral("54842.79")), true); SKGTESTERROR(QStringLiteral("MT940.load"), account.load(), true); SKGTEST(QStringLiteral("MT940:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1030.5")); } } { // 280897 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_MT940"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportmt940/test1.mt940")); SKGTESTERROR(QStringLiteral("MT940.importFile"), imp1.importFile(), true); } { bool oExist = false; SKGTESTERROR(QStringLiteral("document1.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("rc_unit_id=0"), oExist), true); SKGTESTBOOL("document1.existObjects", oExist, false); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportofx.cpp b/tests/skgbankmodelertest/skgtestimportofx.cpp index 3724d0074..6d810ac0d 100644 --- a/tests/skgbankmodelertest/skgtestimportofx.cpp +++ b/tests/skgbankmodelertest/skgtestimportofx.cpp @@ -1,477 +1,477 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.ofx"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/ofx_spec160_stmtrs_example.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } { // To check double import SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/ofx_spec160_stmtrs_example.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("999988"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("200.29")); } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/ofx_spec201_stmtrs_example.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("999988"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("200.29")); } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/t1.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("Investment account 12345 at broker ameritrade.com"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1672.84")); } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/385366.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("Investment account 209830947 at broker fidelity.com"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-1.818989404e-12")); } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/430130.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("1234567L123"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-8238.77")); } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/ca_remi.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } QStringList oResult; SKGTESTERROR(QStringLiteral("ACCOUNT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("account"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("ACCOUNT:oResult.size"), oResult.size(), 5); /*SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1,QStringLiteral("v_account"), QStringLiteral("1234567L123"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"),SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("3366.86"));*/ } { // Test import OFX with initial balance SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/initial_balance.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("40080030367683"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("5036.46")); } { // Test import OFX with initial balance after rename of account SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Create account SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE_ACCOUNT"), err); SKGTESTERROR(QStringLiteral("DOC.addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("COURANT"), QStringLiteral("111111"), QStringLiteral("BANK")), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/bug_statement.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("COURANT"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("7645.86")); } { // Test BUG 234771 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Create an account without number SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE_ACCOUNT"), err); SKGTESTERROR(QStringLiteral("DOC.addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("COURANT"), QLatin1String(""), QStringLiteral("BANK")), true); } { // Create an account without number SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE_ACCOUNT"), err); SKGTESTERROR(QStringLiteral("DOC.addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("COURANT2"), QLatin1String(""), QStringLiteral("BANK")), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/234771.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); // document1.dump ( DUMPOPERATION|DUMPACCOUNT ); } // Test BUG 319706 bool existMode = false; SKGTESTERROR(QStringLiteral("doc.existObjects"), document1.existObjects(QStringLiteral("operation"), QStringLiteral("t_mode<>''"), existMode), true); SKGTESTBOOL("doc.existMode", existMode, true); } { // Test UTF-8 - 284843 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/284843.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } int nb = 0; SKGTESTERROR(QStringLiteral("PAYEE.getNbObjects"), document1.getNbObjects(QStringLiteral("v_payee"), "t_name='" % QStringLiteral("カ-ド") % "'", nb), true); SKGTEST(QStringLiteral("PAYEE.getNbObjects"), nb, 1); document1.dump(DUMPPAYEE); } { // Test UTF-8 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/UTF8.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } { // Test 255133 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/exception.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/missing_file.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), false); } } { // Test export OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGImportExportManager exp(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportofx/export.ofx")); SKGTESTERROR(QStringLiteral("imp1.exportFile"), exp.exportFile(), false); } } { // Test 336320 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/336320.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } int nb1 = 0; SKGTESTERROR(QStringLiteral("PAYEE.getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QLatin1String(""), nb1), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/336320.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } int nb2 = 0; SKGTESTERROR(QStringLiteral("PAYEE.getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QLatin1String(""), nb2), true); SKGTEST(QStringLiteral("PAYEE.getNbObjects"), nb1, nb2); } { // Test handling of debit amount with wrong sign SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/debit_pos.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } bool existDebitPos = false; SKGTESTERROR(QStringLiteral("doc.existObjects"), document1.existObjects(QStringLiteral("v_operation"), QStringLiteral("t_mode='Debit' and f_currentamount>0"), existDebitPos), true); SKGTESTBOOL("doc.existDebitPos", existDebitPos, false); } { // Test import OFX with missing id on transactions (Theo Raves) SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/mut.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("11111111000"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-12.34")); } { // Test import OFX from GNUCASH fr Android SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/20150818_133327_gnucash_export.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } { // Test import OFX from GNUCASH fr Android SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/FEE.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("1234567L123"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-18294.69")); } { // 406321 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/406321.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/406321.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } // 406741 int nb2 = 0; SKGTESTERROR(QStringLiteral("imp1.getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QStringLiteral("d_date>'2000-01-01'"), nb2), true); SKGTEST(QStringLiteral("OPERATION:nb"), SKGServices::intToString(nb2), QStringLiteral("5")); } { // 406321 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/406321.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/406321_2.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } { // 412494 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/412494.qfx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); SKGDocument::SKGMessageList messages; SKGTESTERROR(QStringLiteral("imp1.getMessages"), document1.getMessages(document1.getCurrentTransaction(), messages, true), true); bool test = false; for (const auto& msg : qAsConst(messages)) { SKGTRACE << "Message:" << msg.Text << endl; if (msg.Text.contains(QStringLiteral("0 operations imported"))) { test = true; } } SKGTEST(QStringLiteral("message.0 operations imported"), static_cast(test), 1); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportpdf.cpp b/tests/skgbankmodelertest/skgtestimportpdf.cpp index a22cd5757..317200503 100644 --- a/tests/skgbankmodelertest/skgtestimportpdf.cpp +++ b/tests/skgbankmodelertest/skgtestimportpdf.cpp @@ -1,72 +1,72 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import PDF skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_PDF"), err); QString dir = SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportpdf/"; auto listFiles = QDir(dir).entryList(QStringList() << QStringLiteral("*.pdf"), QDir::Files, QDir::Name); for (const auto& file : listFiles) { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(dir % file)); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } document1.dump(DUMPOPERATION | DUMPACCOUNT); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("Facture allopneus"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-2041.24")); int nb = 0; SKGTESTERROR(QStringLiteral("DOC:getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QLatin1String(""), nb), true); SKGTEST(QStringLiteral("DOC:getNbObjects"), nb, 11); SKGTESTERROR(QStringLiteral("DOC:getNbObjects"), document1.getNbObjects(QStringLiteral("operation"), QStringLiteral("d_date='") + SKGServices::dateToSqlString(QDate::currentDate()) + '\'', nb), true); SKGTEST(QStringLiteral("DOC:getNbObjects"), nb, 0); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportqif1.cpp b/tests/skgbankmodelertest/skgtestimportqif1.cpp index 7c4e0be7c..4090fbd7b 100644 --- a/tests/skgbankmodelertest/skgtestimportqif1.cpp +++ b/tests/skgbankmodelertest/skgtestimportqif1.cpp @@ -1,850 +1,850 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QDate d(1970, 1, 1); { // Test import QIF 1 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.qif"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager::getParameterDefaultValue(QStringLiteral("mapping_date")); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:setNumber"), bank.setNumber(QStringLiteral("0003")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account.setNumber(QStringLiteral("12345P")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setAgencyNumber"), account.setAgencyNumber(QStringLiteral("98765")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setAgencyNumber"), account.setAgencyAddress(QStringLiteral("10 rue Dupon, 31000 TOULOUSE")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BP_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/ref.qif")); SKGTESTERROR(QStringLiteral("QIF.setDefaultAccount"), imp1.setDefaultAccount(&account), true); SKGTESTERROR(QStringLiteral("QIF.setDefaultUnit"), imp1.setDefaultUnit(&unit_euro), true); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-935")); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BP_QIF"), err); SKGImportExportManager imp1(&document1); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/ref.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-935")); } { // Test import QIF 2 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant Guillaume")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account.setNumber(QStringLiteral("98765A")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BP_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/E0269787.qif")); SKGTESTERROR(QStringLiteral("QIF.setDefaultAccount"), imp1.setDefaultAccount(&account), true); SKGTESTERROR(QStringLiteral("QIF.setDefaultUnit"), imp1.setDefaultUnit(&unit_euro), true); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-1684.58")); // Check import with account retrieved from file SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); unit_euro = SKGUnitObject(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787_bis.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } // Check multi import SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/ref.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); // Double import SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); } // Check import with account retrieved from files SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/ref.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager imp2(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp2.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787_ref.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } // Check import qif multi accounts SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/E0269787_ref.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); QStringList oResult; SKGTESTERROR(QStringLiteral("ACCOUNT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("account"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("ACCOUNT:oResult.size"), oResult.size(), 3); } } { // Test import QIF 2 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("ING")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("ING")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account.setNumber(QStringLiteral("ING")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_ING_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/ing.qif")); SKGTESTERROR(QStringLiteral("QIF.setDefaultAccount"), imp1.setDefaultAccount(&account), true); SKGTESTERROR(QStringLiteral("QIF.setDefaultUnit"), imp1.setDefaultUnit(&unit_euro), true); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGTESTERROR(QStringLiteral("QIF.cleanBankImport"), imp1.cleanBankImport(), true); int out = 0; SKGTESTERROR(QStringLiteral("QIF.findAndGroupTransfers"), imp1.findAndGroupTransfers(out), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/ing.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } } { // Test import QIF MOTO SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_ING_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/moto.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("ACTIF Moto")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("26198.77")); } } { // Test import QIF MOTO with euro and franc SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); SKGUnitObject unit; SKGTESTERROR(QStringLiteral("SKGUnitObject::createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("EUR"), unit), true); SKGTESTERROR(QStringLiteral("SKGUnitObject::createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("FRF"), unit), true); SKGTESTERROR(QStringLiteral("FRANC.addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("French Franc (FRF)"), QDate(1963, 1, 1), 1.0 / 6.55957), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_ING_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/moto.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("ACTIF Moto")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(static_cast(account.getCurrentAmount())), QStringLiteral("5009")); } } { // Test import QIF KMM SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMM_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/kmm-without-category.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-52.36")); } } { // Test import QIF KMM with category SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_KMM_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/kmm-with-category.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("CCP")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-52.36")); } } { // Test import QIF REMI in double to check merge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_REMI_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/remi_2.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_REMI_QIF"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/remi_2.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("remi 2")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-1208.63")); } } { // Test import QIF REMI in double to check merge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_DOUBLE"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/double.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("double")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-243")); } } { // Test import bug GNUCash 350286 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/350286.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("350286")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1057.37")); } } { // Test import bug GNUCash 393596 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/393596.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("393596")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("12.34")); } } { // Test import bug GNUCash 503166 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/503166.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("My Investments")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("20")); } } { // Test import bug GNUCash 392707 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/392707.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("392707")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1219.06")); } } { // Test import bug GNUCash 373584 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/373584.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("My Investments")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1000000")); } } { // Test import bug 199818 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/199818.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("199818")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-345.64")); } } { // Test import bug 201316 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/201316.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGStringListList listTmp; SKGTESTERROR(QStringLiteral("QIF.executeSelectSqliteOrder"), document1.executeSelectSqliteOrder( QStringLiteral("SELECT TOTAL(f_CURRENTAMOUNT),t_status FROM v_operation_display GROUP BY t_status ORDER BY t_status"), listTmp), true); SKGTEST(QStringLiteral("QIF:listTmp.count"), listTmp.count(), 4); if (listTmp.count() == 4) { SKGTEST(QStringLiteral("QIF:listTmp.at(1).at(0)"), listTmp.at(1).at(0), QStringLiteral("-10")); SKGTEST(QStringLiteral("QIF:listTmp.at(2).at(0)"), listTmp.at(2).at(0), QStringLiteral("-100")); SKGTEST(QStringLiteral("QIF:listTmp.at(3).at(0)"), listTmp.at(3).at(0), QStringLiteral("-1000")); } } } { // Test import bug 201451 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/201451.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("liability")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-123.45")); } } { // Test import bug 214809 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/BNP_CC_virement.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CC")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("696.64")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CEL")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("500")); } } { // Test import bug 214851 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/Fortuneo PEA (Caisse).qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager imp2(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/Fortuneo PEA.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp2.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CC")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-3604")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Fortuneo PEA")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("86.29")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Fortuneo PEA (Caisse)")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("10319.5")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Fortuneo Titres (Caisse)")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-6700")); } } { // Test import bug 215620 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/Cortal PEA.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager imp2(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/EADS.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp2.importFile(), true); } } { // Test import bug 216520 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/216520.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CC")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("11196.64")); } } { // Test import investment SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); SKGUnitObject unit; SKGTESTERROR(QStringLiteral("EUR.setName"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("Euro (EUR)"), unit), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/exp_inv.qif")); imp1.setCodec(QStringLiteral("UTF-8")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/exp_inv.qif")); exp1.setCodec(QStringLiteral("UTF-8")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } } { // Test transfer qif SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/t2.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("COURANT")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("4767.97")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("CODEVI")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-4767.97")); } } { // 233930 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/233930.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // Quicken SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/quicken.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // 267996 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/267996.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif1/267996.csv")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } } { // 271708 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/271708/10Compte A.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/271708/20Compte B.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/271708/30Compte C.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif1/271708/40Compte D.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("10Compte A")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("0")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("20Compte B")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("10")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("30Compte C")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("20")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("40Compte D")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("40")); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportqif2.cpp b/tests/skgbankmodelertest/skgtestimportqif2.cpp index 1dcf0a99c..86726b60c 100644 --- a/tests/skgbankmodelertest/skgtestimportqif2.cpp +++ b/tests/skgbankmodelertest/skgtestimportqif2.cpp @@ -1,457 +1,457 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QDate d(1970, 1, 1); { // 275963 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGUnitObject unit_euro(&document1); SKGUnitObject unit_dollar(&document1); SKGError err; { SKGAccountObject account; // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_INIT"), err); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit_euro.setSymbol(QStringLiteral("EUR")), true); SKGTESTERROR(QStringLiteral("UNIT:setType"), unit_euro.setType(SKGUnitObject::PRIMARY), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_dollar.setName(QStringLiteral("dollar")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit_dollar.setSymbol(QStringLiteral("USD")), true); SKGTESTERROR(QStringLiteral("UNIT:setType"), unit_dollar.setType(SKGUnitObject::CURRENCY), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_dollar.save(), true); // Creation unitvalue SKGUnitValueObject unit_dollar_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_dollar.addUnitValue(unit_dollar_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_dollar_val1.setQuantity(2), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_dollar_val1.setDate(d), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_dollar_val1.save(), true); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:setNumber"), bank.setNumber(QStringLiteral("0003")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("CODEVI")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setInitialBalance"), account.setInitialBalance(100, unit_dollar), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/t2.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("CODEVI")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-9335.94")); } } { // 275963 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/export_qif.skg"), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BP_QIF"), err); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif2/export_qif.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } } { // Support qif file having Type:Class with description SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGAccountObject la; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/MoneydanceExportExample.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("account"), QStringLiteral("t_name='Wells Fargo:Checking'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); if (result.count() != 0) { la = result.at(0); } } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_QIF"), err); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif2/export_all.qif")); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_QIF"), err); SKGImportExportManager exp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportqif2/export_la.qif")); QMap params; params[QStringLiteral("uuid_of_selected_accounts_or_operations")] = la.getUniqueID(); exp1.setExportParameters(params); SKGTESTERROR(QStringLiteral("QIF.exportFile"), exp1.exportFile(), true); } } { // Default account SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/LA-1234567@ing.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGBEGINTRANSACTION(document1, QStringLiteral("MODIF"), err); SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("bank"), QStringLiteral("t_name='ing'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); SKGBankObject bank(result.at(0)); SKGTESTERROR(QStringLiteral("BANK.setName"), bank.setName(QStringLiteral("ING Direct")), true); SKGTESTERROR(QStringLiteral("BANK.save"), bank.save(), true); SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("account"), QStringLiteral("t_number='1234567'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("account"), QStringLiteral("t_name='LA'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); SKGAccountObject acc(result.at(0)); SKGTESTERROR(QStringLiteral("ACC.setName"), acc.setName(QStringLiteral("Livret A")), true); SKGTESTERROR(QStringLiteral("ACC.save"), acc.save(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/LA-1234567@ing.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } document1.dump(DUMPACCOUNT); { SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("account"), QStringLiteral("t_number='1234567'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); } } { // Bug import date SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/date_money.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // Autorepair SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/autorepair.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("autorepair")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-400")); } } { // Error SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/error.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // Split and transfer SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/split_and_transfer.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Joint Checking")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-1181.25")); // -600 if sum of splits } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("2012 Acadia Loan")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1162.5")); // 581.25 if sum of splits } } { // Split and transfer 2 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/split_and_transfer_2.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Joint Checking")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("2714.31")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Credit Union")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("400")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("TSP")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("437.88")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("FSA")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("88.26")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("TSP - Roth")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("250")); } } { // 400724 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/400724.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // 402330 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/402330.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } } { // 403725 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/403725.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("refund"), QLatin1String(""), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 2); } { // 406243 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/406243.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("406243")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("794")); } } { // 406243 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/406271.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGTrackerObject tracker(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), tracker.setName(QStringLiteral("Jane")), true); SKGTESTERROR(QStringLiteral("QIF.load"), tracker.load(), true); SKGTEST(QStringLiteral("QIF:getComment"), tracker.getComment(), QStringLiteral("expenses that Jane incurs")); } } { // 406266 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/406266.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } { SKGUnitObject unit(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), unit.setName(QStringLiteral("ACME CORP")), true); SKGTESTERROR(QStringLiteral("QIF.load"), unit.load(), true); SKGTEST(QStringLiteral("QIF:getSymbol"), unit.getSymbol(), QStringLiteral("ACMW")); SKGTEST(QStringLiteral("QIF:getSymbol"), static_cast(unit.getType()), static_cast(SKGUnitObject::SHARE)); } } { // 406270 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportqif2/406270.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); } SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("unit"), QLatin1String(""), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), static_cast(result.count()), static_cast(1)); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportskg.cpp b/tests/skgbankmodelertest/skgtestimportskg.cpp index f53339e3d..b35bc7fb2 100644 --- a/tests/skgbankmodelertest/skgtestimportskg.cpp +++ b/tests/skgbankmodelertest/skgtestimportskg.cpp @@ -1,237 +1,237 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import SKG SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.skg"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportskg/all_types.skg")); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("SKG.setName"), account.setName(QStringLiteral("FRANC")), true); SKGTESTERROR(QStringLiteral("SKG.load"), account.load(), true); SKGTEST(QStringLiteral("SKG:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1.524490172")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("SKG.setName"), account.setName(QStringLiteral("COURANT")), true); SKGTESTERROR(QStringLiteral("SKG.load"), account.load(), true); SKGTEST(QStringLiteral("SKG:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-55")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("SKG.setName"), account.setName(QStringLiteral("EPARGNE")), true); SKGTESTERROR(QStringLiteral("SKG.load"), account.load(), true); SKGTEST(QStringLiteral("SKG:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1130.52449")); } // test multi import { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportskg/all_types.skg")); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), true); } // Export xml { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_XML"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types.xml")); SKGTESTERROR(QStringLiteral("SKG.exportFile"), imp1.exportFile(), true); } // Export json { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_JSON"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types.json")); SKGTESTERROR(QStringLiteral("SKG.exportFile"), imp1.exportFile(), true); } // Export json { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_JSON"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types.json")); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), false); } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; // Export skg from memory { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_mem.skg")); SKGTESTERROR(QStringLiteral("SKG.exportFile from memory"), imp1.exportFile(), true); SKGTESTERROR(QStringLiteral("SKG.importFile from file"), imp1.importFile(), true); } SKGTESTERROR(QStringLiteral("SKG.saveAs"), document1.saveAs(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_save.skg", true), true); // Export skg from file SKGTESTERROR(QStringLiteral("SKG.load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_save.skg"), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_file.skg")); SKGTESTERROR(QStringLiteral("SKG.exportFile from file"), imp1.exportFile(), true); SKGTESTERROR(QStringLiteral("SKG.importFile from file"), imp1.importFile(), true); } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; // Export sqlite from memory { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SQLITE"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_mem.sqlite")); SKGTESTERROR(QStringLiteral("SQLITE.exportFile from memory"), imp1.exportFile(), true); SKGTESTERROR(QStringLiteral("SQLITE.importFile from file"), imp1.importFile(), true); } // Export skg from file SKGTESTERROR(QStringLiteral("SKG.load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_save.skg"), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SQLITE"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_file.sqlite")); SKGTESTERROR(QStringLiteral("SQLITE.exportFile from file"), imp1.exportFile(), true); SKGTESTERROR(QStringLiteral("SQLITE.importFile from file"), imp1.importFile(), true); } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; // Export sqlcipher from memory { // Scope of the transaction SKGTESTERROR(QStringLiteral("SQLCIPHER.changePassword"), document1.changePassword(QStringLiteral("password")), true); SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SQLCIPHER"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_mem.sqlcipher")); SKGTESTERROR(QStringLiteral("SQLCIPHER.exportFile from memory"), imp1.exportFile(), true); QMap parameters; parameters[QStringLiteral("password")] = QStringLiteral("password"); imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("SQLCIPHER.importFile from file"), imp1.importFile(), true); } // Export skg from file SKGTESTERROR(QStringLiteral("SKG.load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_save.skg"), true); { // Scope of the transaction SKGTESTERROR(QStringLiteral("SQLCIPHER.changePassword"), document1.changePassword(QStringLiteral("password")), true); SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT_SQLCIPHER"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestimportskg/all_types_exp_from_file.sqlcipher")); SKGTESTERROR(QStringLiteral("SQLCIPHER.exportFile from file"), imp1.exportFile(), true); QMap parameters; parameters[QStringLiteral("password")] = QStringLiteral("password"); imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("SQLCIPHER.importFile from file"), imp1.importFile(), true); } } { // Test import encrypted SKG SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportskg/encrypted.skg")); QMap parameters; parameters[QStringLiteral("password")] = QStringLiteral("password"); imp1.setImportParameters(parameters); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), true); } } { // Test import SKG SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportskg/euro_bitcoin_dollar.skg")); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), true); } } { // Test import SKG SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_SKG"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/advice.skg")); SKGTESTERROR(QStringLiteral("SKG.importFile"), imp1.importFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportstockqif.cpp b/tests/skgbankmodelertest/skgtestimportstockqif.cpp index 2443dc530..5d87f281b 100644 --- a/tests/skgbankmodelertest/skgtestimportstockqif.cpp +++ b/tests/skgbankmodelertest/skgtestimportstockqif.cpp @@ -1,99 +1,99 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgimportexportmanager.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import QIF 1 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_STOCK_UNIT"), err); SKGUnitObject unit; SKGTESTERROR(QStringLiteral("QIF.createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("FRF"), unit), true); } document1.dump(DUMPUNIT); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_STOCK_1"), err); SKGUnitObject unit; SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/La Poste GMO.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager imp2(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/La Poste GMO (Caisse).qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp2.importFile(), true); SKGImportExportManager imp3(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/goog.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp3.importFile(), true); } document1.dump(DUMPOPERATION | DUMPUNIT | DUMPACCOUNT); } { // Test import QIF -Correction bug 2307068 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_2307068"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/2307068-BNP CC.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp1.importFile(), true); SKGImportExportManager imp12(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportstockqif/2307068-Compte Titre.qif")); SKGTESTERROR(QStringLiteral("QIF.importFile"), imp12.importFile(), true); } document1.dump(DUMPOPERATION | DUMPUNIT | DUMPACCOUNT); { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("BNP CC")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::toCurrencyString(account.getCurrentAmount(), QLatin1String(""), 2), QStringLiteral("-520.00")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("QIF.setName"), account.setName(QStringLiteral("Compte Titre")), true); SKGTESTERROR(QStringLiteral("QIF.load"), account.load(), true); SKGTEST(QStringLiteral("QIF:getValue"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("520")); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimporturls.cpp b/tests/skgbankmodelertest/skgtestimporturls.cpp index 243125642..f879e17e7 100644 --- a/tests/skgbankmodelertest/skgtestimporturls.cpp +++ b/tests/skgbankmodelertest/skgtestimporturls.cpp @@ -1,92 +1,92 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QStringList extensions; extensions << QStringLiteral("csv") << QStringLiteral("cfo") << QStringLiteral("gnucash") << QStringLiteral("gsb") << QStringLiteral("kmy") << QStringLiteral("mmb") << QStringLiteral("mt940") << QStringLiteral("ofx") << QStringLiteral("qif") << QStringLiteral("skg") << QStringLiteral("xhb"); int nb = extensions.count(); for (int i = 0; i < nb; ++i) { const QString& ext = extensions.at(i); QString filename = "http://skrooge.org/files/skgtestimporturl/test." % ext; SKGTRACE << i + 1 << "/" << nb << ": Import " << filename << endl; // Test import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromUserInput(filename)); SKGTESTERROR(ext % ".importFile", imp1.importFile(), true); } if (ext == QStringLiteral("skg") && SKGServices::getEnvVariable(QStringLiteral("USER")) == QStringLiteral("s")) { QStringList extensionsExport; extensionsExport.push_back(QStringLiteral("csv")); extensionsExport.push_back(QStringLiteral("kmy")); extensionsExport.push_back(QStringLiteral("qif")); extensionsExport.push_back(QStringLiteral("skg")); extensionsExport.push_back(QStringLiteral("xml")); extensionsExport.push_back(QStringLiteral("sqlite")); int nb2 = extensionsExport.count(); for (int j = 0; j < nb2; ++j) { const QString& ext2 = extensionsExport.at(j); QString filename2 = "ftp://skrooge.org/files/skgtestimporturl/output/test." % ext2; SKGTRACE << " " << j + 1 << "/" << nb2 << ": Export " << filename2 << endl; // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("EXPORT"), err); SKGImportExportManager imp1(&document1, QUrl::fromUserInput(filename2)); SKGTESTERROR(ext2 % ".exportFile", imp1.exportFile(), true); } } } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(QStringLiteral("http://skrooge.org/files/skgtestimporturl/test.skg")), true); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportweboob.cpp b/tests/skgbankmodelertest/skgtestimportweboob.cpp index 9e227bc9d..c47f1e402 100644 --- a/tests/skgbankmodelertest/skgtestimportweboob.cpp +++ b/tests/skgbankmodelertest/skgtestimportweboob.cpp @@ -1,526 +1,526 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QString path = qgetenv("PATH"); QString in = qgetenv("IN"); { // Test import Weboob SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportbackend/fake1/fake1.skg"), true); SKGError err; { SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/fake1/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1523.99")); SKGTEST(QStringLiteral("ACCOUNT:getAmount"), SKGServices::doubleToString(account.getAmount(QDate(2013, 5, 1))), QStringLiteral("1471.22")); SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("47896"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-30")); SKGTEST(QStringLiteral("ACCOUNT:getAmount"), SKGServices::doubleToString(account.getAmount(QDate(2013, 5, 1))), QStringLiteral("0")); SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("t_comment='SNCF'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 2); SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date='2013-05-26'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 1); } } { // BUG: 320716 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTBOOL("PUTENV.320716_1", qputenv("PATH", (in + "/skgtestimportbackend/320716_1/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("100")); } { SKGTESTBOOL("PUTENV.320716_1", qputenv("PATH", (in + "/skgtestimportbackend/320716_2/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("0")); } } { // Test error SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error1/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL); } } { // Test error SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error2/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL); } } { // Test error SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error3/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); document1.sendMessage(QStringLiteral("Hello")); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL); } } { // Test error SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTESTBOOL("PUTENV.fake1", qputenv("PATH", (in + "/skgtestimportbackend/error4/:" + path).toLatin1()), true); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTEST(QStringLiteral("WEBOOB.importFile"), imp1.importFile().getReturnCode(), ERR_FAIL); } } { // Better account selection SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE ACCOUNT"), err); // Creation the bank SKGBankObject bank(&document1); SKGTESTERROR(QStringLiteral("BANK.setName"), bank.setName(QStringLiteral("caisse-epargne")), true); SKGTESTERROR(QStringLiteral("BANK.setNumber"), bank.setNumber(QStringLiteral("13135")), true) SKGTESTERROR(QStringLiteral("BANK.save"), bank.save(), true) // Creation the account SKGAccountObject account; SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("test")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("123456789")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true) } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/betterselection/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("test"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-147994.82")); } } { // Better account selection SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/joint_accounts/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1000")); } } { // BULK import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_BULK"), err); SKGTESTBOOL("PUTENV.bulk", qputenv("PATH", (in + "/skgtestimportbackend/bulk/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".bulk"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("12345"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("10")); } // Check { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("78900"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("20")); } } { // STAMM SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("CREATE ACCOUNT"), err); // Creation the bank SKGBankObject bank(&document1); SKGTESTERROR(QStringLiteral("BANK.setName"), bank.setName(QStringLiteral("ldlc")), true); SKGTESTERROR(QStringLiteral("BANK.save"), bank.save(), true) // Creation the accounts { SKGAccountObject account; SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc1")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("1234567A")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true) } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc2")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("987654321")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true) } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("BANK.addAccount"), bank.addAccount(account), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setName"), account.setName(QStringLiteral("acc3")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setNumber"), account.setNumber(QStringLiteral("1111111A")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.setAgencyNumber"), account.setAgencyNumber(QStringLiteral("00080")), true) SKGTESTERROR(QStringLiteral("ACCOUNT.save"), account.save(), true) } } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/stamm/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc1"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc2"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("acc3"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("1234567W089"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("MYACCOUNTNAME"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } } { // Avoid merge of account due to same name SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/merge/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT2"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-50")); } } { // Avoid merge of account due to same name SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/kevin/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks QStringList accounts; accounts << QStringLiteral("COMPTE 1") << QStringLiteral("COMPTE 2") << QStringLiteral("LIVRET 1") << QStringLiteral("LIVRET 2") << QStringLiteral("EPARGNE 1") << QStringLiteral("EPARGNE 2") << QStringLiteral("EPARGNE 3"); for (const auto& acc : qAsConst(accounts)) { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), acc, account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-10")); } } { // Avoid merge of account due to same name SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/double/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("CPT"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-100")); } } { // Avoid merge of account due to same name SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/397055/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("LEO"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("-20")); } } { // rdate Not available SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/397611/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("LEO"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("598.8")); SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date!='0000-00-00'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 3); } } { // Double transferts SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_WEBOOB"), err); SKGTESTBOOL("PUTENV.weboob", qputenv("PATH", (in + "/skgtestimportbackend/double_transferts/:" + path).toLatin1()), true); SKGImportExportManager imp1(&document1, QUrl(QStringLiteral(".weboob"))); SKGTESTERROR(QStringLiteral("WEBOOB.importFile"), imp1.importFile(), true); } // Checks { SKGObjectBase::SKGListSKGObjectBase result; SKGTESTERROR(QStringLiteral("DOC.getObjects"), document1.getObjects(QStringLiteral("v_operation"), QStringLiteral("d_date!='0000-00-00'"), result), true); SKGTEST(QStringLiteral("DOC.getObjects.count"), result.count(), 4); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestimportxhb.cpp b/tests/skgbankmodelertest/skgtestimportxhb.cpp index 2ab170b9b..de7bded4c 100644 --- a/tests/skgbankmodelertest/skgtestimportxhb.cpp +++ b/tests/skgbankmodelertest/skgtestimportxhb.cpp @@ -1,165 +1,165 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test import XHB SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager impmissing(&document1, QUrl::fromLocalFile(QStringLiteral("missingfile.xhb"))); SKGTESTERROR(QStringLiteral("imp1.importFile"), impmissing.importFile(), false); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/test.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("XHB.setName"), account.setName(QStringLiteral("COURANT")), true); SKGTESTERROR(QStringLiteral("XHB.load"), account.load(), true); SKGTEST(QStringLiteral("XHB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("35")); } // test multi import { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/test.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } } { // Test import XHB SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/example_budget.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("XHB.setName"), account.setName(QStringLiteral("Cheque Account")), true); SKGTESTERROR(QStringLiteral("XHB.load"), account.load(), true); SKGTEST(QStringLiteral("XHB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("5758.22")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("XHB.setName"), account.setName(QStringLiteral("Savings Account")), true); SKGTESTERROR(QStringLiteral("XHB.load"), account.load(), true); SKGTEST(QStringLiteral("XHB:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1024.66")); } } { // Test import XHB SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/comptes.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } { SKGStringListList result; SKGTESTERROR(QStringLiteral("XHB.executeSelectSqliteOrder"), document1.executeSelectSqliteOrder(QStringLiteral("SELECT distinct t_type FROM account"), result), true); SKGTEST(QStringLiteral("XHB:distinct t_type"), result.count(), 6); } } { // Test import wallet SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/wallet.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("XHB.setName"), account.setName(QStringLiteral("Espece")), true); SKGTESTERROR(QStringLiteral("XHB.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("XHB.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("XHB:getName"), bank.getName(), QLatin1String("")); } { SKGAccountObject account(&document1); SKGTESTERROR(QStringLiteral("XHB.setName"), account.setName(QStringLiteral("Courant")), true); SKGTESTERROR(QStringLiteral("XHB.load"), account.load(), true); SKGBankObject bank; SKGTESTERROR(QStringLiteral("XHB.load"), account.getBank(bank), true); SKGTEST(QStringLiteral("XHB:getName"), bank.getName(), QStringLiteral("HOMEBANK")); } } { // Test import SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_XHB"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportxhb/error_import.xhb")); SKGTESTERROR(QStringLiteral("XHB.importFile"), imp1.importFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestinterest.cpp b/tests/skgbankmodelertest/skgtestinterest.cpp index 749084d47..29e58eb34 100644 --- a/tests/skgbankmodelertest/skgtestinterest.cpp +++ b/tests/skgbankmodelertest/skgtestinterest.cpp @@ -1,198 +1,198 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ // Init { // Test interest document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank1 SKGBankObject bank1(&document1); SKGTESTERROR(QStringLiteral("BANK:setName"), bank1.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank1.save(), true); // Creation account1 SKGAccountObject account1; SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank1.addAccount(account1), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account1.setName(QStringLiteral("Livre A")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account1.save(), true); // Add interest parameters SKGInterestObject interest1; SKGTESTERROR(QStringLiteral("ACCOUNT:addInterest"), account1.addInterest(interest1), true); SKGTESTERROR(QStringLiteral("INTEREST:setDate"), interest1.setDate(QDate::currentDate()), true); SKGTESTERROR(QStringLiteral("INTEREST:setRate"), interest1.setRate(1.25), true); SKGTESTERROR(QStringLiteral("INTEREST:setIncomeValueDateMode"), interest1.setIncomeValueDateMode(SKGInterestObject::J1), true); SKGTESTERROR(QStringLiteral("INTEREST:setExpenditueValueDateMode"), interest1.setExpenditueValueDateMode(SKGInterestObject::J2), true); SKGTESTERROR(QStringLiteral("INTEREST:setInterestComputationMode"), interest1.setInterestComputationMode(SKGInterestObject::DAYS360), true); SKGTEST(QStringLiteral("INTEREST:getRate"), interest1.getRate(), 1.25); SKGTEST(QStringLiteral("INTEREST:getIncomeValueDateMode"), static_cast(interest1.getIncomeValueDateMode()), static_cast(SKGInterestObject::J1)); SKGTEST(QStringLiteral("INTEREST:getExpenditueValueDateMode"), static_cast(interest1.getExpenditueValueDateMode()), static_cast(SKGInterestObject::J2)); SKGTEST(QStringLiteral("INTEREST:getInterestComputationMode"), static_cast(interest1.getInterestComputationMode()), static_cast(SKGInterestObject::DAYS360)); SKGTESTERROR(QStringLiteral("INTEREST:save"), interest1.save(), true); SKGInterestObject interest11(static_cast(interest1)); SKGInterestObject interest12 = interest1; SKGInterestObject interest13(SKGObjectBase(&document1, QStringLiteral("xxx"), interest1.getID())); SKGInterestObject interest14; interest14 = static_cast(interest1); } // Test interest computation SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); { QDate firstday = QDate::currentDate(); firstday = firstday.addMonths(1 - firstday.month()); firstday = firstday.addDays(1 - firstday.day()); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank1 SKGBankObject bank1(&document1); SKGTESTERROR(QStringLiteral("BANK:setName"), bank1.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank1.save(), true); // Creation account1 SKGAccountObject account1; SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank1.addAccount(account1), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account1.setName(QStringLiteral("Livre A")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account1.save(), true); // Creation unit SKGUnitObject unit_euro(&document1); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGUnitValueObject unit_euro_val1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(firstday), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Add interest parameters SKGInterestObject interest1; SKGTESTERROR(QStringLiteral("ACCOUNT:addInterest"), account1.addInterest(interest1), true); SKGTESTERROR(QStringLiteral("INTEREST:setDate"), interest1.setDate(firstday.addDays(-10)), true); SKGTESTERROR(QStringLiteral("INTEREST:setRate"), interest1.setRate(4), true); SKGTESTERROR(QStringLiteral("INTEREST:save"), interest1.save(), true); SKGInterestObject interest2; SKGTESTERROR(QStringLiteral("ACCOUNT:addInterest"), account1.addInterest(interest2), true); SKGTESTERROR(QStringLiteral("INTEREST:setDate"), interest2.setDate(firstday.addMonths(1)), true); SKGTESTERROR(QStringLiteral("INTEREST:setRate"), interest2.setRate(2.5), true); SKGTESTERROR(QStringLiteral("INTEREST:save"), interest2.save(), true); SKGInterestObject interest3; SKGTESTERROR(QStringLiteral("ACCOUNT:addInterest"), account1.addInterest(interest3), true); SKGTESTERROR(QStringLiteral("INTEREST:setDate"), interest3.setDate(firstday.addMonths(4)), true); SKGTESTERROR(QStringLiteral("INTEREST:setRate"), interest3.setRate(1.75), true); SKGTESTERROR(QStringLiteral("INTEREST:save"), interest3.save(), true); // Add operations { SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(firstday.addDays(-1)), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(100), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); } { SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(firstday.addDays(14)), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(100), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); } { SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(firstday.addMonths(5).addDays(28)), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(-100), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); } SKGAccountObject::SKGInterestItemList oInterestList; double oInterests = 0; SKGTESTERROR(QStringLiteral("ACCOUNT:getInterestItems"), account1.getInterestItems(oInterestList, oInterests), true); int nb = oInterestList.count(); for (int i = 0; i < nb; ++i) { SKGAccountObject::SKGInterestItem item = oInterestList.at(i); SKGTRACE << "[" << item.object.getDisplayName() << "]: " << SKGServices::dateToSqlString(QDateTime(item.date)) << " " << SKGServices::dateToSqlString(QDateTime(item.valueDate)) << " " << item.amount << " " << item.coef << " " << item.rate << " " << item.annualInterest << " " << item.accruedInterest << endl; } SKGTEST(QStringLiteral("INTEREST:oInterestList.count"), oInterestList.count(), 5); SKGTESTBOOL("INTEREST:oInterestList.at(1).date", (oInterestList.at(0).date == firstday), true); SKGTESTBOOL("INTEREST:oInterestList.at(2).date", (oInterestList.at(1).date == firstday.addDays(14)), true); SKGTESTBOOL("INTEREST:oInterestList.at(3).date", (oInterestList.at(2).date == firstday.addMonths(1)), true); SKGTESTBOOL("INTEREST:oInterestList.at(6).date", (oInterestList.at(3).date == firstday.addMonths(4)), true); SKGTESTBOOL("INTEREST:oInterestList.at(7).date", (oInterestList.at(4).date == firstday.addMonths(5).addDays(28)), true); SKGTEST(QStringLiteral("INTEREST:oInterests"), SKGServices::doubleToString(oInterests), QStringLiteral("3.135416667")); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestmigration.cpp b/tests/skgbankmodelertest/skgtestmigration.cpp index 13fc1b706..b08ef68eb 100644 --- a/tests/skgbankmodelertest/skgtestmigration.cpp +++ b/tests/skgbankmodelertest/skgtestmigration.cpp @@ -1,57 +1,57 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgdocumentbank.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test load old version of files { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestmigration/version_0.1.skg"), true); } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestmigration/version_0.3.skg"), true); } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestmigration/version_1.12.skg"), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestobjects.cpp b/tests/skgbankmodelertest/skgtestobjects.cpp index 164c30d93..dde93e020 100644 --- a/tests/skgbankmodelertest/skgtestobjects.cpp +++ b/tests/skgbankmodelertest/skgtestobjects.cpp @@ -1,191 +1,191 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QDate now = QDate::currentDate(); { // Test objectbase SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("v_node.unknown")), QStringLiteral("v_node.unknown")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("t_comment")), QStringLiteral("Comment")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("p_Test")), QStringLiteral("Test")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("operation.p_Test")), QStringLiteral("operation.Test")); SKGServices::SKGAttributesList undoredoAttributes; SKGTESTERROR(QStringLiteral("OBJBASE:getAttributesDescription)"), document1.getAttributesDescription(QStringLiteral("doctransaction"), undoredoAttributes), true); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.count"), undoredoAttributes.count(), 7); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.name"), undoredoAttributes[0].name, QStringLiteral("id")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.type"), static_cast(undoredoAttributes[0].type), static_cast(SKGServices::ID)); SKGTESTBOOL("OBJBASE:undoredoAttributes.notnull", undoredoAttributes[0].notnull, false); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.defaultvalue"), undoredoAttributes[0].defaultvalue, QLatin1String("")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.name"), undoredoAttributes[2].name, QStringLiteral("t_mode")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.type"), static_cast(undoredoAttributes[2].type), static_cast(SKGServices::TEXT)); SKGTESTBOOL("OBJBASE:undoredoAttributes.notnull", undoredoAttributes[2].notnull, true); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributes.defaultvalue"), undoredoAttributes[2].defaultvalue, QStringLiteral("'U'")); /* | cid | name | t_type | notnull | dflt_value | pk | | 0 | id | INTEGER | 99 | | 1 | | 1 | name | TEXT | 99 | | 0 | | 2 | t_mode | VARCHAR(1) | 0 | 'U' | 0 | | 3 | d_date | DATE | 99 | | 0 | | 4 | t_savestep | VARCHAR(1) | 0 | 'N' | 0 | | 5 | parent | INTEGER | 0 | | 0 | */ QStringList undoredoAttributeNames; SKGTESTERROR(QStringLiteral("OBJBASE:getAttributesList)"), document1.getAttributesList(QStringLiteral("doctransaction"), undoredoAttributeNames), true); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames.count"), undoredoAttributeNames.count(), 7); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[0], QStringLiteral("id")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[1], QStringLiteral("t_name")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[2], QStringLiteral("t_mode")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[3], QStringLiteral("d_date")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[4], QStringLiteral("t_savestep")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[5], QStringLiteral("t_refreshviews")); SKGTEST(QStringLiteral("OBJBASE:undoredoAttributeNames"), undoredoAttributeNames[6], QStringLiteral("i_parent")); SKGBEGINTRANSACTION(document1, QStringLiteral("OBJBASE 1"), err); SKGObjectBase obj1(&document1, QStringLiteral("bank")); SKGTESTERROR(QStringLiteral("OBJBASE:setAttribute"), obj1.setAttribute(QStringLiteral("t_name"), QStringLiteral("CL")), true); SKGTESTERROR(QStringLiteral("OBJBASE:save"), obj1.save(), true); SKGObjectBase obj2(&document1, QStringLiteral("bank"), obj1.getID()); SKGTESTERROR(QStringLiteral("OBJBASE:load"), obj2.load(), true); SKGTEST(QStringLiteral("OBJBASE:getAttribute"), obj2.getAttribute(QStringLiteral("t_name")), QStringLiteral("CL")); SKGTESTERROR(QStringLiteral("OBJBASE:setAttribute"), obj2.setAttribute(QStringLiteral("t_name"), QStringLiteral("CC")), true); SKGTESTERROR(QStringLiteral("OBJBASE:save"), obj2.save(), true); SKGObjectBase obj3(&document1, QStringLiteral("v_bank"), obj2.getID()); SKGTESTERROR(QStringLiteral("OBJBASE:load"), obj3.load(), true); SKGTEST(QStringLiteral("OBJBASE:getAttribute"), obj3.getAttribute(QStringLiteral("t_name")), QStringLiteral("CC")); SKGTEST(QStringLiteral("OBJBASE:getTable"), obj3.getTable(), QStringLiteral("v_bank")); SKGTESTERROR(QStringLiteral("OBJBASE:save"), obj3.save(), true); SKGObjectBase obj4(&document1); SKGTESTBOOL("OBJBASE:Operator =", (obj2 == obj1), true); SKGTESTBOOL("OBJBASE:Operator =", (obj3 == obj1), true); SKGTESTBOOL("OBJBASE:Operator =", (obj4 == obj1), false); SKGTESTBOOL("OBJBASE:Operator !=", (obj2 != obj1), false); SKGTESTBOOL("OBJBASE:Operator !=", (obj3 != obj1), false); SKGTESTBOOL("OBJBASE:Operator !=", (obj4 != obj1), true); SKGQStringQStringMap att = obj3.getAttributes(); int nb = obj3.getNbAttributes(); SKGTEST(QStringLiteral("OBJBASE:getNbAttributes"), obj3.getNbAttributes(), att.count()); for (int i = 0; i < nb; ++i) { SKGTRACE << i << ":" << obj3.getAttribute(SKGServices::intToString(i)) << endl; } SKGTEST(QStringLiteral("OBJBASE:getAttribute"), obj3.getAttribute(QStringLiteral("2")), QStringLiteral("CC")); SKGTESTBOOL("OBJBASE:exist", obj3.exist(), true); SKGTESTERROR(QStringLiteral("OBJBASE:dump"), obj3.dump(), true); SKGTEST(QStringLiteral("OBJBASE:getID"), obj3.getID(), 1); SKGTESTERROR(QStringLiteral("OBJBASE:resetID"), obj3.resetID(), true); SKGTEST(QStringLiteral("OBJBASE:getID"), obj3.getID(), 0); SKGNamedObject tmp1(obj3); const SKGNamedObject& tmp2 = tmp1; SKGTEST(QStringLiteral("OBJBASE:getAttribute"), tmp2.getAttribute(QStringLiteral("t_name")), QStringLiteral("CC")); // Test error SKGObjectBase notFound; SKGTESTERROR(QStringLiteral("OBJBASE:getObject"), document1.getObject(QStringLiteral("v_bank"), QStringLiteral("t_name='NOTFOUND'"), notFound), false); SKGTESTERROR(QStringLiteral("OBJBASE:getObject"), document1.getObject(QStringLiteral("parameters"), QStringLiteral("'"), notFound), false); SKGTESTERROR(QStringLiteral("OBJBASE:getObject"), document1.getObject(QStringLiteral("v_bank"), 9999, notFound), false); } } // ============================================================================ // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGTEST(QStringLiteral("BANK:getNbTransaction"), document1.getNbTransaction(), 0); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // The code here IFOK(err) { SKGTEST(QStringLiteral("BANK:getDepthTransaction"), document1.getDepthTransaction(), 1); // Example; operation succeeded SKGTESTERROR(QStringLiteral("BANK:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL1")), true); SKGTESTERROR(QStringLiteral("BANK:setParameter"), document1.setParameter(QStringLiteral("ATT2"), QStringLiteral("VAL2")), true); SKGTESTERROR(QStringLiteral("BANK:setParameter"), document1.setParameter(QStringLiteral("ATT3"), QStringLiteral("VAL2")), true); QStringList oResult; SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("parameters"), QStringLiteral("t_value"), QStringLiteral("t_value like 'VAL%'"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); // Test account SKGTESTERROR(QStringLiteral("BANK:addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("Courant"), QStringLiteral("123"), QStringLiteral("LCL")), true); SKGTESTERROR(QStringLiteral("BANK:addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("Livret A"), QStringLiteral("456"), QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("Codevi"), QStringLiteral("789"), QStringLiteral("NEF")), true); SKGTESTERROR(QStringLiteral("BANK:addOrModifyAccount"), document1.addOrModifyAccount(QStringLiteral("PEA"), QStringLiteral("ABC"), QStringLiteral("CA")), true); SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("account"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 4); // Test units SKGTESTERROR(QStringLiteral("BANK:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("E"), now, 1), true); SKGTESTERROR(QStringLiteral("BANK:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("$"), now, 1.6), true); // Oups, it is an error SKGTESTERROR(QStringLiteral("BANK:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("$"), now, 0.625), true); // it is better now SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unitvalue"), QStringLiteral("rd_unit_id"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); } } // A commit is done here because the scope is close QStringList oResult; SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unit"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); SKGTESTERROR(QStringLiteral("BANK:undoRedoTransaction(BANK_T1, SKGDocument::UNDO)"), document1.undoRedoTransaction(), true); SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unit"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("BANK:undoRedoTransaction(BANK_T1, SKGDocument::REDO)"), document1.undoRedoTransaction(SKGDocument::REDO), true); SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unit"), QStringLiteral("t_name"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 2); SKGTESTERROR(QStringLiteral("BANK:err"), err, true); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestoperation.cpp b/tests/skgbankmodelertest/skgtestoperation.cpp index 31a8b1444..ec95452cd 100644 --- a/tests/skgbankmodelertest/skgtestoperation.cpp +++ b/tests/skgbankmodelertest/skgtestoperation.cpp @@ -1,496 +1,496 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) QString filename = SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestoperation.skg"; QDate now = QDate::currentDate(); QDate tomorrow = QDate::currentDate().addDays(+1); // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGUnitValueObject unit_euro_val1; SKGBankObject bank(&document1); SKGUnitObject unit_euro(&document1); SKGAccountObject account; SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op_1), false); SKGTESTERROR(QStringLiteral("OP:setParentAccount"), op_1.setParentAccount(account), false); SKGTESTERROR(QStringLiteral("ACCOUNT:setClosed"), account.setClosed(true), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation operation ==> failed SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op_1), false); // Reopen account SKGTESTERROR(QStringLiteral("ACCOUNT:setClosed"), account.setClosed(false), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(now), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation operation ==> OK SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op_1), true); SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), false); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGTEST(QStringLiteral("OPE:getDate"), SKGServices::dateToSqlString(op_1.getDate()), SKGServices::dateToSqlString(now)); SKGTEST(QStringLiteral("SUBOPE:getDate"), SKGServices::dateToSqlString(subop_1.getDate()), SKGServices::dateToSqlString(now)); SKGTESTERROR(QStringLiteral("SUBOPE:setDate"), subop_1.setDate(tomorrow), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); SKGTEST(QStringLiteral("SUBOPE:getDate"), SKGServices::dateToSqlString(subop_1.getDate()), SKGServices::dateToSqlString(tomorrow)); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(tomorrow), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGTESTERROR(QStringLiteral("SUBOPE:load"), subop_1.load(), true); SKGTEST(QStringLiteral("OPE:getDate"), SKGServices::dateToSqlString(op_1.getDate()), SKGServices::dateToSqlString(tomorrow)); SKGTEST(QStringLiteral("SUBOPE:getDate"), SKGServices::dateToSqlString(subop_1.getDate()), SKGServices::dateToSqlString(tomorrow.addDays(+1))); } } // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGUnitValueObject unit_euro_val1; SKGBankObject bank(&document1); SKGUnitObject unit_euro(&document1); SKGAccountObject account; SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setNumber"), account.setNumber(QStringLiteral("12345P")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(now), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation categories SKGCategoryObject cat_1(&document1); SKGTESTERROR(QStringLiteral("CAT:setName"), cat_1.setName(QStringLiteral("transport")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat_1.save(), true); SKGCategoryObject cat_2; SKGTESTERROR(QStringLiteral("CAT:addCategory"), cat_1.addCategory(cat_2), true); SKGTESTERROR(QStringLiteral("CAT:setName"), cat_2.setName(QStringLiteral("train")), true); SKGTESTERROR(QStringLiteral("CAT:save"), cat_2.save(), true); // Creation operation SKGOperationObject mainOperation; double balance = 0; for (int i = 1; i <= 10; ++i) { SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setTemplate"), op_1.setTemplate(true), true); SKGTESTBOOL("OPE:isTemplate", op_1.isTemplate(), true); SKGTESTERROR(QStringLiteral("OPE:setTemplate"), op_1.setTemplate(false), true); SKGTESTBOOL("OPE:isTemplate", op_1.isTemplate(), false); SKGTESTERROR(QStringLiteral("OPE:setNumber"), op_1.setNumber(SKGServices::intToString(1000 + i)), true); SKGTESTERROR(QStringLiteral("OPE:setMode"), op_1.setMode(QStringLiteral("cheque")), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), op_1.setComment(QStringLiteral("10 tickets")), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGUnitObject u; SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.getUnit(u), true); SKGTESTERROR(QStringLiteral("OPE:bookmark"), op_1.bookmark(i % 2 == 0), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); if (i == 1) { mainOperation = op_1; SKGTESTERROR(QStringLiteral("OPE:setGroupOperation"), mainOperation.setGroupOperation(mainOperation), true); SKGTESTERROR(QStringLiteral("OPE:save"), mainOperation.save(), true); } else { if (!op_1.isBookmarked()) { SKGTESTERROR(QStringLiteral("OPE:setGroupOperation"), op_1.setGroupOperation(mainOperation), true); } SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); } // Creation suboperation for (int j = 1; j <= 5; ++j) { SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setCategory"), subop_1.setCategory(cat_2), true); SKGTESTERROR(QStringLiteral("SUBOPE:setComment"), subop_1.setComment(QStringLiteral("subop")), true); SKGTEST(QStringLiteral("SUBOPE:getComment"), subop_1.getComment(), QStringLiteral("subop")); SKGTESTERROR(QStringLiteral("OPE:setFormula"), subop_1.setFormula(QStringLiteral("total*0.196")), true); SKGTEST(QStringLiteral("SUBOPE:getFormula"), subop_1.getFormula(), QStringLiteral("total*0.196")); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(i * j), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); SKGTESTERROR(QStringLiteral("SUBOPE:load"), subop_1.load(), true); SKGOperationObject opget; SKGTESTERROR(QStringLiteral("SUBOPE:getParentOperation"), subop_1.getParentOperation(opget), true); SKGTESTBOOL("OPE:comparison", (opget == op_1), true); SKGSubOperationObject subop_12 = subop_1; SKGSubOperationObject subop_13((SKGObjectBase(subop_1))); SKGSubOperationObject subop_14 = SKGSubOperationObject(subop_1); SKGObjectBase subop_base = subop_1; SKGSubOperationObject subop_15; subop_15 = subop_base; } // Checks SKGTESTERROR(QStringLiteral("OPE:load"), op_1.load(), true); SKGTEST(QStringLiteral("OPE:getCurrentAmount"), op_1.getCurrentAmount(), i * 15); balance += i * 15; SKGTEST(QStringLiteral("OPE:getNbSubOperations"), op_1.getNbSubOperations(), 5); SKGTEST(QStringLiteral("OPE:getBalance"), op_1.getBalance(), balance); } SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 55 * 15); SKGTEST(QStringLiteral("ACCOUNT:getAmount"), account.getAmount(QDate::currentDate()), 55 * 15); SKGUnitObject getUnit; SKGTESTERROR(QStringLiteral("ACCOUNT:getUnit"), account.getUnit(getUnit), true); SKGTESTBOOL("ACCOUNT:unit", (getUnit == unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:load"), mainOperation.load(), true); SKGObjectBase::SKGListSKGObjectBase oGroupedOperations; SKGTESTERROR(QStringLiteral("OPE:getGroupedOperations"), mainOperation.getGroupedOperations(oGroupedOperations), true); SKGTEST(QStringLiteral("OPE:oGroupedOperations"), oGroupedOperations.size(), 2); // Normal SKGTESTBOOL("OPE:isInGroup", mainOperation.isInGroup(), true); // Normal SKGOperationObject mainOpe; SKGTESTERROR(QStringLiteral("OPE:getGroupedOperations"), mainOperation.getGroupOperation(mainOpe), true); SKGTESTBOOL("OPE:isImported", mainOperation.isImported(), false); SKGTESTBOOL("OPE:isTransfer", mainOperation.isTransfer(mainOpe), false); SKGTEST(QStringLiteral("OPE:getAmount"), mainOpe.getAmount(QDate::currentDate()), 135); SKGAccountObject acc; SKGTESTERROR(QStringLiteral("OPE:getParentAccount"), mainOperation.getParentAccount(acc), true); SKGTESTBOOL("OPE:account==acc", (account == acc), true); SKGTEST(QStringLiteral("OPE:getImportID"), mainOperation.getImportID(), QLatin1String("")); SKGObjectBase::SKGListSKGObjectBase oSubOperations; SKGTESTERROR(QStringLiteral("OPE:getSubOperations"), mainOperation.getSubOperations(oSubOperations), true); SKGTEST(QStringLiteral("OPE:oSubOperations"), oSubOperations.size(), 5); SKGTESTERROR(QStringLiteral("BANK:load"), bank.load(), true); } // A commit is done here because the scope is close { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T2"), err); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(2.5), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 55 * 15 * 2.5); SKGTESTERROR(QStringLiteral("BANK:load"), bank.load(), true); SKGTEST(QStringLiteral("BANK:getCurrentAmount"), bank.getCurrentAmount(), 55 * 15 * 2.5); } QFile(filename).remove(); SKGTESTERROR(QStringLiteral("DOC:saveAs"), document1.saveAs(filename), true); { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T3"), err); // Test foreign key constrain SKGTESTERROR(QStringLiteral("UNIT:remove"), unit_euro.remove(), false); } } // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load"), document1.load(filename), true); SKGAccountObject account; SKGTESTERROR(QStringLiteral("SKGAccountObject::getObjectByName"), SKGAccountObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("Courant steph"), account), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 55 * 15 * 2.5); SKGBankObject bank; SKGTESTERROR(QStringLiteral("SKGBankObject::getObjectByName"), SKGBankObject::getObjectByName(&document1, QStringLiteral("v_bank"), QStringLiteral("CREDIT COOP"), bank), true); SKGTEST(QStringLiteral("BANK:getCurrentAmount"), bank.getCurrentAmount(), 55 * 15 * 2.5); SKGTESTERROR(QStringLiteral("BANK:undoRedoTransaction"), document1.undoRedoTransaction(), true); SKGTESTERROR(QStringLiteral("ACCOUNT:load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), account.getCurrentAmount(), 55 * 15); SKGTESTERROR(QStringLiteral("BANK:load"), bank.load(), true); SKGTEST(QStringLiteral("BANK:getCurrentAmount"), bank.getCurrentAmount(), 55 * 15); // delete cascade SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T2"), err); SKGTESTERROR(QStringLiteral("BANK:delete"), bank.remove(), true); } QStringList oResult; SKGTESTERROR(QStringLiteral("BANK:getDistinctValues"), document1.getDistinctValues(QStringLiteral("bank"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("BANK:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("ACCOUNT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("account"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("ACCOUNT:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("OPE:getDistinctValues"), document1.getDistinctValues(QStringLiteral("operation"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("OPE:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("SUBOPE:getDistinctValues"), document1.getDistinctValues(QStringLiteral("suboperation"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("SUBOPE:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("BANK:undoRedoTransaction"), document1.undoRedoTransaction(), true); SKGTESTERROR(QStringLiteral("BANK:undoRedoTransaction(SKGDocument::REDO)"), document1.undoRedoTransaction(SKGDocument::REDO), true); QFile(filename).remove(); } // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGUnitValueObject unit_euro_val1; SKGBankObject bank(&document1); SKGUnitObject unit_euro(&document1); SKGAccountObject account1; SKGAccountObject account2; SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account1), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account1.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account1.setType(SKGAccountObject::CURRENT), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account1.save(), true); SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account2), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account2.setName(QStringLiteral("Loan")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account2.setType(SKGAccountObject::CURRENT), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account2.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(now), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation operations SKGOperationObject op_1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(op_1), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_1.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:setNumber"), op_1.setNumber(QStringLiteral("5490990004")), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGTEST(QStringLiteral("OPE:getNumber"), op_1.getNumber(), QStringLiteral("5490990004")); SKGSubOperationObject subop_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_1.addSubOperation(subop_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_1.setQuantity(10), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_1.save(), true); SKGOperationObject op_2; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account2.addOperation(op_2), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op_2.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op_2.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_2.save(), true); SKGSubOperationObject subop_2; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op_2.addSubOperation(subop_2), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop_2.setQuantity(-10), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop_2.save(), true); SKGTESTERROR(QStringLiteral("OPE:setGroupOperation"), op_1.setGroupOperation(op_2), true); SKGTESTERROR(QStringLiteral("OPE:setStatus"), op_1.setStatus(SKGOperationObject::POINTED), true); SKGTESTERROR(QStringLiteral("OPE:save"), op_1.save(), true); SKGOperationObject tmp; SKGOperationObject tmp2; SKGTESTBOOL("OPE:isTransfer", op_1.isTransfer(tmp), true); SKGTESTBOOL("OPE:isTransfer", tmp.isTransfer(tmp2), true); SKGTESTBOOL("OPE:equal", (tmp == op_2), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setType"), account2.setType(SKGAccountObject::LOAN), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account2.save(), true); SKGTESTERROR(QStringLiteral("OPE:load"), op_1.load(), true); SKGTESTBOOL("OPE:isTransfer", op_1.isTransfer(tmp), false); SKGTESTBOOL("OPE:isTransfer", tmp.isTransfer(tmp2), false); SKGTESTBOOL("OPE:equal", (tmp == op_2), true); SKGTESTERROR(QStringLiteral("OPE:mergeSuboperations"), op_1.mergeSuboperations(op_2), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setLinkedAccount"), account1.setLinkedAccount(account2), true); SKGAccountObject account2_2; SKGTESTERROR(QStringLiteral("ACCOUNT:getLinkedAccount"), account1.getLinkedAccount(account2_2), true); SKGTESTBOOL("OPE:equal", (account2 == account2_2), true); SKGObjectBase::SKGListSKGObjectBase accounts; SKGTESTERROR(QStringLiteral("ACCOUNT:getLinkedByAccounts"), account2.getLinkedByAccounts(accounts), true); SKGTESTERROR(QStringLiteral("ACCOUNT:transferDeferredOperations"), account1.transferDeferredOperations(account2), true); // Creation template SKGOperationObject template1; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(template1), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), template1.setDate(now.addDays(-5)), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), template1.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), template1.setComment(QStringLiteral("Comment op")), true); SKGTESTERROR(QStringLiteral("OPE:setTemplate"), template1.setTemplate(true), true); SKGTESTERROR(QStringLiteral("OPE:save"), template1.save(), true); SKGSubOperationObject template1_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), template1.addSubOperation(template1_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setDate"), template1_1.setDate(now.addDays(-4)), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), template1_1.setQuantity(10), true); SKGTESTERROR(QStringLiteral("SUBOPE:setComment"), template1.setComment(QStringLiteral("Comment sub op 1")), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), template1_1.save(), true); SKGSubOperationObject template1_2; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), template1.addSubOperation(template1_2), true); SKGTESTERROR(QStringLiteral("SUBOPE:setDate"), template1_2.setDate(now.addDays(-3)), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), template1_2.setQuantity(90), true); SKGTESTERROR(QStringLiteral("SUBOPE:setComment"), template1_2.setComment(QStringLiteral("Comment sub op 2")), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), template1_2.save(), true); // Creation op SKGOperationObject opbasic; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account1.addOperation(opbasic), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), opbasic.setDate(now), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), opbasic.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), opbasic.setComment(QStringLiteral("Comment op2")), true); SKGTESTERROR(QStringLiteral("OPE:save"), opbasic.save(), true); SKGSubOperationObject opbasic_1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), opbasic.addSubOperation(opbasic_1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), opbasic_1.setQuantity(200), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), opbasic_1.save(), true); document1.dump(DUMPOPERATION); SKGTESTERROR(QStringLiteral("SUBOPE:load"), template1.load(), true); SKGTEST(QStringLiteral("OPE:getCurrentAmount"), template1.getCurrentAmount(), 100); SKGTEST(QStringLiteral("OPE:getNbSubOperations"), template1.getNbSubOperations(), 2); SKGTESTERROR(QStringLiteral("SUBOPE:load"), opbasic.load(), true); SKGTEST(QStringLiteral("OPE:getCurrentAmount"), opbasic.getCurrentAmount(), 200); SKGTEST(QStringLiteral("OPE:getNbSubOperations"), opbasic.getNbSubOperations(), 1); // Apply the template SKGOperationObject op; SKGTESTERROR(QStringLiteral("OPE:duplicate"), template1.duplicate(op), true); SKGTESTERROR(QStringLiteral("OPE:load"), op.load(), true); SKGTEST(QStringLiteral("OPE:d_createdate"), static_cast(op.getAttribute(QStringLiteral("d_createdate")) != QLatin1String("")), static_cast(true)); SKGTESTERROR(QStringLiteral("OPE:mergeAttribute"), op.mergeAttribute(opbasic, SKGOperationObject::PROPORTIONAL), true); document1.dump(DUMPOPERATION); SKGTEST(QStringLiteral("OPE:getCurrentAmount"), template1.getCurrentAmount(), 100); SKGTEST(QStringLiteral("OPE:getNbSubOperations"), template1.getNbSubOperations(), 2); SKGTEST(QStringLiteral("OPE:getCurrentAmount"), op.getCurrentAmount(), 200); SKGTEST(QStringLiteral("OPE:getNbSubOperations"), op.getNbSubOperations(), 2); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestpayee.cpp b/tests/skgbankmodelertest/skgtestpayee.cpp index 29e1c3f33..c6499975a 100644 --- a/tests/skgbankmodelertest/skgtestpayee.cpp +++ b/tests/skgbankmodelertest/skgtestpayee.cpp @@ -1,126 +1,126 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgservices.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGUnitValueObject unit_euro_val1; QDate d1 = QDate::currentDate().addMonths(-6); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation operation SKGOperationObject op; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op), true); SKGTESTERROR(QStringLiteral("OPE:setMode"), op.setMode(QStringLiteral("cheque")), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op.setDate(d1), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); SKGPayeeObject payee(&document1); SKGPayeeObject payeeCopy(payee); SKGPayeeObject payeeCopy2(static_cast(payee)); SKGTESTERROR(QStringLiteral("REF:setName"), payee.setName(QStringLiteral("payee")), true); SKGTESTERROR(QStringLiteral("REF:setAddress"), payee.setAddress(QStringLiteral("address")), true); SKGTESTBOOL("REF:isBookmarked", payee.isBookmarked(), false); SKGTESTERROR(QStringLiteral("REF:bookmark"), payee.bookmark(true), true); SKGTESTBOOL("REF:isBookmarked", payee.isBookmarked(), true); SKGTESTBOOL("REF:isClosed", payee.isClosed(), false); SKGTESTERROR(QStringLiteral("REF:setClosed"), payee.setClosed(true), true); SKGTESTBOOL("REF:isClosed", payee.isClosed(), true); SKGTESTERROR(QStringLiteral("REF:save"), payee.save(), true); SKGTEST(QStringLiteral("REF:getName"), payee.getName(), QStringLiteral("payee")); SKGTEST(QStringLiteral("REF:getAddress"), payee.getAddress(), QStringLiteral("address")); SKGTESTERROR(QStringLiteral("OPE:setPayee"), op.setPayee(payee), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); SKGPayeeObject payee2; SKGTESTERROR(QStringLiteral("OPE:getPayee"), op.getPayee(payee2), true); SKGTESTBOOL("OPE:compare", (payee == payee2), true); SKGCategoryObject cat; SKGTESTERROR(QStringLiteral("REF:getCategory"), payee.getCategory(cat), false); SKGTESTERROR(QStringLiteral("CAT:createPathCategory"), SKGCategoryObject::createPathCategory(&document1, QStringLiteral("A"), cat), true); SKGTESTERROR(QStringLiteral("REF:setCategory"), payee.setCategory(cat), true); SKGTESTERROR(QStringLiteral("REF:getCategory"), payee.getCategory(cat), true); SKGTESTERROR(QStringLiteral("REF:save"), payee.save(), true); SKGTESTERROR(QStringLiteral("REF:load"), payee.load(), true); SKGPayeeObject pay; SKGTESTERROR(QStringLiteral("REF:createPayee"), SKGPayeeObject::createPayee(&document1, QStringLiteral("pay"), pay, true), true); SKGTEST(QStringLiteral("DOC:getCategoryForPayee"), document1.getCategoryForPayee(QStringLiteral("payee")), QStringLiteral("A")); // Merge SKGTESTERROR(QStringLiteral("CAT:merge"), payee2.merge(pay), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestpfs.cpp b/tests/skgbankmodelertest/skgtestpfs.cpp index f4e13b6ae..a449400be 100644 --- a/tests/skgbankmodelertest/skgtestpfs.cpp +++ b/tests/skgbankmodelertest/skgtestpfs.cpp @@ -1,67 +1,67 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgreportbank.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestpfs/personalfinancescore.skg"), true); SKGError err; auto* rep = qobject_cast(document1.getReport()); rep->setPeriod(QStringLiteral("2010")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), SKGServices::doubleToString(rep->getPersonalFinanceScoreDetails().value(QStringLiteral("value")).toDouble()), QStringLiteral("-0.04761904762")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), rep->getPersonalFinanceScoreDetails().value(QStringLiteral("level")).toString(), QStringLiteral("danger")); rep->setPeriod(QStringLiteral("2011")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), SKGServices::doubleToString(rep->getPersonalFinanceScoreDetails().value(QStringLiteral("value")).toDouble()), QStringLiteral("3.75")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), rep->getPersonalFinanceScoreDetails().value(QStringLiteral("level")).toString(), QStringLiteral("warning")); rep->setPeriod(QStringLiteral("2012")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), SKGServices::doubleToString(rep->getPersonalFinanceScoreDetails().value(QStringLiteral("value")).toDouble()), QStringLiteral("9.833333333")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), rep->getPersonalFinanceScoreDetails().value(QStringLiteral("level")).toString(), QStringLiteral("warning")); rep->setPeriod(QStringLiteral("2013")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), SKGServices::doubleToString(rep->getPersonalFinanceScoreDetails().value(QStringLiteral("value")).toDouble()), QStringLiteral("11.95")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), rep->getPersonalFinanceScoreDetails().value(QStringLiteral("level")).toString(), QStringLiteral("success")); rep->setPeriod(QStringLiteral("2014")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), SKGServices::doubleToString(rep->getPersonalFinanceScoreDetails().value(QStringLiteral("value")).toDouble()), QStringLiteral("35.95")); SKGTEST(QStringLiteral("SKGReportBank:getPersonalFinanceScore"), rep->getPersonalFinanceScoreDetails().value(QStringLiteral("level")).toString(), QStringLiteral("success")); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestrecurrent.cpp b/tests/skgbankmodelertest/skgtestrecurrent.cpp index b42fd8b8c..795116c28 100644 --- a/tests/skgbankmodelertest/skgtestrecurrent.cpp +++ b/tests/skgbankmodelertest/skgtestrecurrent.cpp @@ -1,185 +1,185 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgservices.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGUnitValueObject unit_euro_val1; QDate d1 = QDate::currentDate().addMonths(-6); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation operation SKGOperationObject op; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op), true); SKGObjectBase::SKGListSKGObjectBase recups; SKGTESTERROR(QStringLiteral("OP:getRecurrentOperations"), op.getRecurrentOperations(recups), false); SKGRecurrentOperationObject recuope; SKGTESTERROR(QStringLiteral("OP:addRecurrentOperation"), op.addRecurrentOperation(recuope), false); SKGTESTERROR(QStringLiteral("OPE:setMode"), op.setMode(QStringLiteral("cheque")), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), op.setComment(QStringLiteral("10 tickets")), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op.setDate(d1), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); { SKGSubOperationObject subop; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op.addSubOperation(subop), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop.setQuantity(8.5), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop.save(), true); } { SKGSubOperationObject subop; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op.addSubOperation(subop), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop.setQuantity(10), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop.save(), true); } // Checks SKGTESTERROR(QStringLiteral("OPE:load"), op.load(), true); { SKGOperationObject op2; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op2), true); SKGTESTERROR(QStringLiteral("OPE:setMode"), op2.setMode(QStringLiteral("cheque")), true); SKGTESTERROR(QStringLiteral("OPE:setComment"), op2.setComment(QStringLiteral("10 tickets")), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op2.setDate(d1), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op2.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op2.save(), true); SKGSubOperationObject subop; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op2.addSubOperation(subop), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop.setQuantity(8.5), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop.save(), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.setGroupOperation(op2), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); } // Add recurrent operation SKGTESTERROR(QStringLiteral("OP:addRecurrentOperation"), op.addRecurrentOperation(recuope), true); SKGTESTERROR(QStringLiteral("RECOP:setPeriodIncrement"), recuope.setPeriodIncrement(2), true); SKGTESTERROR(QStringLiteral("RECOP:setPeriodUnit"), recuope.setPeriodUnit(SKGRecurrentOperationObject::MONTH), true); SKGTESTERROR(QStringLiteral("RECOP:setAutoWriteDays"), recuope.setAutoWriteDays(6), true); SKGTESTERROR(QStringLiteral("RECOP:autoWriteEnabled"), recuope.autoWriteEnabled(true), true); SKGTESTERROR(QStringLiteral("RECOP:setWarnDays"), recuope.setWarnDays(10), true); SKGTESTERROR(QStringLiteral("RECOP:warnEnabled"), recuope.warnEnabled(true), true); SKGTESTERROR(QStringLiteral("RECOP:setTimeLimit"), recuope.setTimeLimit(QDate::currentDate().addMonths(-4)), true); SKGTESTERROR(QStringLiteral("RECOP:timeLimit"), recuope.timeLimit(true), true); SKGTESTERROR(QStringLiteral("RECOP:save"), recuope.save(), true); SKGRecurrentOperationObject recuope2(recuope); SKGRecurrentOperationObject recuope3(SKGObjectBase(recuope.getDocument(), QStringLiteral("xxx"), recuope.getID())); SKGRecurrentOperationObject recuope4(SKGNamedObject(recuope.getDocument(), QStringLiteral("xxx"), recuope.getID())); SKGObjectBase::SKGListSKGObjectBase recops; SKGTESTERROR(QStringLiteral("OP:getRecurrentOperations"), op.getRecurrentOperations(recops), true); SKGTEST(QStringLiteral("RECOP:recops.count"), recops.count(), 1); SKGTEST(QStringLiteral("RECOP:getPeriodIncrement"), recuope.getPeriodIncrement(), 2); SKGTEST(QStringLiteral("RECOP:getPeriodUnit"), static_cast(recuope.getPeriodUnit()), static_cast(SKGRecurrentOperationObject::MONTH)); SKGTEST(QStringLiteral("RECOP:getAutoWriteDays"), recuope.getAutoWriteDays(), 6); SKGTESTBOOL("RECOP:isAutoWriteEnabled", recuope.isAutoWriteEnabled(), true); SKGTEST(QStringLiteral("RECOP:getWarnDays"), recuope.getWarnDays(), 10); SKGTESTBOOL("RECOP:isWarnEnabled", recuope.isWarnEnabled(), true); SKGTEST(QStringLiteral("RECOP:getTimeLimit"), recuope.getTimeLimit(), 3); SKGTESTBOOL("RECOP:hasTimeLimit", recuope.hasTimeLimit(), true); SKGTEST(QStringLiteral("RECOP:getDate"), recuope.getDate().toString(), d1.toString()); SKGOperationObject ope2; SKGTESTERROR(QStringLiteral("RECOP:getParentOperation"), recuope.getParentOperation(ope2), true); SKGTESTBOOL("RECOP:op==ope2", (op == ope2), true); document1.dump(DUMPOPERATION); int nbi = 0; SKGTESTERROR(QStringLiteral("RECOP:process"), recuope.process(nbi), true); SKGTEST(QStringLiteral("RECOP:nbi"), nbi, 3); SKGTESTERROR(QStringLiteral("RECOP:getParentOperation"), recuope.getParentOperation(ope2), true); SKGTESTBOOL("RECOP:op!=ope2", (op != ope2), true); SKGTESTERROR(QStringLiteral("RECOP:getRecurredOperations"), recuope.getRecurredOperations(recops), true); SKGTEST(QStringLiteral("RECOP:recops.count"), recops.count(), 3); SKGTESTERROR(QStringLiteral("RECOP:SKGRecurrentOperationObject::process"), SKGRecurrentOperationObject::process(&document1, nbi), true); document1.dump(DUMPOPERATION); SKGTESTERROR(QStringLiteral("RECOP:setPeriodIncrement"), recuope.setPeriodIncrement(2), true); SKGTESTERROR(QStringLiteral("RECOP:setPeriodUnit"), recuope.setPeriodUnit(SKGRecurrentOperationObject::DAY), true); recuope.getNextDate(); SKGTESTERROR(QStringLiteral("RECOP:setPeriodUnit"), recuope.setPeriodUnit(SKGRecurrentOperationObject::WEEK), true); recuope.getNextDate(); SKGTESTERROR(QStringLiteral("RECOP:setPeriodUnit"), recuope.setPeriodUnit(SKGRecurrentOperationObject::MONTH), true); recuope.getNextDate(); SKGTESTERROR(QStringLiteral("RECOP:setPeriodUnit"), recuope.setPeriodUnit(SKGRecurrentOperationObject::YEAR), true); recuope.getNextDate(); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestrefund.cpp b/tests/skgbankmodelertest/skgtestrefund.cpp index 5db401f90..dd7316a1c 100644 --- a/tests/skgbankmodelertest/skgtestrefund.cpp +++ b/tests/skgbankmodelertest/skgtestrefund.cpp @@ -1,152 +1,152 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgservices.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Test bank document SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGBankObject bank(&document1); SKGAccountObject account; SKGUnitObject unit_euro(&document1); SKGUnitValueObject unit_euro_val1; QDate d1 = QDate::currentDate().addMonths(-6); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Creation bank SKGTESTERROR(QStringLiteral("BANK:setName"), bank.setName(QStringLiteral("CREDIT COOP")), true); SKGTESTERROR(QStringLiteral("BANK:save"), bank.save(), true); // Creation account SKGTESTERROR(QStringLiteral("BANK:addAccount"), bank.addAccount(account), true); SKGTESTERROR(QStringLiteral("ACCOUNT:setName"), account.setName(QStringLiteral("Courant steph")), true); SKGTESTERROR(QStringLiteral("ACCOUNT:save"), account.save(), true); // Creation unit SKGTESTERROR(QStringLiteral("UNIT:setName"), unit_euro.setName(QStringLiteral("euro")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit_euro.save(), true); // Creation unitvalue SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit_euro.addUnitValue(unit_euro_val1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unit_euro_val1.setQuantity(1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unit_euro_val1.setDate(d1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unit_euro_val1.save(), true); // Creation operation SKGOperationObject op; SKGTESTERROR(QStringLiteral("ACCOUNT:addOperation"), account.addOperation(op), true); SKGTESTERROR(QStringLiteral("OPE:setMode"), op.setMode(QStringLiteral("cheque")), true); SKGTESTERROR(QStringLiteral("OPE:setDate"), op.setDate(d1), true); SKGTESTERROR(QStringLiteral("OPE:setUnit"), op.setUnit(unit_euro), true); SKGTESTERROR(QStringLiteral("OPE:save"), op.save(), true); SKGSubOperationObject subop1; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op.addSubOperation(subop1), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop1.setQuantity(21), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop1.save(), true); SKGSubOperationObject subop2; SKGTESTERROR(QStringLiteral("OPE:addSubOperation"), op.addSubOperation(subop2), true); SKGTESTERROR(QStringLiteral("SUBOPE:setQuantity"), subop2.setQuantity(1), true); SKGTESTERROR(QStringLiteral("SUBOPE:save"), subop2.save(), true); SKGTrackerObject tracker(&document1); SKGTrackerObject trackerCopy(tracker); SKGTrackerObject trackerCopy2(static_cast(tracker)); SKGTESTERROR(QStringLiteral("REF:setName"), tracker.setName(QStringLiteral("tracker")), true); SKGTESTERROR(QStringLiteral("REF:setComment"), tracker.setComment(QStringLiteral("comment")), true); SKGTESTERROR(QStringLiteral("REF:save"), tracker.save(), true); SKGTEST(QStringLiteral("REF:getName"), tracker.getName(), QStringLiteral("tracker")); SKGTEST(QStringLiteral("REF:getComment"), tracker.getComment(), QStringLiteral("comment")); SKGTESTBOOL("REF:isClosed", tracker.isClosed(), false); SKGTESTERROR(QStringLiteral("OPE:setClosed"), tracker.setClosed(true), true); SKGTESTBOOL("REF:isClosed", tracker.isClosed(), true) SKGTESTERROR(QStringLiteral("OPE:setClosed"), tracker.setClosed(false), true); SKGTESTBOOL("REF:isClosed", tracker.isClosed(), false); SKGTESTERROR(QStringLiteral("OPE:setTracker"), subop1.setTracker(tracker), true); SKGTESTERROR(QStringLiteral("OPE:save"), subop1.save(), true); SKGTESTERROR(QStringLiteral("OPE:setClosed"), tracker.setClosed(true), true); SKGTESTERROR(QStringLiteral("OPE:save"), tracker.save(), true); // BUG 250350 vvv SKGTESTERROR(QStringLiteral("OPE:setTracker"), subop1.setTracker(tracker), true); SKGTESTERROR(QStringLiteral("OPE:setTracker"), subop1.setTracker(tracker), true); SKGTrackerObject trackerclose(&document1); SKGTESTERROR(QStringLiteral("REF:setName"), trackerclose.setName(QStringLiteral("trackerclose")), true); SKGTESTERROR(QStringLiteral("OPE:setClosed"), trackerclose.setClosed(true), true); SKGTESTERROR(QStringLiteral("REF:save"), trackerclose.save(), true); SKGTESTERROR(QStringLiteral("OPE:setTracker"), subop1.setTracker(trackerclose), false); SKGTrackerObject trackeropen(&document1); SKGTESTERROR(QStringLiteral("REF:setName"), trackeropen.setName(QStringLiteral("trackeropen")), true); SKGTESTERROR(QStringLiteral("OPE:setClosed"), trackerclose.setClosed(true), true); SKGTESTERROR(QStringLiteral("OPE:setTracker"), subop1.setTracker(trackeropen), false); // BUG 250350 ^^^ SKGTrackerObject tracker2; SKGTESTERROR(QStringLiteral("OPE:getTracker"), subop1.getTracker(tracker2), true); SKGTESTBOOL("OPE:compare", (tracker == tracker2), true); SKGTESTERROR(QStringLiteral("REF:load"), tracker.load(), true); SKGTEST(QStringLiteral("REF:getCurrentAmount"), tracker.getCurrentAmount(), 21); SKGObjectBase::SKGListSKGObjectBase oSubOperations; SKGTESTERROR(QStringLiteral("REF:getSubOperations"), tracker.getSubOperations(oSubOperations), true); SKGTEST(QStringLiteral("REF:compare"), oSubOperations.count(), 1); SKGTrackerObject track; SKGTESTERROR(QStringLiteral("REF:createTracker"), SKGTrackerObject::createTracker(&document1, QStringLiteral("track"), track, true), true); SKGTESTERROR(QStringLiteral("OPE:setClosed"), tracker.setClosed(false), true); SKGTESTERROR(QStringLiteral("REF:save"), tracker.save(), true); SKGTESTERROR(QStringLiteral("REF:merge"), track.merge(tracker), true); SKGTrackerObject trackBlank; SKGTESTERROR(QStringLiteral("REF:createTracker"), SKGTrackerObject::createTracker(&document1, QLatin1String(""), trackBlank, true), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestrestore.cpp b/tests/skgbankmodelertest/skgtestrestore.cpp index 2fb0b690f..dee79fb6c 100644 --- a/tests/skgbankmodelertest/skgtestrestore.cpp +++ b/tests/skgbankmodelertest/skgtestrestore.cpp @@ -1,75 +1,75 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test restore SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true); SKGTESTERROR(QStringLiteral("document1.load(pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/pwd.skg", QLatin1String(""), true), false); SKGTESTERROR(QStringLiteral("document1.load(pwd.skg, a)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/pwd.skg", QStringLiteral("a"), true), true); QFile(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/.nopwd.skg.wrk").remove(); SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true); } { // Test load file SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("document1.load(sqlite_no_pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlite_no_pwd.skg", QLatin1String(""), true), true); SKGTESTERROR(QStringLiteral("document1.load(sqlite_pwd_ABC.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlite_pwd_ABC.skg", QStringLiteral("ABC"), true), true); SKGTESTERROR(QStringLiteral("document1.load(sqlcipher_no_pwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlcipher_no_pwd.skg", QLatin1String(""), true), true); SKGTESTERROR(QStringLiteral("document1.load(sqlcipher_pwd_ABC.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/sqlcipher_pwd_ABC.skg", QStringLiteral("ABC"), true), true); } { // Test load (sqlite mode) + save + load SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("document1.load(nopwd.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd.skg", QLatin1String(""), true), true); SKGTESTERROR(QStringLiteral("document1.saveas(nopwd2.skg)"), document1.saveAs(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd2.skg", true), true); SKGTESTERROR(QStringLiteral("document1.load(nopwd2.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestrestore/nopwd2.skg", QLatin1String(""), true), true); } { SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % QStringLiteral("skgtestrestore/recovery.skg"), QLatin1String(""), true), true); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestrule.cpp b/tests/skgbankmodelertest/skgtestrule.cpp index aad744761..c8470175a 100644 --- a/tests/skgbankmodelertest/skgtestrule.cpp +++ b/tests/skgbankmodelertest/skgtestrule.cpp @@ -1,280 +1,280 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // ============================================================================ { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; // Initialisation document { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/385366.ofx")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } // Check static methods { auto list = SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::SEARCH); list << SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::UPDATE); list << SKGRuleObject::getListOfOperators(SKGServices::INTEGER, SKGRuleObject::SEARCH); list << SKGRuleObject::getListOfOperators(SKGServices::INTEGER, SKGRuleObject::UPDATE); list << SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::SEARCH); list << SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::UPDATE); list << SKGRuleObject::getListOfOperators(SKGServices::DATE, SKGRuleObject::SEARCH); list << SKGRuleObject::getListOfOperators(SKGServices::DATE, SKGRuleObject::UPDATE); list << SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::ALARM); list << SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::APPLYTEMPLATE); for (const auto& i : qAsConst(list)) { SKGRuleObject::getDisplayForOperator(i, QLatin1String(""), QLatin1String(""), QLatin1String("")); SKGRuleObject::getToolTipForOperator(i); } SKGRuleObject::getListOfOperators(SKGServices::INTEGER, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::FLOAT, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::DATE, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::TRISTATE, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::SEARCH); SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::INTEGER, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::FLOAT, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::DATE, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::TRISTATE, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::BOOL, SKGRuleObject::UPDATE); SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::ALARM); SKGRuleObject::getListOfOperators(SKGServices::TEXT, SKGRuleObject::APPLYTEMPLATE); } // Rule creation SKGRuleObject rule1; { SKGBEGINTRANSACTION(document1, QStringLiteral("RULE_1"), err); // Create rule rule1 = SKGRuleObject(&document1); QString searchDef = QStringLiteral(" " " " "" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLSearchDefinition"), rule1.setXMLSearchDefinition(searchDef), true); SKGTEST(QStringLiteral("RULE:getXMLSearchDefinition"), rule1.getXMLSearchDefinition(), searchDef); QString actionDef = QStringLiteral(" " " " "" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLActionDefinition"), rule1.setXMLActionDefinition(actionDef), true); SKGTEST(QStringLiteral("RULE:getXMLActionDefinition"), rule1.getXMLActionDefinition(), actionDef); SKGTESTERROR(QStringLiteral("RULE:setSearchDescription"), rule1.setSearchDescription(QStringLiteral("search description")), true); SKGTEST(QStringLiteral("RULE:getSearchDescription"), rule1.getSearchDescription(), QStringLiteral("search description")); SKGTESTERROR(QStringLiteral("RULE:setActionDescription"), rule1.setActionDescription(QStringLiteral("action description")), true); SKGTEST(QStringLiteral("RULE:getActionDescription"), rule1.getActionDescription(), QStringLiteral("action description")); SKGTESTERROR(QStringLiteral("RULE:setActionType"), rule1.setActionType(SKGRuleObject::SEARCH), true); SKGTESTERROR(QStringLiteral("RULE:setActionType"), rule1.setActionType(SKGRuleObject::APPLYTEMPLATE), true); SKGTESTERROR(QStringLiteral("RULE:setActionType"), rule1.setActionType(SKGRuleObject::UPDATE), true); SKGTEST(QStringLiteral("RULE:getActionType"), static_cast(rule1.getActionType()), static_cast(SKGRuleObject::UPDATE)); SKGTESTERROR(QStringLiteral("RULE:setOrder"), rule1.setOrder(-1), true); SKGTEST(QStringLiteral("RULE:getOrder"), rule1.getOrder(), 1); SKGTESTBOOL("RULE:setOrder", rule1.isBookmarked(), false); SKGTESTERROR(QStringLiteral("RULE:getOrder"), rule1.bookmark(true), true); SKGTESTBOOL("RULE:setOrder", rule1.isBookmarked(), true); SKGTESTERROR(QStringLiteral("UNIT:save"), rule1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:load"), rule1.load(), true); rule1.getDisplayName(); SKGRuleObject rule1bis = SKGRuleObject(rule1); SKGRuleObject rule1ter = SKGRuleObject(static_cast(rule1)); SKGRuleObject rule4; rule4 = static_cast(rule1); SKGRuleObject rule5(SKGObjectBase(&document1, QStringLiteral("xxx"), rule1.getID())); } // Rule creation (ALARM) SKGRuleObject alarm1; { SKGBEGINTRANSACTION(document1, QStringLiteral("ALARM_1"), err); // Create rule alarm1 = SKGRuleObject(&document1); QString searchDef = QStringLiteral(" " " " "" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLSearchDefinition"), alarm1.setXMLSearchDefinition(searchDef), true); SKGTEST(QStringLiteral("RULE:getXMLSearchDefinition"), alarm1.getXMLSearchDefinition(), searchDef); QString actionDef = QStringLiteral(" " " " "=\"/>" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLActionDefinition"), alarm1.setXMLActionDefinition(actionDef), true); SKGTEST(QStringLiteral("RULE:getXMLActionDefinition"), alarm1.getXMLActionDefinition(), actionDef); SKGTESTERROR(QStringLiteral("RULE:setSearchDescription"), alarm1.setSearchDescription(QStringLiteral("search description")), true); SKGTEST(QStringLiteral("RULE:getSearchDescription"), alarm1.getSearchDescription(), QStringLiteral("search description")); SKGTESTERROR(QStringLiteral("RULE:setActionDescription"), alarm1.setActionDescription(QStringLiteral("action description")), true); SKGTEST(QStringLiteral("RULE:getActionDescription"), alarm1.getActionDescription(), QStringLiteral("action description")); SKGTESTERROR(QStringLiteral("RULE:setActionType"), alarm1.setActionType(SKGRuleObject::ALARM), true); SKGTEST(QStringLiteral("RULE:getActionType"), static_cast(alarm1.getActionType()), static_cast(SKGRuleObject::ALARM)); SKGTESTERROR(QStringLiteral("RULE:setOrder"), alarm1.setOrder(-1), true); SKGTEST(QStringLiteral("RULE:getOrder"), alarm1.getOrder(), 2); SKGTESTERROR(QStringLiteral("UNIT:save"), alarm1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:load"), alarm1.load(), true); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Message, QStringLiteral("Take care!")); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), static_cast(alarm1.getAlarmInfo().Raised), static_cast(true)); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Amount, 121.41); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Limit, 100); } // Process rule1 { SKGBEGINTRANSACTION(document1, QStringLiteral("PROCESS_1"), err); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTING), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTEDNOTVALIDATE), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTED), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::NOTCHECKED), true); } // Rule creation (BUG:345974) { SKGBEGINTRANSACTION(document1, QStringLiteral("ALARM_2"), err); // Create rule alarm1 = SKGRuleObject(&document1); QString searchDef = QStringLiteral(" " " " "" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLSearchDefinition"), alarm1.setXMLSearchDefinition(searchDef), true); SKGTEST(QStringLiteral("RULE:getXMLSearchDefinition"), alarm1.getXMLSearchDefinition(), searchDef); QString actionDef = QStringLiteral(" " " " "=\"/>" "" ""); SKGTESTERROR(QStringLiteral("RULE:setXMLActionDefinition"), alarm1.setXMLActionDefinition(actionDef), true); SKGTEST(QStringLiteral("RULE:getXMLActionDefinition"), alarm1.getXMLActionDefinition(), actionDef); SKGTESTERROR(QStringLiteral("RULE:setSearchDescription"), alarm1.setSearchDescription(QStringLiteral("search description")), true); SKGTEST(QStringLiteral("RULE:getSearchDescription"), alarm1.getSearchDescription(), QStringLiteral("search description")); SKGTESTERROR(QStringLiteral("RULE:setActionDescription"), alarm1.setActionDescription(QStringLiteral("action description")), true); SKGTEST(QStringLiteral("RULE:getActionDescription"), alarm1.getActionDescription(), QStringLiteral("action description")); SKGTESTERROR(QStringLiteral("RULE:setActionType"), alarm1.setActionType(SKGRuleObject::ALARM), true); SKGTEST(QStringLiteral("RULE:getActionType"), static_cast(alarm1.getActionType()), static_cast(SKGRuleObject::ALARM)); SKGTESTERROR(QStringLiteral("UNIT:save"), alarm1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:load"), alarm1.load(), true); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Message, QStringLiteral("Take care!")); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), static_cast(alarm1.getAlarmInfo().Raised), static_cast(false)); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Amount, 121.41); SKGTEST(QStringLiteral("RULE:getAlarmInfo"), alarm1.getAlarmInfo().Limit, 200); } // Process rule1 { SKGBEGINTRANSACTION(document1, QStringLiteral("PROCESS_1"), err); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTING), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTEDNOTVALIDATE), true); SKGTESTERROR(QStringLiteral("RULE:execute"), rule1.execute(SKGRuleObject::IMPORTED), true); } document1.dump(DUMPOPERATION | DUMPACCOUNT); } // ============================================================================ { // Test import OFX skrooge SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "skgtestrule/file.skg"), true); // Process rules SKGError err; { SKGBEGINTRANSACTION(document1, QStringLiteral("PROCESS_1"), err); SKGObjectBase::SKGListSKGObjectBase rules; SKGTESTERROR(QStringLiteral("RULE:execute"), document1.getObjects(QStringLiteral("rule"), QLatin1String(""), rules), true); for (int i = 0; i < rules.count(); ++i) { SKGRuleObject rule(rules.at(i)); SKGTESTERROR(QStringLiteral("RULE:execute"), rule.execute(), true); } } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_OFX"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestimportofx/ofx_spec201_stmtrs_example.ofx")); imp1.setAutomaticApplyRules(true); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestunit.cpp b/tests/skgbankmodelertest/skgtestunit.cpp index ab80b4601..a4d94a82b 100644 --- a/tests/skgbankmodelertest/skgtestunit.cpp +++ b/tests/skgbankmodelertest/skgtestunit.cpp @@ -1,441 +1,441 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbankincludes.h" #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { QStringList sources = SKGUnitObject::downloadSources(); SKGTESTBOOL("UNIT:downloadSources", (sources.count() >= 4), true); for (const QString& source : sources) { SKGUnitObject::getCommentFromSource(source); } // Test unit et unitvalue SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGTEST(QStringLiteral("UNIT:getNbTransaction"), document1.getNbTransaction(), 0); // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("BANK_T1"), err); // Create unit SKGUnitObject unit1(&document1); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("UNIT1")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("F")), true); SKGTEST(QStringLiteral("UNIT:getSymbol"), unit1.getSymbol(), QStringLiteral("F")); SKGTESTERROR(QStringLiteral("UNIT:setCountry"), unit1.setCountry(QStringLiteral("France")), true); SKGTEST(QStringLiteral("UNIT:getSymbol"), unit1.getCountry(), QStringLiteral("France")); SKGTESTERROR(QStringLiteral("UNIT:setInternetCode"), unit1.setInternetCode(QStringLiteral("code Internet")), true); SKGTEST(QStringLiteral("UNIT:getInternetCode"), unit1.getInternetCode(), QStringLiteral("code Internet")); SKGTESTERROR(QStringLiteral("UNIT:setType"), unit1.setType(SKGUnitObject::OBJECT), true); SKGTEST(QStringLiteral("UNIT:getType"), static_cast(unit1.getType()), static_cast(SKGUnitObject::OBJECT)); SKGTESTERROR(QStringLiteral("UNIT:setNumberDecimal"), unit1.setNumberDecimal(4), true); SKGTEST(QStringLiteral("UNIT:getNumberDecimal"), unit1.getNumberDecimal(), 4); SKGUnitValueObject unitvalue1; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit1.addUnitValue(unitvalue1), false); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); // Create unit value SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit1.addUnitValue(unitvalue1), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unitvalue1.setQuantity(119999.11), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unitvalue1.setDate(SKGServices::stringToTime(QStringLiteral("1970-07-16")).date()), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unitvalue1.save(), true); SKGUnitValueObject unitvalue1bis = SKGUnitValueObject(unitvalue1); SKGUnitValueObject unitvalue1ter = SKGUnitValueObject(static_cast(unitvalue1)); SKGUnitValueObject unitvalue14(SKGNamedObject(&document1, QStringLiteral("xxx"), unitvalue1.getID())); SKGUnitObject unit_get; SKGTESTERROR(QStringLiteral("UNITVALUE:getUnit"), unitvalue1.getUnit(unit_get), true); SKGTESTBOOL("UNIT:comparison", (unit_get == unit1), true); SKGUnitValueObject unitvalue2; SKGTESTERROR(QStringLiteral("UNIT:addUnitValue"), unit1.addUnitValue(unitvalue2), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setQuantity"), unitvalue2.setQuantity(34.12), true); SKGTESTERROR(QStringLiteral("UNITVALUE:setDate"), unitvalue2.setDate(SKGServices::stringToTime(QStringLiteral("1973-02-04")).date()), true); SKGTESTERROR(QStringLiteral("UNITVALUE:save"), unitvalue2.save(), true); // Retrieve unit SKGNamedObject unit2Named; SKGTESTERROR(QStringLiteral("UNIT:getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("unit"), QStringLiteral("UNIT1"), unit2Named), true); SKGUnitObject unit2(unit2Named); // Retrieve unit value SKGUnitValueObject unitvalue3; SKGTESTERROR(QStringLiteral("UNIT:getLastUnitValue"), unit2.getLastUnitValue(unitvalue3), true); SKGUnitValueObject unitvalue19700101; SKGTESTERROR(QStringLiteral("UNIT:getUnitValue"), unit2.getUnitValue(SKGServices::stringToTime(QStringLiteral("1970-01-01")).date(), unitvalue19700101), true); SKGUnitValueObject unitvalue19700716; SKGTESTERROR(QStringLiteral("UNIT:getUnitValue"), unit2.getUnitValue(SKGServices::stringToTime(QStringLiteral("1970-07-16")).date(), unitvalue19700716), true); SKGUnitValueObject unitvalue19720716; SKGTESTERROR(QStringLiteral("UNIT:getUnitValue"), unit2.getUnitValue(SKGServices::stringToTime(QStringLiteral("1972-07-16")).date(), unitvalue19720716), true); SKGUnitValueObject unitvalue19730204; SKGTESTERROR(QStringLiteral("UNIT:getUnitValue"), unit2.getUnitValue(SKGServices::stringToTime(QStringLiteral("1973-02-04")).date(), unitvalue19730204), true); SKGUnitValueObject unitvalue19750204; SKGTESTERROR(QStringLiteral("UNIT:getUnitValue"), unit2.getUnitValue(SKGServices::stringToTime(QStringLiteral("1975-02-04")).date(), unitvalue19750204), true); // Check unit value SKGTESTBOOL("UNITVALUE:==", (unitvalue3 == unitvalue2), true); SKGTESTBOOL("UNITVALUE:==", (unitvalue19700101 == unitvalue1), true); SKGTESTBOOL("UNITVALUE:==", (unitvalue19700716 == unitvalue1), true); SKGTESTBOOL("UNITVALUE:==", (unitvalue19720716 == unitvalue1), true); SKGTESTBOOL("UNITVALUE:==", (unitvalue19730204 == unitvalue2), true); SKGTESTBOOL("UNITVALUE:==", (unitvalue19750204 == unitvalue2), true); SKGTEST(QStringLiteral("UNITVALUE:getQuantity"), unitvalue1.getQuantity() - 119999.11, 0); SKGTEST(QStringLiteral("UNITVALUE:getQuantity"), unitvalue3.getQuantity() - 34.12, 0); SKGTEST(QStringLiteral("UNITVALUE:getDate"), SKGServices::dateToSqlString(QDateTime(unitvalue3.getDate())), QStringLiteral("1973-02-04")); // Check cascading delete SKGTESTERROR(QStringLiteral("UNIT:delete"), unit2.remove(), true); QStringList oResult; SKGTESTERROR(QStringLiteral("UNIT:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unit"), QStringLiteral("id"), oResult), true); SKGTEST(QStringLiteral("UNIT:oResult.size"), oResult.size(), 0); SKGTESTERROR(QStringLiteral("UNITVALUE:getDistinctValues"), document1.getDistinctValues(QStringLiteral("unitvalue"), QStringLiteral("rd_unit_id"), oResult), true); SKGTEST(QStringLiteral("UNITVALUE:oResult.size"), oResult.size(), 0); // Merge SKGTESTERROR(QStringLiteral("UNIT:merge"), unit1.merge(unit2), true); } { // Test unit et unitvalue SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGTEST(QStringLiteral("DOC:getPrimaryUnit"), document1.getPrimaryUnit().Symbol, QLatin1String("")); SKGTEST(QStringLiteral("DOC:getSecondaryUnit"), document1.getSecondaryUnit().Symbol, QLatin1String("")); SKGUnitObject franc(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT_1"), err); // Create unit SKGTESTERROR(QStringLiteral("FRANC:setName"), franc.setName(QStringLiteral("F")), true); SKGTESTERROR(QStringLiteral("FRANC:setSymbol"), franc.setSymbol(QStringLiteral("F")), true); SKGTESTERROR(QStringLiteral("FRANC:setType"), franc.setType(SKGUnitObject::PRIMARY), true); SKGTEST(QStringLiteral("FRANC:getType"), static_cast(franc.getType()), static_cast(SKGUnitObject::PRIMARY)); SKGTESTERROR(QStringLiteral("FRANC:save"), franc.save(), true); SKGTEST(QStringLiteral("DOC:getPrimaryUnit"), document1.getPrimaryUnit().Symbol, QStringLiteral("F")); } SKGTEST(QStringLiteral("DOC:getPrimaryUnit"), document1.getPrimaryUnit().Symbol, QStringLiteral("F")); SKGTEST(QStringLiteral("DOC:getSecondaryUnit"), document1.getSecondaryUnit().Symbol, QLatin1String("")); SKGTEST(QStringLiteral("DOC:getSecondaryUnit"), document1.getSecondaryUnit().Value, 1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT_2"), err); SKGUnitObject euro(&document1); SKGTESTERROR(QStringLiteral("EURO:setName"), euro.setName(QStringLiteral("E")), true); SKGTESTERROR(QStringLiteral("EURO:setSymbol"), euro.setSymbol(QStringLiteral("E")), true); SKGTESTERROR(QStringLiteral("EURO:setType"), euro.setType(SKGUnitObject::PRIMARY), true); SKGTEST(QStringLiteral("EURO:getType"), static_cast(euro.getType()), static_cast(SKGUnitObject::PRIMARY)); SKGTESTERROR(QStringLiteral("EURO:save"), euro.save(), true); SKGTESTERROR(QStringLiteral("FRANC:load"), franc.load(), true); SKGTEST(QStringLiteral("FRANC:getType"), static_cast(franc.getType()), static_cast(SKGUnitObject::SECONDARY)); SKGTEST(QStringLiteral("EURO:getType"), static_cast(euro.getType()), static_cast(SKGUnitObject::PRIMARY)); SKGTESTERROR(QStringLiteral("EURO:save"), euro.save(), true); } SKGTEST(QStringLiteral("DOC:getPrimaryUnit"), document1.getPrimaryUnit().Symbol, QStringLiteral("E")); SKGTEST(QStringLiteral("DOC:getSecondaryUnit"), document1.getSecondaryUnit().Symbol, QStringLiteral("F")); } { // Test unit et unitvalue SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { QStringList units = SKGUnitObject::getListofKnownCurrencies(false); SKGTEST(QStringLiteral("UNIT:getListofKnownCurrencies"), units.count(), 276); units = SKGUnitObject::getListofKnownCurrencies(true); SKGTEST(QStringLiteral("UNIT:getListofKnownCurrencies"), units.count(), 316); for (const auto& unit : qAsConst(units)) { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT_1"), err); SKGUnitObject unitObj; SKGTESTERROR(QStringLiteral("UNIT:createCurrencyUnit-") % unit, SKGUnitObject::createCurrencyUnit(&document1, unit, unitObj), true); unitObj.getUnitInfo(); } SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT_1"), err); SKGUnitObject unitObj; SKGTESTERROR(QStringLiteral("UNIT:createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("ZZZZZZZ"), unitObj), false); } } { // Compute unit amount at a date SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); SKGUnitObject unit2(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2001-01-01")).date(), 1), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2006-01-01")).date(), 6), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2007-01-01")).date(), 7), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2008-01-01")).date(), 8), true); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit2.setName(QStringLiteral("U2")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit2.setSymbol(QStringLiteral("U2")), true); SKGTESTERROR(QStringLiteral("UNIT:removeUnit"), unit2.removeUnit(), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit2.save(), true); SKGTESTERROR(QStringLiteral("UNIT:setUnit"), unit2.setUnit(unit2), false); SKGTESTERROR(QStringLiteral("UNIT:setUnit"), unit2.setUnit(unit1), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit2.save(), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U2"), SKGServices::stringToTime(QStringLiteral("2001-02-01")).date(), 10), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U2"), SKGServices::stringToTime(QStringLiteral("2006-01-01")).date(), 60), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U2"), SKGServices::stringToTime(QStringLiteral("2007-02-01")).date(), 70), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U2"), SKGServices::stringToTime(QStringLiteral("2008-01-01")).date(), 80), true); } SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2001-01-01")).date()), 1); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2001-02-01")).date()), 1); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2006-01-01")).date()), 6); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2006-02-01")).date()), 6); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2007-01-01")).date()), 7); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2007-02-01")).date()), 7); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2008-01-01")).date()), 8); SKGTEST(QStringLiteral("DOC:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2008-02-01")).date()), 8); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2001-01-01")).date()), 1 * 10); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2001-02-01")).date()), 1 * 10); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2006-01-01")).date()), 6 * 60); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2006-02-01")).date()), 6 * 60); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2007-01-01")).date()), 7 * 60); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2007-02-01")).date()), 7 * 70); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2008-01-01")).date()), 8 * 80); SKGTEST(QStringLiteral("DOC:getAmount"), unit2.getAmount(SKGServices::stringToTime(QStringLiteral("2008-02-01")).date()), 8 * 80); SKGTESTERROR(QStringLiteral("UNIT:load"), unit1.load(), true); SKGTESTERROR(QStringLiteral("UNIT:load"), unit2.load(), true); SKGTEST(QStringLiteral("DOC:convert"), SKGUnitObject::convert(100, unit1, unit1), 100); SKGTEST(QStringLiteral("DOC:convert"), SKGUnitObject::convert(100, unit1, unit2), 1.25); } { // Split unit SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2001-01-01")).date(), 100), true); } { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT-SPLIT"), err); SKGTESTERROR(QStringLiteral("DOC:getAmount"), unit1.split(-2), false); SKGTESTERROR(QStringLiteral("DOC:getAmount"), unit1.split(2), true); } SKGTESTERROR(QStringLiteral("UNIT:load"), unit1.load(), true); SKGTEST(QStringLiteral("UNIT:getAmount"), unit1.getAmount(SKGServices::stringToTime(QStringLiteral("2001-01-01")).date()), 50); } { // Unit Daily change SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-01-01")).date(), 100), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-01-02")).date(), 105), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-02-01")).date(), 110), true); } SKGTEST(QStringLiteral("UNIT:getDailyChange"), SKGServices::intToString(365 * unit1.getDailyChange(SKGServices::stringToTime(QStringLiteral("2009-01-02")).date())), QStringLiteral("1825")); SKGTEST(QStringLiteral("UNIT:getDailyChange"), SKGServices::intToString(365 * unit1.getDailyChange(SKGServices::stringToTime(QStringLiteral("2009-02-01")).date())), QStringLiteral("80")); } { // Unit download SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("DS")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("DS")), true); SKGTESTERROR(QStringLiteral("UNIT:setDownloadSource"), unit1.setDownloadSource(QStringLiteral("Yahoo")), true); SKGTESTERROR(QStringLiteral("UNIT:setInternetCode"), unit1.setInternetCode(QStringLiteral("DSY.PA")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::ALL_DAILY, 20), true); SKGObjectBase::SKGListSKGObjectBase values; SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), unit1.getUnitValues(values), true); SKGTESTBOOL("UNIT:getUnitValues", (!values.isEmpty()), true); // All download modes SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::LAST_WEEKLY, 20), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::LAST_DAILY, 20), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::LAST_MONTHLY, 20), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::ALL_MONTHLY, 20), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::ALL_WEEKLY, 20), true); SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), unit1.getUnitValues(values), true); SKGTESTBOOL("UNIT:getUnitValues", static_cast(values.count() > 1), static_cast(true)); QUrl url; unit1.getUrl(url); // For coverage } } { // Unit download SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("FORMULA")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("FORMULA")), true); SKGTESTERROR(QStringLiteral("UNIT:setInternetCode"), unit1.setInternetCode(QStringLiteral("=5")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::ALL_DAILY, 20), true); SKGObjectBase::SKGListSKGObjectBase values; SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), unit1.getUnitValues(values), true); SKGTESTBOOL("UNIT:getUnitValues", (!values.isEmpty()), true); } } { // Unit download SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("Bitcoin"), unit1), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), unit1.downloadUnitValue(SKGUnitObject::LAST), true); SKGObjectBase::SKGListSKGObjectBase values; SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), unit1.getUnitValues(values), true); SKGTESTBOOL("UNIT:getUnitValues", (!values.isEmpty()), true); } } { // Unit download SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGUnitObject euro; SKGTESTERROR(QStringLiteral("UNIT:createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("EUR"), euro), true); SKGUnitObject fr; SKGTESTERROR(QStringLiteral("UNIT:createCurrencyUnit"), SKGUnitObject::createCurrencyUnit(&document1, QStringLiteral("GBP"), fr), true); SKGTESTERROR(QStringLiteral("UNIT:downloadUnitValue"), fr.downloadUnitValue(SKGUnitObject::LAST), true); SKGObjectBase::SKGListSKGObjectBase values; SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), fr.getUnitValues(values), true); SKGTESTBOOL("UNIT:getUnitValues", values.isEmpty(), false); } } { // Unit simplify SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; SKGUnitObject unit1(&document1); { SKGBEGINTRANSACTION(document1, QStringLiteral("UNIT"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.setName(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:setSymbol"), unit1.setSymbol(QStringLiteral("U1")), true); SKGTESTERROR(QStringLiteral("UNIT:save"), unit1.save(), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addDays(-7), 1), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addDays(-6), 2), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addDays(-5), 3), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addMonths(-3).addDays(-7), 1), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addMonths(-3).addDays(-6), 2), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addMonths(-3).addDays(-5), 3), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addYears(-1).addDays(-7), 1), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addMonths(-1).addDays(-6), 2), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), QDate::currentDate().addMonths(-1).addDays(-5), 3), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-01-01")).date(), 1), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-01-02")).date(), 2), true); SKGTESTERROR(QStringLiteral("UNIT:addOrModifyUnitValue"), document1.addOrModifyUnitValue(QStringLiteral("U1"), SKGServices::stringToTime(QStringLiteral("2009-01-03")).date(), 3), true); } { SKGBEGINTRANSACTION(document1, QStringLiteral("SYMPLIFY"), err); SKGTESTERROR(QStringLiteral("UNIT:setName"), unit1.simplify(), true); } SKGObjectBase::SKGListSKGObjectBase oUnitValueList; SKGTESTERROR(QStringLiteral("UNIT:getUnitValues"), unit1.getUnitValues(oUnitValueList), true); SKGTESTBOOL("UNIT:oUnitValueList", (oUnitValueList.count() == 10 || oUnitValueList.count() == 11), true); } { SKGTESTERROR(QStringLiteral("UNIT:addSource"), SKGUnitObject::addSource(QStringLiteral("test"), false), true); SKGTESTBOOL("UNIT:isWritable", SKGUnitObject::isWritable(QStringLiteral("test")), true); SKGTESTERROR(QStringLiteral("UNIT:deleteSource"), SKGUnitObject::deleteSource(QStringLiteral("test")), true); SKGTESTERROR(QStringLiteral("UNIT:deleteSource"), SKGUnitObject::deleteSource(QStringLiteral("notfound")), false); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbankmodelertest/skgtestvariousbugs.cpp b/tests/skgbankmodelertest/skgtestvariousbugs.cpp index 5d0e1728a..802729504 100644 --- a/tests/skgbankmodelertest/skgtestvariousbugs.cpp +++ b/tests/skgbankmodelertest/skgtestvariousbugs.cpp @@ -1,161 +1,161 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" #include "skgbankincludes.h" #include "skgimportexportmanager.h" #include "skgimportplugin.h" #include "skgreportbank.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { // Test bug 324649 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/324649.skg"), true); // Check { auto* report = qobject_cast(document1.getReport()); report->setPeriod(QStringLiteral("2013-09")); QVariantList values = report->getBankTable(); SKGTEST(QStringLiteral("324649:getCurrentAmount"), values.count(), 4); SKGTEST(QStringLiteral("324649:title"), values[0].toList()[0].toString(), QStringLiteral("sum")); SKGTEST(QStringLiteral("324649:10"), values[1].toList()[2].toString(), QStringLiteral("20")); SKGTEST(QStringLiteral("324649:20"), values[2].toList()[2].toString(), QStringLiteral("10")); SKGTEST(QStringLiteral("324649:30"), values[3].toList()[2].toString(), QStringLiteral("30")); } } { // Test bug 324972 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.initialize()"), document1.initialize(), true); SKGError err; { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_CSV"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/324972_1.csv")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); } { // Scope of the transaction SKGBEGINTRANSACTION(document1, QStringLiteral("IMPORT_CSV"), err); SKGImportExportManager imp1(&document1, QUrl::fromLocalFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/324972_2.csv")); SKGTESTERROR(QStringLiteral("imp1.importFile"), imp1.importFile(), true); SKGDocument::SKGMessageList messages; SKGTESTERROR(QStringLiteral("DOC.getMessages"), document1.getMessages(document1.getCurrentTransaction(), messages, true), true); bool test = false; for (const auto& msg : qAsConst(messages)) { SKGTRACE << "Message:" << msg.Text << endl; if (msg.Text.contains(QStringLiteral("last imported one"))) { test = true; } } SKGTEST(QStringLiteral("message.last imported one"), static_cast(test), 1); } SKGAccountObject account; SKGTESTERROR(QStringLiteral("ACCOUNT.getObjectByName"), SKGNamedObject::getObjectByName(&document1, QStringLiteral("v_account"), QStringLiteral("My account"), account), true); SKGTESTERROR(QStringLiteral("ACCOUNT.load"), account.load(), true); SKGTEST(QStringLiteral("ACCOUNT:getCurrentAmount"), SKGServices::doubleToString(account.getCurrentAmount()), QStringLiteral("1000")); } { // Test import Weboob SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/interests_and_shares.skg"), true); // Check { SKGAccountObject act(&document1); SKGTESTERROR(QStringLiteral("account.setName()"), act.setName(QStringLiteral("TEST")), true); SKGTESTERROR(QStringLiteral("account.load()"), act.load(), true); SKGAccountObject::SKGInterestItemList oInterestList; double oInterests; SKGTESTERROR(QStringLiteral("account.getInterestItems()"), act.getInterestItems(oInterestList, oInterests, 2013), true); SKGTEST(QStringLiteral("oInterestList"), oInterestList.count(), 4); SKGTEST(QStringLiteral("oInterests"), static_cast(oInterests > 3.20 && oInterests < 3.22), 1); SKGTESTERROR(QStringLiteral("account.getInterestItems()"), act.getInterestItems(oInterestList, oInterests, 2014), true); } } { // Test open invalid files SKGDocumentBank document1; SKGTEST(QStringLiteral("document1.load(interests_and_shares.skg,notneededpassword)"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/interests_and_shares.skg", QStringLiteral("notneededpassword")).getReturnCode(), 0); SKGTEST(QStringLiteral("document1.load(invalid.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/invalid.skg").getReturnCode(), ERR_CORRUPTION); SKGTEST(QStringLiteral("document1.load(invalid_protected.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/invalid_protected.skg").getReturnCode(), ERR_ENCRYPTION); SKGTEST(QStringLiteral("document1.load(protected.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/protected.skg").getReturnCode(), ERR_ENCRYPTION); SKGTEST(QStringLiteral("document1.load(protected.skg, pwd)"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/protected.skg", QStringLiteral("pwd")).getReturnCode(), 0); SKGTEST(QStringLiteral("document1.load(forrecovery.skg)"), document1.load(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestvariousbugs/forrecovery.skg").getReturnCode(), ERR_CORRUPTION); QString recoveredFile; SKGTESTERROR(QStringLiteral("document1.recover(forrecovery.skg)"), document1.recover(SKGTest::getTestPath(QStringLiteral("OUT")) % "/skgtestvariousbugs/forrecovery.skg", QLatin1String(""), recoveredFile), true); SKGTEST(QStringLiteral("document1.load(forrecovery_recovered.skg)"), document1.load(recoveredFile).getReturnCode(), 0); } { // Test 329568 SKGDocumentBank document1; SKGTESTERROR(QStringLiteral("document1.load()"), document1.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/skgtestvariousbugs/329568.skg"), true); // Check { SKGAccountObject act(&document1); SKGTESTERROR(QStringLiteral("account.setName()"), act.setName(QStringLiteral("T")), true); SKGTESTERROR(QStringLiteral("account.load()"), act.load(), true); SKGAccountObject::SKGInterestItemList oInterestList; double oInterests; SKGTESTERROR(QStringLiteral("account.getInterestItems()"), act.getInterestItems(oInterestList, oInterests, 2014), true); SKGTEST(QStringLiteral("oInterestList"), oInterestList.count(), 4); SKGTEST(QStringLiteral("oInterests"), static_cast(oInterests > 8.20 && oInterests < 8.22), 1); } { auto imp1 = new SKGImportPlugin(); SKGTESTERROR(QStringLiteral("SKGImportPlugin.importFile"), imp1->importFile(), false); SKGTESTERROR(QStringLiteral("SKGImportPlugin.exportFile"), imp1->exportFile(), false); imp1->getMimeTypeFilter(); delete imp1; } } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbasemodelertest/skgtestbase.cpp b/tests/skgbasemodelertest/skgtestbase.cpp index 5796a8835..cff51fe0c 100644 --- a/tests/skgbasemodelertest/skgtestbase.cpp +++ b/tests/skgbasemodelertest/skgtestbase.cpp @@ -1,722 +1,730 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ void test_getPeriodWhereClause(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("2014")), QStringLiteral("STRFTIME('%Y',d_date)='2014'")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("2014-02")), QStringLiteral("STRFTIME('%Y-%m',d_date)='2014-02'")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("2014-10")), QStringLiteral("STRFTIME('%Y-%m',d_date)='2014-10'")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("2014-Q2")), QStringLiteral("STRFTIME('%Y',d_date)||'-Q'||(CASE WHEN STRFTIME('%m',d_date)<='03' THEN '1' WHEN STRFTIME('%m',d_date)<='06' THEN '2' WHEN STRFTIME('%m',d_date)<='09' THEN '3' ELSE '4' END)='2014-Q2'")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("2014-S2")), QStringLiteral("STRFTIME('%Y',d_date)||'-S'||(CASE WHEN STRFTIME('%m',d_date)<='06' THEN '1' ELSE '2' END)='2014-S2'")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("INVALID STRING")), QStringLiteral("1=0")); SKGTEST(QStringLiteral("CONV:getPeriodWhereClause"), SKGServices::getPeriodWhereClause(QStringLiteral("ALL")), QStringLiteral("1=1")); } void test_getNeighboringPeriod(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014")), QStringLiteral("2013")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-10")), QStringLiteral("2014-09")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-01")), QStringLiteral("2013-12")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-Q2")), QStringLiteral("2014-Q1")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-Q1")), QStringLiteral("2013-Q4")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-S2")), QStringLiteral("2014-S1")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-S1")), QStringLiteral("2013-S2")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("INVALID STRING")), QStringLiteral("1=0")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod"), SKGServices::getNeighboringPeriod(QStringLiteral("ALL")), QStringLiteral("1=0")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014"), 1), QStringLiteral("2015")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-10"), 1), QStringLiteral("2014-11")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-01"), 1), QStringLiteral("2014-02")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-Q4"), 1), QStringLiteral("2015-Q1")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-Q2"), 1), QStringLiteral("2014-Q3")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-Q1"), 1), QStringLiteral("2014-Q2")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-S2"), 1), QStringLiteral("2015-S1")); SKGTEST(QStringLiteral("CONV:getNeighboringPeriod +1"), SKGServices::getNeighboringPeriod(QStringLiteral("2014-S1"), 1), QStringLiteral("2014-S2")); } void test_periodToDate(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014")).toString(), QDate(2014, 12, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-S1")).toString(), QDate(2014, 6, 30).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-S2")).toString(), QDate(2014, 12, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-Q1")).toString(), QDate(2014, 3, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-Q2")).toString(), QDate(2014, 6, 30).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-Q3")).toString(), QDate(2014, 9, 30).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-Q4")).toString(), QDate(2014, 12, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-01")).toString(), QDate(2014, 1, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("2014-07")).toString(), QDate(2014, 7, 31).toString()); SKGTEST(QStringLiteral("CONV:periodToDate"), SKGServices::periodToDate(QStringLiteral("ALL")).toString(), QDate::currentDate().toString()); } void test_partialStringToDate(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("INVALID"), true).toString(), QLatin1String("")); QDate currentMonth10 = QDate::currentDate(); currentMonth10 = currentMonth10.addDays(10 - QDate::currentDate().day()); QDate current0102(QDate::currentDate().year(), 2, 1); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("10"), true).toString(), (currentMonth10 <= QDate::currentDate() ? currentMonth10 : currentMonth10.addMonths(-1)).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2"), true).toString(), (current0102 <= QDate::currentDate() ? current0102 : current0102.addYears(-1)).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/14"), true).toString(), QDate(2014, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/99"), true).toString(), QDate(1999, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/014"), true).toString(), QDate(2014, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/199"), true).toString(), QDate(1199, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/1014"), true).toString(), QDate(1014, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/2222"), true).toString(), QDate(2222, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("10"), false).toString(), (currentMonth10 >= QDate::currentDate() ? currentMonth10 : currentMonth10.addMonths(1)).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2"), false).toString(), (current0102 >= QDate::currentDate() ? current0102 : current0102.addYears(1)).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/14"), false).toString(), QDate(2114, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/99"), false).toString(), QDate(2099, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/014"), false).toString(), QDate(3014, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/199"), false).toString(), QDate(2199, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/1014"), false).toString(), QDate(1014, 2, 1).toString()); SKGTEST(QStringLiteral("CONV:partialStringToDate"), SKGServices::partialStringToDate(QStringLiteral("1/2/2222"), false).toString(), QDate(2222, 2, 1).toString()); } void test_conversions(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("D")), QStringLiteral("2013-03-05")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 01, 01), QStringLiteral("W")), QStringLiteral("2013-W01")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("W")), QStringLiteral("2013-W10")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("M")), QStringLiteral("2013-03")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("Q")), QStringLiteral("2013-Q1")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("S")), QStringLiteral("2013-S1")); SKGTEST(QStringLiteral("CONV:dateToPeriod"), SKGServices::dateToPeriod(QDate(2013, 03, 05), QStringLiteral("Y")), QStringLiteral("2013")); SKGTEST(QStringLiteral("CONV:intToString"), SKGServices::intToString(10), QStringLiteral("10")); SKGTEST(QStringLiteral("CONV:intToString"), SKGServices::intToString(5490990004), QStringLiteral("5490990004")); SKGTEST(QStringLiteral("CONV:stringToInt"), SKGServices::stringToInt(QStringLiteral("56")), 56); SKGTEST(QStringLiteral("CONV:stringToInt"), SKGServices::stringToInt(QStringLiteral("HELLO")), 0); SKGTEST(QStringLiteral("CONV:stringToInt"), SKGServices::stringToInt(QStringLiteral("5HELLO")), 0); SKGTEST(QStringLiteral("CONV:stringToInt"), SKGServices::stringToInt(QStringLiteral("5490990004")), 5490990004); SKGTEST(QStringLiteral("CONV:doubleToString"), SKGServices::doubleToString(10), QStringLiteral("10")); SKGTEST(QStringLiteral("CONV:doubleToString"), SKGServices::doubleToString(5.3), QStringLiteral("5.3")); SKGTEST(QStringLiteral("CONV:doubleToString"), SKGServices::doubleToString(11111115.33), QStringLiteral("11111115.33")); SKGTEST(QStringLiteral("CONV:doubleToString"), SKGServices::doubleToString(119999.11), QStringLiteral("119999.11")); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("10")) - 10, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("5.3")) - 5.3, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("11111115.33")) - 11111115.33, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("25,000.00")) - 25000.00, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("1.307,40")) - 1307.40, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("2 150,10")) - 2150.10, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("-$8.35")) + 8.35, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("8.35€")) - 8.35, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("1234.56e-02")) - 12.3456, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("31238/100")) - 312.38, 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("31238/abc")), 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("nan")), 0); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("inf")), 1e300); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("-inf")), -1e300); SKGTEST(QStringLiteral("CONV:stringToDouble"), SKGServices::stringToDouble(QStringLiteral("00000000194065")), 194065); SKGServices::timeToString(QDateTime()); SKGTEST(QStringLiteral("CONV:stringToTime"), SKGServices::timeToString(SKGServices::stringToTime(QStringLiteral("1970-07-16"))), QStringLiteral("1970-07-16 00:00:00")); SKGTEST(QStringLiteral("CONV:stringToTime"), SKGServices::timeToString(SKGServices::stringToTime(QStringLiteral("2008-04-20"))), QStringLiteral("2008-04-20 00:00:00")); SKGTEST(QStringLiteral("CONV:stringToTime"), SKGServices::dateToSqlString(SKGServices::stringToTime(QStringLiteral("1970-07-16"))), QStringLiteral("1970-07-16")); SKGTEST(QStringLiteral("CONV:stringToTime"), SKGServices::dateToSqlString(SKGServices::stringToTime(QStringLiteral("2008-04-20"))), QStringLiteral("2008-04-20")); SKGTESTBOOL("CONV:SKGServices::getMicroTime", (SKGServices::getMicroTime() > 0), true); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("20080525"), QStringLiteral("YYYYMMDD")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("2008-05-25"), QStringLiteral("YYYY-MM-DD")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("2008-05-25 00:00:00"), QStringLiteral("YYYY-MM-DD")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("05/25/08"), QStringLiteral("MM/DD/YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("05/25/78"), QStringLiteral("MM/DD/YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("05-25-08"), QStringLiteral("MM-DD-YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("05-25-78"), QStringLiteral("MM-DD-YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5/25/08"), QStringLiteral("MM/DD/YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5/25/78"), QStringLiteral("MM/DD/YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-25-08"), QStringLiteral("MM-DD-YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-6-08"), QStringLiteral("MM-DD-YY")), QStringLiteral("2008-05-06")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-25-78"), QStringLiteral("MM-DD-YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25/05/08"), QStringLiteral("DD/MM/YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25/05/78"), QStringLiteral("DD/MM/YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25-05-08"), QStringLiteral("DD-MM-YY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25-05-78"), QStringLiteral("DD-MM-YY")), QStringLiteral("1978-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25/05/2008"), QStringLiteral("DD/MM/YYYY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("25-05-2008"), QStringLiteral("DD-MM-YYYY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5/25/2008"), QStringLiteral("MM/DD/YYYY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-25-2008"), QStringLiteral("MM-DD-YYYY")), QStringLiteral("2008-05-25")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-6-2008"), QStringLiteral("MM-DD-YYYY")), QStringLiteral("2008-05-06")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("5-6-8"), QStringLiteral("MM-DD-YYYY")), QStringLiteral("2008-05-06")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("3.21.01"), QStringLiteral("MM-DD-YY")), QStringLiteral("2001-03-21")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("1/ 1' 6"), QStringLiteral("DD-MM-YY")), QStringLiteral("2006-01-01")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("6/ 1/94"), QStringLiteral("DD-MM-YY")), QStringLiteral("1994-01-06")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("21/12'2001"), QStringLiteral("DD-MM-YYYY")), QStringLiteral("2001-12-21")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("21122001"), QStringLiteral("DDMMYYYY")), QStringLiteral("2001-12-21")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("12212001"), QStringLiteral("MMDDYYYY")), QStringLiteral("2001-12-21")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("010203"), QStringLiteral("MMDDYY")), QStringLiteral("2003-01-02")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("010203"), QStringLiteral("DDMMYY")), QStringLiteral("2003-02-01")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("3/9/04"), QStringLiteral("DD-MM-YY")), QStringLiteral("2004-09-03")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31Dec2005"), QStringLiteral("DDMMMYYYY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31-Dec-2005"), QStringLiteral("DD-MMM-YYYY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31/Dec/2005"), QStringLiteral("DD/MMM/YYYY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31Dec05"), QStringLiteral("DDMMMYY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31-Dec-05"), QStringLiteral("DD-MMM-YY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31/Dec/05"), QStringLiteral("DD/MMM/YY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("31DEC2005"), QStringLiteral("DDMMMYYYY")), QStringLiteral("2005-12-31")); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("INVALIDDATE"), QStringLiteral("DD-MM-YY")), SKGServices::dateToSqlString(QDateTime::currentDateTime())); SKGTEST(QStringLiteral("STR:dateToSqlString"), SKGServices::dateToSqlString(QStringLiteral("02.01.2015"), QStringLiteral("DD-MM-YYYY")), QStringLiteral("2015-01-02")); } void test_nbWorkingDays(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("SKGServices::nbWorkingDays"), SKGServices::nbWorkingDays(QDate(2010, 9, 3), QDate(2010, 9, 6)), 1); SKGTEST(QStringLiteral("SKGServices::nbWorkingDays"), SKGServices::nbWorkingDays(QDate(2010, 9, 6), QDate(2010, 9, 3)), 1); SKGTEST(QStringLiteral("SKGServices::nbWorkingDays"), SKGServices::nbWorkingDays(QDate(2010, 9, 3), QDate(2010, 9, 3)), 1); SKGTEST(QStringLiteral("SKGServices::nbWorkingDays"), SKGServices::nbWorkingDays(QDate(2010, 9, 1), QDate(2010, 9, 3)), 2); SKGTEST(QStringLiteral("SKGServices::nbWorkingDays"), SKGServices::nbWorkingDays(QDate(2010, 9, 1), QDate(2010, 9, 8)), 5); } void test_getnext(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("SKGServices::getNextString"), SKGServices::getNextString(QStringLiteral("12345")), QStringLiteral("12346")); SKGTEST(QStringLiteral("SKGServices::getNextString"), SKGServices::getNextString(QStringLiteral("9")), QStringLiteral("10")); } void test_errors(int& nberror, int& nbcheck, bool showonlyfailures) { { SKGTraces::cleanProfilingStatistics(); SKGError err; SKGTEST(QStringLiteral("ERR:Default RC"), err.getReturnCode(), 0); SKGTEST(QStringLiteral("ERR:Default RC"), err.getReturnCode(), 0); SKGTESTBOOL("ERR:isWarning", err.isWarning(), false); SKGTESTBOOL("ERR:isSucceeded", err.isSucceeded(), true); SKGTESTBOOL("ERR:isFailed", err.isFailed(), false); SKGTESTBOOL("ERR:!", !err, true); SKGTESTBOOL("ERR:operator bool", err, false); SKGTESTBOOL("ERR:getPreviousError", (err.getPreviousError() == nullptr), true); SKGTEST(QStringLiteral("ERR:Default message"), err.getMessage(), QLatin1String("")); err.setReturnCode(10); err.setMessage(QStringLiteral("Invalid parameter")); SKGTEST(QStringLiteral("ERR:getHistoricalSize"), err.getHistoricalSize(), 0); SKGTEST(QStringLiteral("ERR:RC 10"), err.getReturnCode(), 10); SKGTEST(QStringLiteral("ERR:MSG Invalid parameter"), err.getMessage(), QStringLiteral("Invalid parameter")); err.addError(11, QStringLiteral("Message 11")); SKGTESTBOOL("ERR:isWarning", err.isWarning(), false); SKGTESTBOOL("ERR:isSucceeded", err.isSucceeded(), false); SKGTESTBOOL("ERR:isFailed", err.isFailed(), true); SKGTESTBOOL("ERR:!", !err, false); SKGTESTBOOL("ERR:operator bool", err, true); SKGTEST(QStringLiteral("ERR:getHistoricalSize"), err.getHistoricalSize(), 1); err.addError(-12, QStringLiteral("Message 12")); SKGTESTBOOL("ERR:isWarning", err.isWarning(), true); SKGTESTBOOL("ERR:isSucceeded", err.isSucceeded(), true); SKGTESTBOOL("ERR:isFailed", err.isFailed(), false); SKGTESTBOOL("ERR:!", !err, true); SKGTESTBOOL("ERR:operator bool", err, false); SKGTEST(QStringLiteral("ERR:getHistoricalSize"), err.getHistoricalSize(), 2); SKGTEST(QStringLiteral("ERR:getFullMessageWithHistorical"), err.getFullMessageWithHistorical(), QStringLiteral("[WAR--12]: Message 12\n[ERR-11]: Message 11\n[ERR-10]: Invalid parameter")); } { SKGTraces::cleanProfilingStatistics(); SKGError err; err.setReturnCode(10).setMessage(QStringLiteral("Invalid parameter")).addError(11, QStringLiteral("Message 11")); SKGTEST(QStringLiteral("ERR:getHistoricalSize"), err.getHistoricalSize(), 1); SKGTEST(QStringLiteral("ERR:RC 10"), err.getReturnCode(), 11); SKGTEST(QStringLiteral("ERR:MSG Message 11"), err.getMessage(), QStringLiteral("Message 11")); } } void test_getDateFormat(int& nberror, int& nbcheck, bool showonlyfailures) { { QStringList dates; dates << QStringLiteral("19/08/2008"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("20080819"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("YYYYMMDD")); } { QStringList dates; dates << QStringLiteral("10141989"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("MMDDYYYY")); } { QStringList dates; dates << QStringLiteral("14101989"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DDMMYYYY")); } { QStringList dates; dates << QStringLiteral("05/08/2008") << QStringLiteral("19/08/2008"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("19/ 1' 6"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("21/12'2001"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("6/ 1/94"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("10.29.07"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("MM-DD-YY")); } { QStringList dates; dates << QStringLiteral("10.05.07"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YY")); } { QStringList dates; dates << QStringLiteral("2001.10.25"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("YYYY-MM-DD")); } { QStringList dates; dates << QStringLiteral("45450116"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("YYYYMMDD")); } { QStringList dates; dates << QStringLiteral("7/14' 0") << QStringLiteral("11/30/99"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("MM-DD-YYYY")); } { QStringList dates; dates << QStringLiteral("10/ 8'10"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YYYY")); } { QStringList dates; dates << QStringLiteral("7/8/06"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YY")); } { QStringList dates; dates << QStringLiteral("7/8/06") << QStringLiteral("11/30/99") << QStringLiteral("7/14' 0"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("MM-DD-YYYY")); } { QStringList dates; dates << QStringLiteral("3/9/04"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YY")); } { QStringList dates; dates << QStringLiteral("31Dec2005"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DDMMMYYYY")); } { QStringList dates; dates << QStringLiteral("31-Dec-05"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MMM-YY")); } { QStringList dates; dates << QStringLiteral("2008-05-25 00:00:00"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("YYYY-MM-DD")); } { QStringList dates; dates << QStringLiteral("2008-05-25 01:02:03"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("YYYY-MM-DD")); } { QStringList dates; QFile inputFile(SKGTest::getTestPath(QStringLiteral("IN")) % "/dates.txt"); if (inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); while (!in.atEnd()) { QString l = in.readLine().trimmed(); if (!l.isEmpty()) { dates << l; } } inputFile.close(); } SKGTEST(QStringLiteral("STR:dats.count"), dates.count(), 2364); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("MM-DD-YY")); } { QStringList dates; dates << QStringLiteral(" 7/8/06 ") << QLatin1String(""); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QStringLiteral("DD-MM-YY")); } { QStringList dates; dates << QStringLiteral("99999999") << QStringLiteral("9999999999"); SKGTEST(QStringLiteral("STR:getDateFormat"), SKGServices::getDateFormat(dates), QLatin1String("")); } } void test_csv(int& nberror, int& nbcheck, bool showonlyfailures) { SKGTEST(QStringLiteral("STR:stringToCsv"), SKGServices::stringToCsv(QStringLiteral("ABC")), QStringLiteral("\"ABC\"")); SKGTEST(QStringLiteral("STR:stringToCsv"), SKGServices::stringToCsv(QStringLiteral("ABC;CDE")), QStringLiteral("\"ABC;CDE\"")); SKGTEST(QStringLiteral("STR:stringToCsv"), SKGServices::stringToCsv(QStringLiteral("AB \"C\" DE")), QStringLiteral("\"AB \"\"C\"\" DE\"")); SKGTEST(QStringLiteral("STR:stringToCsv"), SKGServices::stringToCsv(QStringLiteral("AB \"C\";DE")), QStringLiteral("\"AB \"\"C\"\";DE\"")); QStringList parameters = SKGServices::splitCSVLine(QStringLiteral("52.33,\"9/28/2010\",52.36,231803,52.33,0.00,+0.15,-,0.00,-,0.00,0.00,0.00,0.00,\"- - -\",\"-\",-,\"n\",N/A,0,+15.82,+43.33%,9,672,-1.08,-2.02%,-,-,\"51.76 - 52.57\",0.00,0.00,N/A,N/A,N/A,N/A,\"-\",51.91,52.18,-,\"+0.29%\",N/A,N/A,\"N/A\",N/A,\"N/A\",N/A,N/A,N/A,-,N/A,\"11:35am\",N/A,211524,-,\"36.51 - 53.41\",\"- - +0.29%\",\"Paris\",N/A,\"DASSAULT SYST.\""), ','); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 59); parameters = SKGServices::splitCSVLine(QStringLiteral("2013-04-02;transfer;\"a2\";'some text 2';-20,13"), ';', true); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 5); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("2013-04-02")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("transfer")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[2], QStringLiteral("a2")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[3], QStringLiteral("some text 2")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[4], QStringLiteral("-20,13")); parameters = SKGServices::splitCSVLine(QStringLiteral("\"A;'B\";'A;\"B'"), ';', true); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A;'B")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("A;\"B")); SKGTEST(QStringLiteral("STR:stringToHtml"), SKGServices::stringToHtml(QStringLiteral("&")), QStringLiteral("<hello>&<world>")); SKGTEST(QStringLiteral("STR:htmlToString"), SKGServices::htmlToString(QStringLiteral("<hello>&<world>")), QStringLiteral("&")); parameters = SKGServices::splitCSVLine(SKGServices::stringToCsv(QStringLiteral("Y")) % ';' % SKGServices::stringToCsv(QStringLiteral("A;B"))); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("Y")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("A;B")); parameters = SKGServices::splitCSVLine(QStringLiteral("A;\"B;C\";D")); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 3); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("B;C")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[2], QStringLiteral("D")); parameters = SKGServices::splitCSVLine(QStringLiteral("'A';'B'")); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("B")); parameters = SKGServices::splitCSVLine(QStringLiteral("\"A ' B\",\"C\"")); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A ' B")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("C")); parameters = SKGServices::splitCSVLine(QStringLiteral("'A \" B','C'")); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A \" B")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("C")); QChar realsep; parameters = SKGServices::splitCSVLine(QStringLiteral("\"A\",18,\"B\""), ';', true, &realsep); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 3); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("18")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[2], QStringLiteral("B")); SKGTEST(QStringLiteral("STR:sep"), realsep, ','); parameters = SKGServices::splitCSVLine(QStringLiteral("30/05/2008;RETRAIT ESPECES AGENCE; ; 100,00;DEBIT;")); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 6); parameters = SKGServices::splitCSVLine(QStringLiteral("A|\"B\";\"C\""), '|', false); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 2); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("A")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("\"B\";\"C\"")); parameters = SKGServices::splitCSVLine(QStringLiteral("+123 \"-abc def\" \"e:f\" e:f"), ' ', true); SKGTEST(QStringLiteral("STR:splitCSVLine count"), parameters.count(), 4); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[0], QStringLiteral("+123")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[1], QStringLiteral("-abc def")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[2], QStringLiteral("e:f")); SKGTEST(QStringLiteral("STR:splitCSVLine"), parameters[3], QStringLiteral("e:f")); - SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("w1 w2"), ' ', true).count(), 2); - SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("\"w1 w1\""), ' ', true).count(), 1); - SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("\"w1 w1\" w2 \"w3 w3 w3\" w4"), ' ', true).count(), 4); + SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("w1 w2"), ' ', true).count(), 2) + SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("\"w1 w1\""), ' ', true).count(), 1) + SKGTEST(QStringLiteral("STR:splitCSVLine words"), SKGServices::splitCSVLine(QStringLiteral("\"w1 w1\" w2 \"w3 w3 w3\" w4"), ' ', true).count(), 4) + + QChar realseparator; + SKGTEST(QStringLiteral("STR:splitCSVLine comma"), SKGServices::splitCSVLine(QStringLiteral("date,payee,amount"), ';', true, &realseparator).count(), 1) + SKGTEST(QStringLiteral("STR:splitCSVLine comma"), realseparator, ';') + + QString t(QStringLiteral("Export Format, Date (YYYY-MM-DD as UTC), Time (HH:MM:SS), Merchant, Txn Amount (Funding Card), Txn Currency (Funding Card), Txn Amount (Foreign Spend), Txn Currency (Foreign Spend), Card Name, Card Last 4 Digits, Type, Category, Notes")); + SKGTEST(QStringLiteral("STR:splitCSVLine comma"), SKGServices::splitCSVLine(t, ';', true, &realseparator).count(), 1) + SKGTEST(QStringLiteral("STR:splitCSVLine comma"), SKGServices::splitCSVLine(t, ',', true, &realseparator).count(), 13) } void test_stringToSearchCriterias(int& nberror, int& nbcheck, bool showonlyfailures) { SKGServices::SKGSearchCriteriaList criterias = SKGServices::stringToSearchCriterias(QStringLiteral("abc +def +ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 3); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[1].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[1].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[1].words[0], QStringLiteral("def")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[2].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[2].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[2].words[0], QStringLiteral("abc")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("-abc +def ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("def")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[1], QStringLiteral("ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[1].mode, '-'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[1].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[1].words[0], QStringLiteral("abc")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("-abc +def ghi -10")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 3); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("def")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[1], QStringLiteral("ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[2], QStringLiteral("-10")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[1].mode, '-'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[1].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[1].words[0], QStringLiteral("abc")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("-10")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("-10")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("-abc")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QLatin1String("")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[1].mode, '-'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[1].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[1].words[0], QStringLiteral("abc")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("\"abc def ghi\" \"123 456\"")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("abc def ghi")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[1], QStringLiteral("123 456")); criterias = SKGServices::stringToSearchCriterias(QStringLiteral("\"-payee:abc def : ghi\" +amount:25")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias count"), criterias.count(), 2); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[0].mode, '+'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[0].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[0].words[0], QStringLiteral("amount:25")); SKGTEST(QStringLiteral("STR:stringToSearchCriterias mode"), criterias[1].mode, '-'); SKGTEST(QStringLiteral("STR:stringToSearchCriterias words count"), criterias[1].words.count(), 1); SKGTEST(QStringLiteral("STR:stringToSearchCriterias word"), criterias[1].words[0], QStringLiteral("payee:abc def : ghi")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(d_DATEOP) LIKE '%toto%' OR lower(i_number) LIKE '%toto%' OR lower(t_PAYEE) LIKE '%toto%' OR lower(t_bookmarked) LIKE '%toto%'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("i_num:ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(i_number) LIKE '%toto%'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("i_num=1234")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((i_number=1234))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_PAYEE>ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(t_PAYEE)>'toto'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_PAYEE=ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(t_PAYEE)>='toto'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_PAYEE<=ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(t_PAYEE)<='toto'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_PAYEE=ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(t_PAYEE)='toto'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_PAYEE#^t[o|a]to$")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((REGEXP('^t[o|a]to$',t_PAYEE)))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("+i_number<20 +i_number>30")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((i_number>30)) OR ((i_number<20))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("d_DATEOP>2015-05-04")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("((lower(d_DATEOP)>'2015-05-04'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("notfound:ToTo")), QStringList() << QStringLiteral("d_DATEOP") << QStringLiteral("i_number") << QStringLiteral("t_PAYEE") << QStringLiteral("t_bookmarked"), nullptr), QStringLiteral("(1=0)")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("v1 v2 +v3 -v4 -v5")), QStringList() << QStringLiteral("t_comment"), nullptr), QStringLiteral("((lower(t_comment) LIKE '%v3%')) OR ((lower(t_comment) LIKE '%v1%') AND (lower(t_comment) LIKE '%v2%')) AND NOT((lower(t_comment) LIKE '%v4%')) AND NOT((lower(t_comment) LIKE '%v5%'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("v1 v2 +v3 -v4 -v5")), QStringList() << QStringLiteral("t_comment"), nullptr, true), QStringLiteral("(((t_comment:v3) and ((t_comment:v1) and (t_comment:v2))) and not (t_comment:v4)) and not (t_comment:v5)")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("-v5")), QStringList() << QStringLiteral("t_comment"), nullptr), QStringLiteral("((lower(t_comment) LIKE '%%')) AND NOT((lower(t_comment) LIKE '%v5%'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("a'b")), QStringList() << QStringLiteral("t_comment"), nullptr), QStringLiteral("((lower(t_comment) LIKE '%a''b%'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("-v5")), QStringList() << QStringLiteral("t_comment"), nullptr, true), QStringLiteral("(t_comment:) and not (t_comment:v5)")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral(":ToTo")), QStringList() << QStringLiteral("p_prop1") << QStringLiteral("p_prop2"), nullptr), QStringLiteral("((i_PROPPNAME='prop1' AND (lower(i_PROPVALUE) LIKE '%toto%') OR i_PROPPNAME='prop2' AND (lower(i_PROPVALUE) LIKE '%toto%')))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral(":ToTo")), QStringList() << QStringLiteral("p_prop1") << QStringLiteral("p_prop2"), nullptr, true), QStringLiteral("p_prop1:toto or p_prop2:toto")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("#ToTo")), QStringList() << QStringLiteral("p_prop1") << QStringLiteral("p_prop2"), nullptr), QStringLiteral("((i_PROPPNAME='prop1' AND REGEXP('toto',i_PROPVALUE) OR i_PROPPNAME='prop2' AND REGEXP('toto',i_PROPVALUE)))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_att>10")), QStringList() << QStringLiteral("t_att") << QStringLiteral("t_att1"), nullptr), QStringLiteral("((lower(t_att)>'10' OR lower(t_att1)>'10'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_att.>10")), QStringList() << QStringLiteral("t_att") << QStringLiteral("t_att1"), nullptr), QStringLiteral("((lower(t_att)>'10'))")); SKGTEST(QStringLiteral("STR:searchCriteriasToWhereClause"), SKGServices::searchCriteriasToWhereClause(SKGServices::stringToSearchCriterias(QStringLiteral("t_att.>10")), QStringList() << QStringLiteral("t_att") << QStringLiteral("t_att1"), nullptr, true), QStringLiteral("t_att>10")); } int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) // Test class SKGError test_errors(nberror, nbcheck, showonlyfailures); // SKGServices { test_getPeriodWhereClause(nberror, nbcheck, showonlyfailures); test_getNeighboringPeriod(nberror, nbcheck, showonlyfailures); test_periodToDate(nberror, nbcheck, showonlyfailures); test_partialStringToDate(nberror, nbcheck, showonlyfailures); test_conversions(nberror, nbcheck, showonlyfailures); test_nbWorkingDays(nberror, nbcheck, showonlyfailures); test_getDateFormat(nberror, nbcheck, showonlyfailures); test_csv(nberror, nbcheck, showonlyfailures); test_stringToSearchCriterias(nberror, nbcheck, showonlyfailures); test_getnext(nberror, nbcheck, showonlyfailures); // Various test SKGStringListList table; table.push_back(QStringList() << QStringLiteral("Person") << QStringLiteral("Salary") << QStringLiteral("Age")); table.push_back(QStringList() << QStringLiteral("John") << QStringLiteral("58000") << QStringLiteral("33")); table.push_back(QStringList() << QStringLiteral("Paul") << QStringLiteral("42000") << QStringLiteral("25")); table.push_back(QStringList() << QStringLiteral("Alan") << QStringLiteral("65000") << QStringLiteral("41")); SKGServices::getBase100Table(table); SKGServices::getPercentTable(table, true, false); SKGServices::getPercentTable(table, false, true); SKGServices::getHistorizedTable(table); SKGTEST(QStringLiteral("STR:encodeForUrl"), SKGServices::encodeForUrl(QStringLiteral("abc")), QStringLiteral("abc")); SKGTEST(QStringLiteral("STR:getMajorVersion"), SKGServices::getMajorVersion(QStringLiteral("4.3.12.3")), QStringLiteral("4.3")); SKGTEST(QStringLiteral("STR:getMajorVersion"), SKGServices::getMajorVersion(QStringLiteral("4.3.12")), QStringLiteral("4.3")); SKGTEST(QStringLiteral("STR:getMajorVersion"), SKGServices::getMajorVersion(QStringLiteral("4.3")), QStringLiteral("4.3")); SKGTEST(QStringLiteral("STR:getMajorVersion"), SKGServices::getMajorVersion(QStringLiteral("4")), QStringLiteral("4")); SKGTEST(QStringLiteral("STR:toCurrencyString"), SKGServices::toCurrencyString(5.12341234, QStringLiteral("F"), 2).remove(' '), QStringLiteral("5.12F")); SKGTEST(QStringLiteral("STR:toCurrencyString"), SKGServices::toCurrencyString(-5.12341234, QStringLiteral("F"), 4).remove(' '), QStringLiteral("-5.1234F")); SKGTEST(QStringLiteral("STR:toPercentageString"), SKGServices::toPercentageString(5.12341234, 2), QStringLiteral("5.12 %")); SKGTEST(QStringLiteral("STR:toPercentageString"), SKGServices::toPercentageString(5.12341234, 4), QStringLiteral("5.1234 %")); QByteArray tmp; SKGTESTERROR(QStringLiteral("STR:downloadToStream"), SKGServices::downloadToStream(QUrl::fromLocalFile(QStringLiteral("notfound")), tmp), false); SKGTEST(QStringLiteral("STR:getFullPathCommandLine"), SKGServices::getFullPathCommandLine(QStringLiteral("skrooge-release.py --help")), QStringLiteral("skrooge-release.py --help")); } // End test - SKGENDTEST(); + SKGENDTEST() } diff --git a/tests/skgbasemodelertest/skgtestfile.cpp b/tests/skgbasemodelertest/skgtestfile.cpp index b560dfba5..fa5f02673 100644 --- a/tests/skgbasemodelertest/skgtestfile.cpp +++ b/tests/skgbasemodelertest/skgtestfile.cpp @@ -1,208 +1,208 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ /** @file * This file is a test script. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include #include "skgtestmacro.h" /** * The main function of the unit test * @param argc the number of arguments * @param argv the list of arguments */ int main(int argc, char** argv) { Q_UNUSED(argc); Q_UNUSED(argv); // Init test - SKGINITTEST(true); + SKGINITTEST(true) { SKGTESTBOOL("QSQLITE:isDriverAvailable", QSqlDatabase::isDriverAvailable(QStringLiteral("QSQLITE")), true); SKGTESTBOOL("SKGSQLCIPHER:isDriverAvailable", QSqlDatabase::isDriverAvailable(QStringLiteral("SKGSQLCIPHER")), true); } { // test class SKGDocument / LOAD / SAVE QString filename1 = SKGTest::getTestPath(QStringLiteral("IN")) % QStringLiteral("/filename1_e.skg"); qDebug("filename1=%s", filename1.toUtf8().constData()); { SKGDocument document1; QFile(filename1).remove(); SKGTESTERROR(QStringLiteral("DOC:initialize"), document1.initialize(), true); SKGTESTERROR(QStringLiteral("DOC:setLanguage"), document1.setLanguage(QStringLiteral("en")), true); SKGTESTERROR(QStringLiteral("DOC:setLanguage"), document1.setLanguage(QStringLiteral("fr")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("tt")), true); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("ATT3"), QStringLiteral("VAL3")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(false), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("tt")), true); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("ATT3"), QStringLiteral("VAL3")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); document1.setFileNotModified(); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("t_name")), QStringLiteral("Name")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("node.t_name")), QStringLiteral("Name")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("v_node.t_name")), QStringLiteral("Name")); SKGTEST(QStringLiteral("DOC:getDisplay"), document1.getDisplay(QStringLiteral("v_node.unknown")), QStringLiteral("v_node.unknown")); QString oResult; SKGTESTERROR(QStringLiteral("DOC:isFileModified"), document1.dumpSelectSqliteOrder(QStringLiteral("select * from parameters"), oResult), true); } { SKGDocument document1; QFile(filename1).remove(); SKGTESTERROR(QStringLiteral("DOC:initialize"), document1.initialize(), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("tt")), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); // because the transaction is empty } { SKGDocument document1; QFile(filename1).remove(); SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QLatin1String("")), false); SKGTESTERROR(QStringLiteral("DOC:saveAs+invalid path"), document1.saveAs(QStringLiteral("/notfound/file.skg"), true), false); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), QLatin1String("")); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTERROR(QStringLiteral("DOC:initialize"), document1.initialize(), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("t1")), true); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), QLatin1String("")); SKGTESTERROR(QStringLiteral("DOC:save"), document1.save(), false); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), QLatin1String("")); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); // due to the beginTransaction SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QLatin1String("")); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL1")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1")); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTESTERROR(QStringLiteral("DOC:saveAs+overwrite=false"), document1.saveAs(filename1, false), true); SKGTESTBOOL("DOC:exist", QFile(filename1).exists(), true); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), filename1); SKGTESTERROR(QStringLiteral("DOC:saveAs+overwrite=false"), document1.saveAs(filename1, false), false); SKGTESTBOOL("DOC:exist", QFile(filename1).exists(), true); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), filename1); SKGTESTERROR(QStringLiteral("DOC:save"), document1.save(), true); SKGTESTBOOL("DOC:exist", QFile(filename1).exists(), true); SKGTEST(QStringLiteral("DOC:getCurrentFileName"), document1.getCurrentFileName(), filename1); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("t1")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); // due to the beginTransaction SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1")); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("ATT1"), QStringLiteral("VAL2")), true); SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL2")); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTESTBOOL("DOC:exist", QFile(filename1).exists(), true); SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QLatin1String("")), true); SKGTESTBOOL("DOC:isFileModified", document1.isFileModified(), false); SKGTESTBOOL("DOC:getCurrentFileName", (!document1.getCurrentFileName().isEmpty()), true); SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("ATT1")), QStringLiteral("VAL1")); } { SKGDocument document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QLatin1String("")), true); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("t3")), true); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("ATT3"), QStringLiteral("VAL3")), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTESTERROR(QStringLiteral("DOC:save"), document1.save(), true); SKGTESTERROR(QStringLiteral("DOC:changePassword"), document1.changePassword(QStringLiteral("pwd1")), true); SKGTESTERROR(QStringLiteral("DOC:changePassword"), document1.changePassword(QStringLiteral("pwd")), true); SKGTESTERROR(QStringLiteral("DOC:beginTransaction"), document1.beginTransaction(QStringLiteral("tt")), true); SKGTESTERROR(QStringLiteral("DOC:setParameter"), document1.setParameter(QStringLiteral("SAVE"), QStringLiteral("1")), true); SKGTESTERROR(QStringLiteral("DOC:endTransaction"), document1.endTransaction(true), true); SKGTEST(QStringLiteral("DOC:getParameter"), document1.getParameter(QStringLiteral("SAVE")), QStringLiteral("1")); SKGTESTERROR(QStringLiteral("DOC:save"), document1.save(), true); } { SKGDocument document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QLatin1String("")), false); SKGTEST(QStringLiteral("DOC:load"), document1.load(filename1, QStringLiteral("wrong pwd")).getReturnCode(), ERR_ENCRYPTION); } { SKGDocument document1; SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QStringLiteral("pwd")), true); SKGTESTERROR(QStringLiteral("DOC:changePassword"), document1.changePassword(QStringLiteral("pwd1")), true); SKGTESTERROR(QStringLiteral("DOC:changePassword"), document1.changePassword(QLatin1String("")), true); SKGTESTERROR(QStringLiteral("DOC:save"), document1.save(), true); SKGTESTERROR(QStringLiteral("DOC:load"), document1.load(filename1, QLatin1String("")), true); } { SKGDocument document1; QFile(filename1).remove(); SKGTESTERROR(QStringLiteral("DOC:initialize"), document1.initialize(), true); document1.setBackupParameters(QLatin1String(""), QStringLiteral("/invalid suffix")); SKGTESTERROR(QStringLiteral("DOC:saveAs"), document1.saveAs(filename1, true), true); SKGTESTERROR(QStringLiteral("DOC:saveAs"), document1.saveAs(filename1, true), true); document1.setBackupParameters(QStringLiteral("."), QStringLiteral(".old")); SKGTEST(QStringLiteral("DOC:getBackupFile"), document1.getBackupFile(QStringLiteral("/tmp/file.skg")), QStringLiteral("/tmp/.file.skg.old")); document1.setBackupParameters(QLatin1String(""), QStringLiteral("_.backup")); SKGTEST(QStringLiteral("DOC:getBackupFile"), document1.getBackupFile(QStringLiteral("/tmp/file.skg")), QStringLiteral("/tmp/file.skg_") % SKGServices::dateToSqlString(QDateTime::currentDateTime().date()) % ".backup"); document1.setBackupParameters(QLatin1String(""), QStringLiteral("_.skg")); SKGTEST(QStringLiteral("DOC:getBackupFile"), document1.getBackupFile(QStringLiteral("/tmp/file.skg")), QStringLiteral("/tmp/file_") % SKGServices::dateToSqlString(QDateTime::currentDateTime().date()) % ".skg"); document1.setBackupParameters(QLatin1String(""), QStringLiteral("_