Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/storage/tests/mymoneystoragemgr-test.cpp
Context not available. | |||||
226 | try { | 226 | try { | ||
---|---|---|---|---|---|
227 | a = m->account("Unknown ID"); | 227 | a = m->account("Unknown ID"); | ||
228 | QFAIL("Exception expected"); | 228 | QFAIL("Exception expected"); | ||
229 | } catch (const MyMoneyException &) { | 229 | } catch (const std::exception &) { | ||
230 | } | 230 | } | ||
231 | m->commitTransaction(); | 231 | m->commitTransaction(); | ||
232 | m->startTransaction(); | 232 | m->startTransaction(); | ||
Context not available. | |||||
240 | QCOMPARE(a.name(), QLatin1String("AccountName")); | 240 | QCOMPARE(a.name(), QLatin1String("AccountName")); | ||
241 | QCOMPARE(a.id(), QLatin1String("A000001")); | 241 | QCOMPARE(a.id(), QLatin1String("A000001")); | ||
242 | QCOMPARE(m->dirty(), true); | 242 | QCOMPARE(m->dirty(), true); | ||
243 | } catch (const MyMoneyException &) { | 243 | } catch (const std::exception &) { | ||
244 | QFAIL("Unexpected exception"); | 244 | QFAIL("Unexpected exception"); | ||
245 | } | 245 | } | ||
246 | } | 246 | } | ||
Context not available. | |||||
266 | MyMoneyAccount c("UnknownID", b); | 266 | MyMoneyAccount c("UnknownID", b); | ||
267 | m->addAccount(c, a); | 267 | m->addAccount(c, a); | ||
268 | QFAIL("Exception expected"); | 268 | QFAIL("Exception expected"); | ||
269 | } catch (const MyMoneyException &) { | 269 | } catch (const std::exception &) { | ||
270 | } | 270 | } | ||
271 | m->commitTransaction(); | 271 | m->commitTransaction(); | ||
272 | m->startTransaction(); | 272 | m->startTransaction(); | ||
Context not available. | |||||
283 | QCOMPARE(m->d_func()->m_accountList["A000002"].accountList().count(), 1); | 283 | QCOMPARE(m->d_func()->m_accountList["A000002"].accountList().count(), 1); | ||
284 | QCOMPARE(m->d_func()->m_accountList[stdAccNames[stdAccAsset]].accountList().count(), 0); | 284 | QCOMPARE(m->d_func()->m_accountList[stdAccNames[stdAccAsset]].accountList().count(), 0); | ||
285 | QCOMPARE(m->dirty(), true); | 285 | QCOMPARE(m->dirty(), true); | ||
286 | } catch (const MyMoneyException &) { | 286 | } catch (const std::exception &) { | ||
287 | QFAIL("Unexpected exception"); | 287 | QFAIL("Unexpected exception"); | ||
288 | } | 288 | } | ||
289 | } | 289 | } | ||
Context not available. | |||||
311 | try { | 311 | try { | ||
312 | i = m->institution("Unknown ID"); | 312 | i = m->institution("Unknown ID"); | ||
313 | QFAIL("Exception expected"); | 313 | QFAIL("Exception expected"); | ||
314 | } catch (const MyMoneyException &) { | 314 | } catch (const std::exception &) { | ||
315 | } | 315 | } | ||
316 | 316 | | |||
317 | QCOMPARE(m->dirty(), false); | 317 | QCOMPARE(m->dirty(), false); | ||
Context not available. | |||||
321 | i = m->institution("I000001"); | 321 | i = m->institution("I000001"); | ||
322 | QCOMPARE(i.name(), QLatin1String("Inst Name")); | 322 | QCOMPARE(i.name(), QLatin1String("Inst Name")); | ||
323 | QCOMPARE(m->dirty(), false); | 323 | QCOMPARE(m->dirty(), false); | ||
324 | } catch (const MyMoneyException &) { | 324 | } catch (const std::exception &) { | ||
325 | QFAIL("Unexpected exception"); | 325 | QFAIL("Unexpected exception"); | ||
326 | } | 326 | } | ||
327 | } | 327 | } | ||
Context not available. | |||||
337 | try { | 337 | try { | ||
338 | i = m->institution("I000001"); | 338 | i = m->institution("I000001"); | ||
339 | a = m->account("A000001"); | 339 | a = m->account("A000001"); | ||
340 | } catch (const MyMoneyException &) { | 340 | } catch (const std::exception &) { | ||
341 | QFAIL("Unexpected exception"); | 341 | QFAIL("Unexpected exception"); | ||
342 | } | 342 | } | ||
343 | 343 | | |||
Context not available. | |||||
349 | try { | 349 | try { | ||
350 | m->modifyAccount(a); | 350 | m->modifyAccount(a); | ||
351 | QFAIL("Exception expected"); | 351 | QFAIL("Exception expected"); | ||
352 | } catch (const MyMoneyException &) { | 352 | } catch (const std::exception &) { | ||
353 | } | 353 | } | ||
354 | m->commitTransaction(); | 354 | m->commitTransaction(); | ||
355 | m->startTransaction(); | 355 | m->startTransaction(); | ||
Context not available. | |||||
367 | b = m->account("A000001"); | 367 | b = m->account("A000001"); | ||
368 | QCOMPARE(b.institutionId(), i.id()); | 368 | QCOMPARE(b.institutionId(), i.id()); | ||
369 | QCOMPARE(i.accountList().count(), 0); | 369 | QCOMPARE(i.accountList().count(), 0); | ||
370 | } catch (const MyMoneyException &) { | 370 | } catch (const std::exception &) { | ||
371 | QFAIL("Unexpected exception"); | 371 | QFAIL("Unexpected exception"); | ||
372 | } | 372 | } | ||
373 | } | 373 | } | ||
Context not available. | |||||
388 | QCOMPARE(b.parentAccountId(), a.parentAccountId()); | 388 | QCOMPARE(b.parentAccountId(), a.parentAccountId()); | ||
389 | QCOMPARE(b.name(), QLatin1String("New account name")); | 389 | QCOMPARE(b.name(), QLatin1String("New account name")); | ||
390 | QCOMPARE(m->dirty(), true); | 390 | QCOMPARE(m->dirty(), true); | ||
391 | } catch (const MyMoneyException &) { | 391 | } catch (const std::exception &) { | ||
392 | QFAIL("Unexpected exception"); | 392 | QFAIL("Unexpected exception"); | ||
393 | } | 393 | } | ||
394 | 394 | | |||
Context not available. | |||||
398 | try { | 398 | try { | ||
399 | m->modifyAccount(c); | 399 | m->modifyAccount(c); | ||
400 | QFAIL("Exception expected"); | 400 | QFAIL("Exception expected"); | ||
401 | } catch (const MyMoneyException &) { | 401 | } catch (const std::exception &) { | ||
402 | } | 402 | } | ||
403 | 403 | | |||
404 | // use different account type | 404 | // use different account type | ||
Context not available. | |||||
408 | try { | 408 | try { | ||
409 | m->modifyAccount(f); | 409 | m->modifyAccount(f); | ||
410 | QFAIL("Exception expected"); | 410 | QFAIL("Exception expected"); | ||
411 | } catch (const MyMoneyException &) { | 411 | } catch (const std::exception &) { | ||
412 | } | 412 | } | ||
413 | 413 | | |||
414 | // use different parent | 414 | // use different parent | ||
Context not available. | |||||
416 | try { | 416 | try { | ||
417 | m->modifyAccount(c); | 417 | m->modifyAccount(c); | ||
418 | QFAIL("Exception expected"); | 418 | QFAIL("Exception expected"); | ||
419 | } catch (const MyMoneyException &) { | 419 | } catch (const std::exception &) { | ||
420 | } | 420 | } | ||
421 | } | 421 | } | ||
422 | 422 | | |||
Context not available. | |||||
435 | i = m->institution("I000001"); | 435 | i = m->institution("I000001"); | ||
436 | QCOMPARE(i.name(), QLatin1String("New inst name")); | 436 | QCOMPARE(i.name(), QLatin1String("New inst name")); | ||
437 | 437 | | |||
438 | } catch (const MyMoneyException &) { | 438 | } catch (const std::exception &) { | ||
439 | QFAIL("Unexpected exception"); | 439 | QFAIL("Unexpected exception"); | ||
440 | } | 440 | } | ||
441 | 441 | | |||
Context not available. | |||||
444 | try { | 444 | try { | ||
445 | m->modifyInstitution(f); | 445 | m->modifyInstitution(f); | ||
446 | QFAIL("Exception expected"); | 446 | QFAIL("Exception expected"); | ||
447 | } catch (const MyMoneyException &) { | 447 | } catch (const std::exception &) { | ||
448 | } | 448 | } | ||
449 | } | 449 | } | ||
450 | 450 | | |||
Context not available. | |||||
508 | QCOMPARE(m->expense().accountCount(), 2); | 508 | QCOMPARE(m->expense().accountCount(), 2); | ||
509 | QCOMPARE(m->account(ex1.id()).accountCount(), 2); | 509 | QCOMPARE(m->account(ex1.id()).accountCount(), 2); | ||
510 | QCOMPARE(ex3.parentAccountId(), ex1.id()); | 510 | QCOMPARE(ex3.parentAccountId(), ex1.id()); | ||
511 | } catch (const MyMoneyException &e) { | 511 | } catch (const std::exception &e) { | ||
512 | std::cout << std::endl << qPrintable(e.what()) << std::endl; | 512 | std::cout << std::endl << qPrintable(e.what()) << std::endl; | ||
513 | QFAIL("Unexpected exception"); | 513 | QFAIL("Unexpected exception"); | ||
514 | } | 514 | } | ||
Context not available. | |||||
538 | t1.addSplit(s); | 538 | t1.addSplit(s); | ||
539 | 539 | | |||
540 | t1.setPostDate(QDate(2002, 5, 10)); | 540 | t1.setPostDate(QDate(2002, 5, 10)); | ||
541 | } catch (const MyMoneyException &e) { | 541 | } catch (const std::exception &e) { | ||
542 | unexpectedException(e); | 542 | unexpectedException(e); | ||
543 | } | 543 | } | ||
544 | 544 | | |||
Context not available. | |||||
551 | QCOMPARE(t1.id(), QLatin1String("T000000000000000001")); | 551 | QCOMPARE(t1.id(), QLatin1String("T000000000000000001")); | ||
552 | QCOMPARE(t1.splitCount(), 2u); | 552 | QCOMPARE(t1.splitCount(), 2u); | ||
553 | QCOMPARE(m->transactionCount(QString()), 1u); | 553 | QCOMPARE(m->transactionCount(QString()), 1u); | ||
554 | } catch (const MyMoneyException &e) { | 554 | } catch (const std::exception &e) { | ||
555 | unexpectedException(e); | 555 | unexpectedException(e); | ||
556 | } | 556 | } | ||
557 | 557 | | |||
Context not available. | |||||
586 | t2.addSplit(s); | 586 | t2.addSplit(s); | ||
587 | 587 | | |||
588 | t2.setPostDate(QDate(2002, 5, 9)); | 588 | t2.setPostDate(QDate(2002, 5, 9)); | ||
589 | } catch (const MyMoneyException &e) { | 589 | } catch (const std::exception &e) { | ||
590 | unexpectedException(e); | 590 | unexpectedException(e); | ||
591 | } | 591 | } | ||
592 | m->d_func()->m_dirty = false; | 592 | m->d_func()->m_dirty = false; | ||
Context not available. | |||||
630 | QCOMPARE((*it).id(), QLatin1String("T000000000000000001")); | 630 | QCOMPARE((*it).id(), QLatin1String("T000000000000000001")); | ||
631 | ++it; | 631 | ++it; | ||
632 | QCOMPARE(it, list.constEnd()); | 632 | QCOMPARE(it, list.constEnd()); | ||
633 | } catch (const MyMoneyException &e) { | 633 | } catch (const std::exception &e) { | ||
634 | unexpectedException(e); | 634 | unexpectedException(e); | ||
635 | } | 635 | } | ||
636 | } | 636 | } | ||
Context not available. | |||||
689 | QCOMPARE(m->balance("A000004", QDate()), MyMoneyMoney(11000, 100)); | 689 | QCOMPARE(m->balance("A000004", QDate()), MyMoneyMoney(11000, 100)); | ||
690 | QCOMPARE(m->balance("A000006", QDate()), MyMoneyMoney(100000 - 12600, 100)); | 690 | QCOMPARE(m->balance("A000006", QDate()), MyMoneyMoney(100000 - 12600, 100)); | ||
691 | QCOMPARE(m->totalBalance("A000001", QDate()), MyMoneyMoney(1600, 100)); | 691 | QCOMPARE(m->totalBalance("A000001", QDate()), MyMoneyMoney(1600, 100)); | ||
692 | } catch (const MyMoneyException &) { | 692 | } catch (const std::exception &) { | ||
693 | QFAIL("Unexpected exception"); | 693 | QFAIL("Unexpected exception"); | ||
694 | } | 694 | } | ||
695 | 695 | | |||
Context not available. | |||||
731 | QCOMPARE((*it).id(), QLatin1String("T000000000000000002")); | 731 | QCOMPARE((*it).id(), QLatin1String("T000000000000000002")); | ||
732 | ++it; | 732 | ++it; | ||
733 | QCOMPARE(it, list.constEnd()); | 733 | QCOMPARE(it, list.constEnd()); | ||
734 | } catch (const MyMoneyException &) { | 734 | } catch (const std::exception &) { | ||
735 | QFAIL("Unexpected exception"); | 735 | QFAIL("Unexpected exception"); | ||
736 | } | 736 | } | ||
737 | } | 737 | } | ||
Context not available. | |||||
749 | try { | 749 | try { | ||
750 | m->removeAccount(m->liability()); | 750 | m->removeAccount(m->liability()); | ||
751 | QFAIL("Exception expected"); | 751 | QFAIL("Exception expected"); | ||
752 | } catch (const MyMoneyException &) { | 752 | } catch (const std::exception &) { | ||
753 | } | 753 | } | ||
754 | 754 | | |||
755 | try { | 755 | try { | ||
756 | m->removeAccount(m->asset()); | 756 | m->removeAccount(m->asset()); | ||
757 | QFAIL("Exception expected"); | 757 | QFAIL("Exception expected"); | ||
758 | } catch (const MyMoneyException &) { | 758 | } catch (const std::exception &) { | ||
759 | } | 759 | } | ||
760 | 760 | | |||
761 | try { | 761 | try { | ||
762 | m->removeAccount(m->expense()); | 762 | m->removeAccount(m->expense()); | ||
763 | QFAIL("Exception expected"); | 763 | QFAIL("Exception expected"); | ||
764 | } catch (const MyMoneyException &) { | 764 | } catch (const std::exception &) { | ||
765 | } | 765 | } | ||
766 | 766 | | |||
767 | try { | 767 | try { | ||
768 | m->removeAccount(m->income()); | 768 | m->removeAccount(m->income()); | ||
769 | QFAIL("Exception expected"); | 769 | QFAIL("Exception expected"); | ||
770 | } catch (const MyMoneyException &) { | 770 | } catch (const std::exception &) { | ||
771 | } | 771 | } | ||
772 | 772 | | |||
773 | // try to remove the account still attached to the institution | 773 | // try to remove the account still attached to the institution | ||
774 | try { | 774 | try { | ||
775 | m->removeAccount(a); | 775 | m->removeAccount(a); | ||
776 | QFAIL("Exception expected"); | 776 | QFAIL("Exception expected"); | ||
777 | } catch (const MyMoneyException &) { | 777 | } catch (const std::exception &) { | ||
778 | } | 778 | } | ||
779 | 779 | | |||
780 | // now really remove an account | 780 | // now really remove an account | ||
Context not available. | |||||
792 | QCOMPARE(m->dirty(), true); | 792 | QCOMPARE(m->dirty(), true); | ||
793 | i = m->institution("I000001"); | 793 | i = m->institution("I000001"); | ||
794 | QCOMPARE(i.accountCount(), 0u); | 794 | QCOMPARE(i.accountCount(), 0u); | ||
795 | } catch (const MyMoneyException &) { | 795 | } catch (const std::exception &) { | ||
796 | QFAIL("Unexpected exception"); | 796 | QFAIL("Unexpected exception"); | ||
797 | } | 797 | } | ||
798 | } | 798 | } | ||
Context not available. | |||||
806 | try { | 806 | try { | ||
807 | m->removeAccount(a); | 807 | m->removeAccount(a); | ||
808 | QFAIL("Exception expected"); | 808 | QFAIL("Exception expected"); | ||
809 | } catch (const MyMoneyException &) { | 809 | } catch (const std::exception &) { | ||
810 | } | 810 | } | ||
811 | } | 811 | } | ||
812 | 812 | | |||
Context not available. | |||||
825 | a.setInstitutionId(i.id()); | 825 | a.setInstitutionId(i.id()); | ||
826 | m->modifyAccount(a); | 826 | m->modifyAccount(a); | ||
827 | QCOMPARE(i.accountCount(), 0u); | 827 | QCOMPARE(i.accountCount(), 0u); | ||
828 | } catch (const MyMoneyException &) { | 828 | } catch (const std::exception &) { | ||
829 | QFAIL("Unexpected exception"); | 829 | QFAIL("Unexpected exception"); | ||
830 | } | 830 | } | ||
831 | 831 | | |||
Context not available. | |||||
841 | QCOMPARE(m->dirty(), true); | 841 | QCOMPARE(m->dirty(), true); | ||
842 | QVERIFY(a.institutionId().isEmpty()); | 842 | QVERIFY(a.institutionId().isEmpty()); | ||
843 | QCOMPARE(m->institutionCount(), 0u); | 843 | QCOMPARE(m->institutionCount(), 0u); | ||
844 | } catch (const MyMoneyException &) { | 844 | } catch (const std::exception &) { | ||
845 | QFAIL("Unexpected exception"); | 845 | QFAIL("Unexpected exception"); | ||
846 | } | 846 | } | ||
847 | } | 847 | } | ||
Context not available. | |||||
862 | /* removed with MyMoneyAccount::Transaction | 862 | /* removed with MyMoneyAccount::Transaction | ||
863 | QCOMPARE(m->account("A000006").transactionCount(QString()), 1); | 863 | QCOMPARE(m->account("A000006").transactionCount(QString()), 1); | ||
864 | */ | 864 | */ | ||
865 | } catch (const MyMoneyException &) { | 865 | } catch (const std::exception &) { | ||
866 | QFAIL("Unexpected exception"); | 866 | QFAIL("Unexpected exception"); | ||
867 | } | 867 | } | ||
868 | } | 868 | } | ||
Context not available. | |||||
904 | m->startTransaction(); | 904 | m->startTransaction(); | ||
905 | QCOMPARE(m->dirty(), true); | 905 | QCOMPARE(m->dirty(), true); | ||
906 | QCOMPARE(m->d_func()->m_nextPayeeID, 1ul); | 906 | QCOMPARE(m->d_func()->m_nextPayeeID, 1ul); | ||
907 | } catch (const MyMoneyException &) { | 907 | } catch (const std::exception &) { | ||
908 | QFAIL("Unexpected exception"); | 908 | QFAIL("Unexpected exception"); | ||
909 | } | 909 | } | ||
910 | 910 | | |||
Context not available. | |||||
914 | { | 914 | { | ||
915 | try { | 915 | try { | ||
916 | m->setAccountName(stdAccNames[stdAccLiability], "Verbindlichkeiten"); | 916 | m->setAccountName(stdAccNames[stdAccLiability], "Verbindlichkeiten"); | ||
917 | } catch (const MyMoneyException &) { | 917 | } catch (const std::exception &) { | ||
918 | QFAIL("Unexpected exception"); | 918 | QFAIL("Unexpected exception"); | ||
919 | } | 919 | } | ||
920 | try { | 920 | try { | ||
921 | m->setAccountName(stdAccNames[stdAccAsset], QString("Vermögen")); | 921 | m->setAccountName(stdAccNames[stdAccAsset], QString("Vermögen")); | ||
922 | } catch (const MyMoneyException &) { | 922 | } catch (const std::exception &) { | ||
923 | QFAIL("Unexpected exception"); | 923 | QFAIL("Unexpected exception"); | ||
924 | } | 924 | } | ||
925 | try { | 925 | try { | ||
926 | m->setAccountName(stdAccNames[stdAccExpense], "Ausgaben"); | 926 | m->setAccountName(stdAccNames[stdAccExpense], "Ausgaben"); | ||
927 | } catch (const MyMoneyException &) { | 927 | } catch (const std::exception &) { | ||
928 | QFAIL("Unexpected exception"); | 928 | QFAIL("Unexpected exception"); | ||
929 | } | 929 | } | ||
930 | try { | 930 | try { | ||
931 | m->setAccountName(stdAccNames[stdAccIncome], "Einnahmen"); | 931 | m->setAccountName(stdAccNames[stdAccIncome], "Einnahmen"); | ||
932 | } catch (const MyMoneyException &) { | 932 | } catch (const std::exception &) { | ||
933 | QFAIL("Unexpected exception"); | 933 | QFAIL("Unexpected exception"); | ||
934 | } | 934 | } | ||
935 | 935 | | |||
Context not available. | |||||
941 | try { | 941 | try { | ||
942 | m->setAccountName("A000001", "New account name"); | 942 | m->setAccountName("A000001", "New account name"); | ||
943 | QFAIL("Exception expected"); | 943 | QFAIL("Exception expected"); | ||
944 | } catch (const MyMoneyException &) { | 944 | } catch (const std::exception &) { | ||
945 | } | 945 | } | ||
946 | } | 946 | } | ||
947 | 947 | | |||
Context not available. | |||||
961 | p = m->payee("P000001"); | 961 | p = m->payee("P000001"); | ||
962 | QCOMPARE(p.name(), QLatin1String("New name")); | 962 | QCOMPARE(p.name(), QLatin1String("New name")); | ||
963 | QCOMPARE(m->dirty(), true); | 963 | QCOMPARE(m->dirty(), true); | ||
964 | } catch (const MyMoneyException &) { | 964 | } catch (const std::exception &) { | ||
965 | QFAIL("Unexpected exception"); | 965 | QFAIL("Unexpected exception"); | ||
966 | } | 966 | } | ||
967 | } | 967 | } | ||
Context not available. | |||||
980 | m->startTransaction(); | 980 | m->startTransaction(); | ||
981 | QCOMPARE(m->d_func()->m_payeeList.count(), 0); | 981 | QCOMPARE(m->d_func()->m_payeeList.count(), 0); | ||
982 | QCOMPARE(m->dirty(), true); | 982 | QCOMPARE(m->dirty(), true); | ||
983 | } catch (const MyMoneyException &) { | 983 | } catch (const std::exception &) { | ||
984 | QFAIL("Unexpected exception"); | 984 | QFAIL("Unexpected exception"); | ||
985 | } | 985 | } | ||
986 | 986 | | |||
Context not available. | |||||
998 | try { | 998 | try { | ||
999 | m->modifyTransaction(tr); | 999 | m->modifyTransaction(tr); | ||
1000 | QFAIL("Expected exception"); | 1000 | QFAIL("Expected exception"); | ||
1001 | } catch (const MyMoneyException &) { | 1001 | } catch (const std::exception &) { | ||
1002 | } | 1002 | } | ||
1003 | 1003 | | |||
1004 | m->d_func()->m_nextPayeeID = 0; // reset here, so that the | 1004 | m->d_func()->m_nextPayeeID = 0; // reset here, so that the | ||
Context not available. | |||||
1008 | // check that it works when the payee exists | 1008 | // check that it works when the payee exists | ||
1009 | try { | 1009 | try { | ||
1010 | m->modifyTransaction(tr); | 1010 | m->modifyTransaction(tr); | ||
1011 | } catch (const MyMoneyException &) { | 1011 | } catch (const std::exception &) { | ||
1012 | QFAIL("Unexpected exception"); | 1012 | QFAIL("Unexpected exception"); | ||
1013 | } | 1013 | } | ||
1014 | 1014 | | |||
Context not available. | |||||
1018 | try { | 1018 | try { | ||
1019 | m->removePayee(p); | 1019 | m->removePayee(p); | ||
1020 | QFAIL("Expected exception"); | 1020 | QFAIL("Expected exception"); | ||
1021 | } catch (const MyMoneyException &) { | 1021 | } catch (const std::exception &) { | ||
1022 | } | 1022 | } | ||
1023 | QCOMPARE(m->d_func()->m_payeeList.count(), 1); | 1023 | QCOMPARE(m->d_func()->m_payeeList.count(), 1); | ||
1024 | } | 1024 | } | ||
Context not available. | |||||
1036 | m->startTransaction(); | 1036 | m->startTransaction(); | ||
1037 | QCOMPARE(m->dirty(), true); | 1037 | QCOMPARE(m->dirty(), true); | ||
1038 | QCOMPARE(m->d_func()->m_nextTagID, 1ul); | 1038 | QCOMPARE(m->d_func()->m_nextTagID, 1ul); | ||
1039 | } catch (const MyMoneyException &) { | 1039 | } catch (const std::exception &) { | ||
1040 | QFAIL("Unexpected exception"); | 1040 | QFAIL("Unexpected exception"); | ||
1041 | } | 1041 | } | ||
1042 | } | 1042 | } | ||
Context not available. | |||||
1057 | ta = m->tag("G000001"); | 1057 | ta = m->tag("G000001"); | ||
1058 | QCOMPARE(ta.name(), QLatin1String("New name")); | 1058 | QCOMPARE(ta.name(), QLatin1String("New name")); | ||
1059 | QCOMPARE(m->dirty(), true); | 1059 | QCOMPARE(m->dirty(), true); | ||
1060 | } catch (const MyMoneyException &) { | 1060 | } catch (const std::exception &) { | ||
1061 | QFAIL("Unexpected exception"); | 1061 | QFAIL("Unexpected exception"); | ||
1062 | } | 1062 | } | ||
1063 | } | 1063 | } | ||
Context not available. | |||||
1076 | m->startTransaction(); | 1076 | m->startTransaction(); | ||
1077 | QCOMPARE(m->d_func()->m_tagList.count(), 0); | 1077 | QCOMPARE(m->d_func()->m_tagList.count(), 0); | ||
1078 | QCOMPARE(m->dirty(), true); | 1078 | QCOMPARE(m->dirty(), true); | ||
1079 | } catch (const MyMoneyException &) { | 1079 | } catch (const std::exception &) { | ||
1080 | QFAIL("Unexpected exception"); | 1080 | QFAIL("Unexpected exception"); | ||
1081 | } | 1081 | } | ||
1082 | 1082 | | |||
Context not available. | |||||
1096 | try { | 1096 | try { | ||
1097 | m->modifyTransaction(tr); | 1097 | m->modifyTransaction(tr); | ||
1098 | QFAIL("Expected exception"); | 1098 | QFAIL("Expected exception"); | ||
1099 | } catch (const MyMoneyException &) { | 1099 | } catch (const std::exception &) { | ||
1100 | } | 1100 | } | ||
1101 | 1101 | | |||
1102 | m->d_func()->m_nextTagID = 0; // reset here, so that the | 1102 | m->d_func()->m_nextTagID = 0; // reset here, so that the | ||
Context not available. | |||||
1106 | // check that it works when the tag exists | 1106 | // check that it works when the tag exists | ||
1107 | try { | 1107 | try { | ||
1108 | m->modifyTransaction(tr); | 1108 | m->modifyTransaction(tr); | ||
1109 | } catch (const MyMoneyException &) { | 1109 | } catch (const std::exception &) { | ||
1110 | QFAIL("Unexpected exception"); | 1110 | QFAIL("Unexpected exception"); | ||
1111 | } | 1111 | } | ||
1112 | 1112 | | |||
Context not available. | |||||
1116 | try { | 1116 | try { | ||
1117 | m->removeTag(ta); | 1117 | m->removeTag(ta); | ||
1118 | QFAIL("Expected exception"); | 1118 | QFAIL("Expected exception"); | ||
1119 | } catch (const MyMoneyException &) { | 1119 | } catch (const std::exception &) { | ||
1120 | } | 1120 | } | ||
1121 | QCOMPARE(m->d_func()->m_tagList.count(), 1); | 1121 | QCOMPARE(m->d_func()->m_tagList.count(), 1); | ||
1122 | } | 1122 | } | ||
Context not available. | |||||
1155 | try { | 1155 | try { | ||
1156 | b = m->account(b.id()); | 1156 | b = m->account(b.id()); | ||
1157 | QFAIL("Exception expected"); | 1157 | QFAIL("Exception expected"); | ||
1158 | } catch (const MyMoneyException &) { | 1158 | } catch (const std::exception &) { | ||
1159 | } | 1159 | } | ||
1160 | QCOMPARE(a.accountList().count(), 1); | 1160 | QCOMPARE(a.accountList().count(), 1); | ||
1161 | QCOMPARE(m->account(a.accountList()[0]).name(), QLatin1String("Acc C")); | 1161 | QCOMPARE(m->account(a.accountList()[0]).name(), QLatin1String("Acc C")); | ||
1162 | 1162 | | |||
1163 | QCOMPARE(c.accountList().count(), 0); | 1163 | QCOMPARE(c.accountList().count(), 0); | ||
1164 | 1164 | | |||
1165 | } catch (const MyMoneyException &e) { | 1165 | } catch (const std::exception &e) { | ||
1166 | unexpectedException(e); | 1166 | unexpectedException(e); | ||
1167 | } | 1167 | } | ||
1168 | } | 1168 | } | ||
Context not available. | |||||
1179 | p = m->payeeByName(name); | 1179 | p = m->payeeByName(name); | ||
1180 | QCOMPARE(p.name(), QLatin1String("THB")); | 1180 | QCOMPARE(p.name(), QLatin1String("THB")); | ||
1181 | QCOMPARE(p.id(), QLatin1String("P000001")); | 1181 | QCOMPARE(p.id(), QLatin1String("P000001")); | ||
1182 | } catch (const MyMoneyException &e) { | 1182 | } catch (const std::exception &e) { | ||
1183 | unexpectedException(e); | 1183 | unexpectedException(e); | ||
1184 | } | 1184 | } | ||
1185 | 1185 | | |||
Context not available. | |||||
1188 | try { | 1188 | try { | ||
1189 | p = m->payeeByName(name); | 1189 | p = m->payeeByName(name); | ||
1190 | QFAIL("Exception expected"); | 1190 | QFAIL("Exception expected"); | ||
1191 | } catch (const MyMoneyException &) { | 1191 | } catch (const std::exception &) { | ||
1192 | } | 1192 | } | ||
1193 | } | 1193 | } | ||
1194 | 1194 | | |||
Context not available. | |||||
1204 | ta = m->tagByName(name); | 1204 | ta = m->tagByName(name); | ||
1205 | QCOMPARE(ta.name(), QLatin1String("THB")); | 1205 | QCOMPARE(ta.name(), QLatin1String("THB")); | ||
1206 | QCOMPARE(ta.id(), QLatin1String("G000001")); | 1206 | QCOMPARE(ta.id(), QLatin1String("G000001")); | ||
1207 | } catch (const MyMoneyException &e) { | 1207 | } catch (const std::exception &e) { | ||
1208 | unexpectedException(e); | 1208 | unexpectedException(e); | ||
1209 | } | 1209 | } | ||
1210 | 1210 | | |||
Context not available. | |||||
1213 | try { | 1213 | try { | ||
1214 | ta = m->tagByName(name); | 1214 | ta = m->tagByName(name); | ||
1215 | QFAIL("Exception expected"); | 1215 | QFAIL("Exception expected"); | ||
1216 | } catch (const MyMoneyException &) { | 1216 | } catch (const std::exception &) { | ||
1217 | } | 1217 | } | ||
1218 | } | 1218 | } | ||
1219 | 1219 | | |||
Context not available. | |||||
1320 | QCOMPARE(m->d_func()->m_scheduleList.count(), 1); | 1320 | QCOMPARE(m->d_func()->m_scheduleList.count(), 1); | ||
1321 | QCOMPARE(schedule.id(), QLatin1String("SCH000001")); | 1321 | QCOMPARE(schedule.id(), QLatin1String("SCH000001")); | ||
1322 | QCOMPARE(m->d_func()->m_scheduleList["SCH000001"].id(), QLatin1String("SCH000001")); | 1322 | QCOMPARE(m->d_func()->m_scheduleList["SCH000001"].id(), QLatin1String("SCH000001")); | ||
1323 | } catch (const MyMoneyException &) { | 1323 | } catch (const std::exception &) { | ||
1324 | QFAIL("Unexpected exception"); | 1324 | QFAIL("Unexpected exception"); | ||
1325 | } | 1325 | } | ||
1326 | 1326 | | |||
Context not available. | |||||
1335 | false); | 1335 | false); | ||
1336 | m->addSchedule(schedule); | 1336 | m->addSchedule(schedule); | ||
1337 | QFAIL("Exception expected"); | 1337 | QFAIL("Exception expected"); | ||
1338 | } catch (const MyMoneyException &) { | 1338 | } catch (const std::exception &) { | ||
1339 | } | 1339 | } | ||
1340 | } | 1340 | } | ||
1341 | 1341 | | |||
Context not available. | |||||
1351 | try { | 1351 | try { | ||
1352 | m->schedule("SCH000002"); | 1352 | m->schedule("SCH000002"); | ||
1353 | QFAIL("Exception expected"); | 1353 | QFAIL("Exception expected"); | ||
1354 | } catch (const MyMoneyException &) { | 1354 | } catch (const std::exception &) { | ||
1355 | } | 1355 | } | ||
1356 | } | 1356 | } | ||
1357 | 1357 | | |||
Context not available. | |||||
1365 | try { | 1365 | try { | ||
1366 | m->modifySchedule(sched); | 1366 | m->modifySchedule(sched); | ||
1367 | QFAIL("Exception expected"); | 1367 | QFAIL("Exception expected"); | ||
1368 | } catch (const MyMoneyException &) { | 1368 | } catch (const std::exception &) { | ||
1369 | } | 1369 | } | ||
1370 | 1370 | | |||
1371 | sched = m->schedule("SCH000001"); | 1371 | sched = m->schedule("SCH000001"); | ||
Context not available. | |||||
1375 | QCOMPARE(m->d_func()->m_scheduleList.count(), 1); | 1375 | QCOMPARE(m->d_func()->m_scheduleList.count(), 1); | ||
1376 | QCOMPARE(m->d_func()->m_scheduleList["SCH000001"].name(), QLatin1String("New Sched-Name")); | 1376 | QCOMPARE(m->d_func()->m_scheduleList["SCH000001"].name(), QLatin1String("New Sched-Name")); | ||
1377 | 1377 | | |||
1378 | } catch (const MyMoneyException &) { | 1378 | } catch (const std::exception &) { | ||
1379 | QFAIL("Unexpected exception"); | 1379 | QFAIL("Unexpected exception"); | ||
1380 | } | 1380 | } | ||
1381 | 1381 | | |||
Context not available. | |||||
1394 | m->removeSchedule(sched); | 1394 | m->removeSchedule(sched); | ||
1395 | m->commitTransaction(); | 1395 | m->commitTransaction(); | ||
1396 | QFAIL("Exception expected"); | 1396 | QFAIL("Exception expected"); | ||
1397 | } catch (const MyMoneyException &) { | 1397 | } catch (const std::exception &) { | ||
1398 | m->rollbackTransaction(); | 1398 | m->rollbackTransaction(); | ||
1399 | } | 1399 | } | ||
1400 | m->startTransaction(); | 1400 | m->startTransaction(); | ||
Context not available. | |||||
1405 | m->commitTransaction(); | 1405 | m->commitTransaction(); | ||
1406 | QCOMPARE(m->d_func()->m_scheduleList.count(), 0); | 1406 | QCOMPARE(m->d_func()->m_scheduleList.count(), 0); | ||
1407 | 1407 | | |||
1408 | } catch (const MyMoneyException &) { | 1408 | } catch (const std::exception &) { | ||
1409 | m->rollbackTransaction(); | 1409 | m->rollbackTransaction(); | ||
1410 | QFAIL("Unexpected exception"); | 1410 | QFAIL("Unexpected exception"); | ||
1411 | } | 1411 | } | ||
Context not available. | |||||
1507 | m->addSchedule(schedule2); | 1507 | m->addSchedule(schedule2); | ||
1508 | m->addSchedule(schedule3); | 1508 | m->addSchedule(schedule3); | ||
1509 | m->addSchedule(schedule4); | 1509 | m->addSchedule(schedule4); | ||
1510 | } catch (const MyMoneyException &e) { | 1510 | } catch (const std::exception &e) { | ||
1511 | qDebug("Error: %s", qPrintable(e.what())); | 1511 | qDebug("Error: %s", qPrintable(e.what())); | ||
1512 | QFAIL("Unexpected exception"); | 1512 | QFAIL("Unexpected exception"); | ||
1513 | } | 1513 | } | ||
Context not available. | |||||
1609 | QCOMPARE(m->d_func()->m_currencyList.count(), 1); | 1609 | QCOMPARE(m->d_func()->m_currencyList.count(), 1); | ||
1610 | QCOMPARE(m->d_func()->m_currencyList["EUR"].name(), QLatin1String("Euro")); | 1610 | QCOMPARE(m->d_func()->m_currencyList["EUR"].name(), QLatin1String("Euro")); | ||
1611 | QCOMPARE(m->dirty(), true); | 1611 | QCOMPARE(m->dirty(), true); | ||
1612 | } catch (const MyMoneyException &) { | 1612 | } catch (const std::exception &) { | ||
1613 | QFAIL("Unexpected exception"); | 1613 | QFAIL("Unexpected exception"); | ||
1614 | } | 1614 | } | ||
1615 | 1615 | | |||
Context not available. | |||||
1617 | try { | 1617 | try { | ||
1618 | m->addCurrency(curr); | 1618 | m->addCurrency(curr); | ||
1619 | QFAIL("Expected exception missing"); | 1619 | QFAIL("Expected exception missing"); | ||
1620 | } catch (const MyMoneyException &) { | 1620 | } catch (const std::exception &) { | ||
1621 | m->commitTransaction(); | 1621 | m->commitTransaction(); | ||
1622 | m->startTransaction(); | 1622 | m->startTransaction(); | ||
1623 | QCOMPARE(m->dirty(), false); | 1623 | QCOMPARE(m->dirty(), false); | ||
Context not available. | |||||
1637 | QCOMPARE(m->d_func()->m_currencyList.count(), 1); | 1637 | QCOMPARE(m->d_func()->m_currencyList.count(), 1); | ||
1638 | QCOMPARE(m->d_func()->m_currencyList["EUR"].name(), QLatin1String("EURO")); | 1638 | QCOMPARE(m->d_func()->m_currencyList["EUR"].name(), QLatin1String("EURO")); | ||
1639 | QCOMPARE(m->dirty(), true); | 1639 | QCOMPARE(m->dirty(), true); | ||
1640 | } catch (const MyMoneyException &) { | 1640 | } catch (const std::exception &) { | ||
1641 | QFAIL("Unexpected exception"); | 1641 | QFAIL("Unexpected exception"); | ||
1642 | } | 1642 | } | ||
1643 | 1643 | | |||
Context not available. | |||||
1647 | try { | 1647 | try { | ||
1648 | m->modifyCurrency(unknownCurr); | 1648 | m->modifyCurrency(unknownCurr); | ||
1649 | QFAIL("Expected exception missing"); | 1649 | QFAIL("Expected exception missing"); | ||
1650 | } catch (const MyMoneyException &) { | 1650 | } catch (const std::exception &) { | ||
1651 | m->commitTransaction(); | 1651 | m->commitTransaction(); | ||
1652 | m->startTransaction(); | 1652 | m->startTransaction(); | ||
1653 | QCOMPARE(m->dirty(), false); | 1653 | QCOMPARE(m->dirty(), false); | ||
Context not available. | |||||
1665 | m->startTransaction(); | 1665 | m->startTransaction(); | ||
1666 | QCOMPARE(m->d_func()->m_currencyList.count(), 0); | 1666 | QCOMPARE(m->d_func()->m_currencyList.count(), 0); | ||
1667 | QCOMPARE(m->dirty(), true); | 1667 | QCOMPARE(m->dirty(), true); | ||
1668 | } catch (const MyMoneyException &) { | 1668 | } catch (const std::exception &) { | ||
1669 | QFAIL("Unexpected exception"); | 1669 | QFAIL("Unexpected exception"); | ||
1670 | } | 1670 | } | ||
1671 | 1671 | | |||
Context not available. | |||||
1675 | try { | 1675 | try { | ||
1676 | m->removeCurrency(unknownCurr); | 1676 | m->removeCurrency(unknownCurr); | ||
1677 | QFAIL("Expected exception missing"); | 1677 | QFAIL("Expected exception missing"); | ||
1678 | } catch (const MyMoneyException &) { | 1678 | } catch (const std::exception &) { | ||
1679 | m->commitTransaction(); | 1679 | m->commitTransaction(); | ||
1680 | m->startTransaction(); | 1680 | m->startTransaction(); | ||
1681 | QCOMPARE(m->dirty(), false); | 1681 | QCOMPARE(m->dirty(), false); | ||
Context not available. | |||||
1695 | QCOMPARE(m->dirty(), false); | 1695 | QCOMPARE(m->dirty(), false); | ||
1696 | QCOMPARE(newCurr.id(), curr.id()); | 1696 | QCOMPARE(newCurr.id(), curr.id()); | ||
1697 | QCOMPARE(newCurr.name(), curr.name()); | 1697 | QCOMPARE(newCurr.name(), curr.name()); | ||
1698 | } catch (const MyMoneyException &) { | 1698 | } catch (const std::exception &) { | ||
1699 | QFAIL("Unexpected exception"); | 1699 | QFAIL("Unexpected exception"); | ||
1700 | } | 1700 | } | ||
1701 | 1701 | | |||
1702 | try { | 1702 | try { | ||
1703 | m->currency("DEM"); | 1703 | m->currency("DEM"); | ||
1704 | QFAIL("Expected exception missing"); | 1704 | QFAIL("Expected exception missing"); | ||
1705 | } catch (const MyMoneyException &) { | 1705 | } catch (const std::exception &) { | ||
1706 | m->commitTransaction(); | 1706 | m->commitTransaction(); | ||
1707 | m->startTransaction(); | 1707 | m->startTransaction(); | ||
1708 | QCOMPARE(m->dirty(), false); | 1708 | QCOMPARE(m->dirty(), false); | ||
Context not available. | |||||
1723 | QCOMPARE(m->d_func()->m_currencyList.count(), 2); | 1723 | QCOMPARE(m->d_func()->m_currencyList.count(), 2); | ||
1724 | QCOMPARE(m->currencyList().count(), 2); | 1724 | QCOMPARE(m->currencyList().count(), 2); | ||
1725 | QCOMPARE(m->dirty(), false); | 1725 | QCOMPARE(m->dirty(), false); | ||
1726 | } catch (const MyMoneyException &) { | 1726 | } catch (const std::exception &) { | ||
1727 | QFAIL("Unexpected exception"); | 1727 | QFAIL("Unexpected exception"); | ||
1728 | } | 1728 | } | ||
1729 | } | 1729 | } | ||
Context not available. |