25 #include <unittest-support.h>
28 #include <qofinstance-p.h>
30 #include "../Account.h"
31 #include "../AccountP.h"
33 #include "../Transaction.h"
34 #include "../gnc-lot.h"
41 #if defined(__clang__) && (__clang_major__ == 5 || (__clang_major__ == 3 && __clang_minor__ < 5))
42 #define USE_CLANG_FUNC_SIG 1
44 static const gchar *suitename =
"/engine/Account";
45 void test_suite_account (
void);
121 {
"waldo_baz",
"baz",
NREC, { -150000, 100}, {0, 1}, 0},
122 {
"waldo_meh",
"meh",
NREC, {150000, 100}, {0, 1}, 0}
127 {
"pepper_baz",
"baz",
CREC, { -12345, 100}, {0, 1}, 0},
128 {
"pepper_meh",
"meh",
CREC, {12345, 100}, {0, 1}, 0}
133 {
"salt_baz",
"baz",
YREC, { -31415, 100}, {0, 1}, 0},
134 {
"salt_meh",
"meh",
YREC, {31415, 100}, {0, 1}, 0}
139 {
"pork_baz",
"baz",
YREC, {23746, 100}, {0, 1}, 0},
140 {
"pork_meh",
"meh",
YREC, { -23746, 100}, {0, 1}, 0}
145 {
"sausage_baz",
"baz",
NREC, { -1143, 100}, {0, 1}, 0},
146 {
"sausage_meh",
"meh",
NREC, {1143, 100}, {0, 1}, 0}
200 {
"funding_money",
"money",
NREC, {1000000, 100}, {0, 1}, 0},
201 {
"funding_gift",
"gift",
NREC, {1000000, 100}, {0, 1}, 0}
206 {
"waldo_baz",
"baz",
NREC, {1500, 1}, {150899, 100}, 1},
207 {
"waldo_money",
"money",
NREC, { -150899, 100}, {0, 1}, 0}
212 {
"pepper_baz",
"baz",
CREC, { -500, 1}, { -69101, 100}, 1},
213 {
"pepper_money",
"money",
CREC, {69101, 100}, {0, 1}, 0}
218 {
"salt_baz",
"baz",
YREC, {1000, 1}, {120899, 10}, 2},
219 {
"salt_money",
"money",
YREC, { -120899, 100}, {0, 1}, 0}
224 {
"pork_baz",
"baz",
YREC, { -1000, 1}, { -79101, 100}, 1},
225 {
"pork_money",
"money",
YREC, {79101, 100}, {0, 1}, 0}
230 {
"sausage_baz",
"baz",
NREC, { -500, 1}, { -74101, 100}, 2},
231 {
"sausage_mmoney",
"money",
NREC, {74101, 100}, {0, 1}, 0}
236 {
"pork_baz2",
"baz2",
YREC, { -1000, 1}, { -79101, 100}, 1},
237 {
"pork_money",
"money",
YREC, {79101, 100}, {0, 1}, 0}
242 {
"sausage_baz2",
"baz2",
NREC, { -500, 1}, { -74101, 100}, 2},
243 {
"sausage_mmoney",
"money",
NREC, {74101, 100}, {0, 1}, 0}
248 {
"links_baz",
"baz",
NREC, {500, 1}, {60899, 100}, 3},
249 {
"links_mmoney",
"money",
NREC, { -60899, 100}, {0, 1}, 0}
254 static SetupData complex = {G_N_ELEMENTS (complex_accts),
258 static SetupData complex_data = {G_N_ELEMENTS (complex_accts),
260 G_N_ELEMENTS (lot_txns),
267 QofBook *book = gnc_account_get_book (parent);
272 g_assert (acct != NULL);
273 xaccSplitSetParent (split, txn);
279 "amount", &(p->amount),
280 "value", &(p->value),
287 if (p->lotnum > g_list_length (lotlist))
288 lot = gnc_lot_new (book);
290 lot = GNC_LOT (g_list_nth_data (lotlist, p->lotnum - 1));
297 setup (
Fixture *fixture, gconstpointer pData)
304 GHashTable *accts = g_hash_table_new (g_str_hash, g_str_equal);
307 g_hash_table_insert (accts,
"root", root);
308 fixture->func = _utest_account_fill_functions ();
311 fixture->acct = root;
317 for (ind = 0; ind < parms->num_accounts; ind++)
321 if (p.parent && strlen (p.parent) > 0)
323 Account *parent = g_hash_table_lookup (accts, p.parent);
324 g_assert (parent != NULL);
334 g_hash_table_insert (accts, p.name, acct);
351 for (ind = 0; ind < parms->num_txns; ind++)
355 GDate *date = g_date_new ();
360 if (p.date_offset < 0)
361 g_date_subtract_days (date, (guint)(-p.date_offset));
363 g_date_add_days (date, (guint)(p.date_offset));
365 insert_split (root, txn, &p.splits[0]);
366 insert_split (root, txn, &p.splits[1]);
370 fixture->acct = acct;
371 g_hash_table_destroy (accts);
372 gnc_set_account_separator (
":");
376 teardown (
Fixture *fixture, gconstpointer pData)
378 Account *child = fixture->acct;
381 g_free (fixture->func);
401 test_gnc_set_account_separator ()
404 const gunichar pass_sep = 0xE5A;
405 const gunichar fail_sep = 0x92A;
406 const gunichar default_sep =
':';
407 gunichar sep = gnc_get_account_separator ();
409 g_assert (sep == default_sep);
410 memset (sep_str, 0,
sizeof (sep_str));
411 g_unichar_to_utf8 (fail_sep, sep_str);
412 gnc_set_account_separator (sep_str);
413 sep = gnc_get_account_separator ();
414 g_assert (sep != fail_sep);
415 g_assert (sep == default_sep);
416 memset (sep_str, 0,
sizeof (sep_str));
417 g_unichar_to_utf8 (pass_sep, sep_str);
418 gnc_set_account_separator (sep_str);
419 sep = gnc_get_account_separator ();
420 g_assert (sep == pass_sep);
426 test_gnc_account_name_violations_errmsg ()
428 GList *badnames = NULL, *nonames = NULL, *node = NULL;
429 gchar *separator =
":", *message, *validation_message, *account_list = NULL;
431 badnames = g_list_prepend (badnames, g_strdup (
"Foo:bar"));
432 badnames = g_list_prepend (badnames, g_strdup (
"baz"));
433 badnames = g_list_prepend (badnames, g_strdup (
"waldo:pepper"));
435 for (node = badnames; node; node = g_list_next (node))
438 account_list = g_strdup (node->data);
441 gchar *tmp_list = g_strconcat ( account_list,
"\n",
443 g_free (account_list);
444 account_list = tmp_list;
448 g_assert (message == NULL);
449 validation_message = g_strdup_printf (
450 "The separator character \"%s\" is used in one or more account "
451 "names.\n\nThis will result in unexpected behaviour. "
452 "Either change the account names or choose another separator "
453 "character.\n\nBelow you will find the list of invalid account names:\n"
454 "%s", separator, account_list);
456 g_assert_cmpstr ( message, == , validation_message);
457 g_free (validation_message);
464 test_gnc_account_list_name_violations (
Fixture *fixture, gconstpointer pData)
466 guint log_level = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
467 gchar *log_domain =
"gnc.engine";
468 #ifdef USE_CLANG_FUNC_SIG
469 #define _func "GList *gnc_account_list_name_violations(QofBook *, const gchar *)"
471 #define _func "gnc_account_list_name_violations"
473 gchar *msg = _func
": assertion " _Q
"separator != NULL' failed";
476 GList *results, *res_iter;
478 QofBook *book = gnc_account_get_book (fixture->acct);
482 GLogFunc oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
483 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
485 g_assert_cmpint (check.hits, ==, 1);
487 g_assert_cmpint (check.hits, ==, 2);
489 g_log_set_default_handler (oldlogger, NULL);
491 g_assert_cmpuint (g_list_length (results), == , 2);
492 g_assert_cmpint (check.hits, ==, 2);
493 for (res_iter = results; res_iter; res_iter = g_list_next (res_iter))
494 test_free (res_iter->data);
495 g_list_free (results);
546 test_gnc_account_create_and_destroy (
void)
548 Account *acc = g_object_new (GNC_TYPE_ACCOUNT, NULL);
549 gchar *name, *fname, *code, *desc, *color, *notes, *tax_code, *tax_src;
552 gint commo_scu, mark;
553 gboolean non_std_scu, sort_dirty, bal_dirty, tax_rel, hide, hold;
555 gnc_numeric *start_bal, *start_clr_bal, *start_rec_bal;
563 "description", &desc,
568 "commodity_scu", &commo_scu,
569 "non-std-scu", &non_std_scu,
570 "sort-dirty", &sort_dirty,
571 "balance-dirty", &bal_dirty,
572 "start-balance", &start_bal,
573 "start-cleared-balance", &start_clr_bal,
574 "start-reconciled-balance", &start_rec_bal,
575 "end-balance", &end_bal,
576 "end-cleared-balance", &end_clr_bal,
577 "end-reconciled-balance", &end_rec_bal,
580 "tax-related", &tax_rel,
581 "tax-code", &tax_code,
582 "tax-source", &tax_src,
583 "tax-copy-number", ©_num,
585 "placeholder", &hold,
588 g_assert_cmpstr (name, == ,
"");
589 g_assert_cmpstr (fname, == ,
"");
590 g_assert_cmpstr (code, == ,
"");
591 g_assert_cmpstr (desc, == ,
"");
596 g_assert (!commo_scu);
597 g_assert (!non_std_scu);
598 g_assert (!sort_dirty);
599 g_assert (!bal_dirty);
609 g_assert (!tax_code);
611 g_assert (copy_num == 1);
627 g_object_unref (acc);
660 test_gnc_book_set_get_root_account (
Fixture *fixture, gconstpointer pData)
662 guint log_level = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
663 gchar *log_domain =
"gnc.account";
664 gchar *msg =
"[gnc_book_set_root_account()] cannot mix and match books freely!";
669 QofBook *book2 = gnc_account_get_book (fixture->acct);
670 acc1 = gnc_book_get_root_account (NULL);
675 acc1 = gnc_book_get_root_account (book1);
677 g_assert (acc1 != fixture->acct);
681 oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
682 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler,
684 gnc_book_set_root_account (book1, fixture->acct);
685 g_assert (gnc_book_get_root_account (book1) == acc1);
686 g_assert_cmpint (check.hits, ==, 1);
687 g_log_set_default_handler (oldlogger, NULL);
689 gnc_book_set_root_account (book2, fixture->acct);
690 g_assert (gnc_book_get_root_account (book2) == fixture->acct);
693 gnc_book_set_root_account (book1, acc2);
694 g_assert (gnc_book_get_root_account (book1) != acc1);
695 g_assert (gnc_book_get_root_account (book1) == acc2);
700 g_object_unref (book1);
701 g_object_unref (acc2);
708 test_xaccMallocAccount (
void)
712 TestSignal signal = test_signal_new (NULL, QOF_EVENT_CREATE, NULL);
714 g_assert (acc != NULL);
715 test_signal_assert_hits (signal, 1);
716 test_signal_free (signal);
717 g_object_unref (book);
718 g_object_unref (acc);
725 test_gnc_account_create_root (
void)
734 g_assert (func->coll_get_root_account (coll) == NULL);
737 g_object_get (acc,
"name", &name, NULL);
738 g_assert_cmpstr (name, == ,
"Root Account");
739 g_assert (gnc_book_get_root_account (book) == acc);
740 g_object_unref (book);
741 g_object_unref (acc);
750 test_xaccCloneAccount (
Fixture *fixture, gconstpointer pData)
753 QofBook *book = gnc_account_get_book (fixture->acct);
754 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
755 #ifdef USE_CLANG_FUNC_SIG
756 #define _func "Account *xaccCloneAccount(const Account *, QofBook *)"
758 #define _func "xaccCloneAccount"
760 gchar *msg1 = _func
": assertion " _Q
"GNC_IS_ACCOUNT(from)' failed";
761 gchar *msg2 = _func
": assertion " _Q
"QOF_IS_BOOK(book)' failed";
766 oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
767 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
769 g_assert (clone == NULL);
770 g_assert_cmpint (check.hits, ==, 1);
773 g_assert (clone == NULL);
774 g_assert_cmpint (check.hits, ==, 2);
775 g_log_set_default_handler (oldlogger, NULL);
779 acct_p = fixture->func->get_private (fixture->acct);
780 clone_p = fixture->func->get_private (clone);
781 g_assert (clone_p->type == acct_p->type);
782 g_assert (clone_p->accountName == acct_p->accountName);
783 g_assert (clone_p->accountCode == acct_p->accountCode);
784 g_assert (clone_p->description == acct_p->description);
786 fixture->acct->inst.kvp_data) == 0);
788 g_assert (clone_p->commodity_scu == acct_p->commodity_scu);
789 g_assert (clone_p->non_standard_scu == acct_p->non_standard_scu);
791 g_object_unref (clone);
804 test_xaccFreeAccountChildren (
Fixture *fixture, gconstpointer pData)
808 g_assert_cmpuint (g_list_length (priv->children), > , 0);
809 fixture->func->xaccFreeAccountChildren (root);
812 g_assert_cmpuint (g_list_length (priv->children), == , 0);
815 g_free (fixture->func);
854 test_xaccFreeAccount (
Fixture *fixture, gconstpointer pData)
856 gchar *msg1 =
"[xaccFreeAccount()] instead of calling xaccFreeAccount(), please call \n"
857 " xaccAccountBeginEdit(); xaccAccountDestroy(); \n";
858 #ifdef USE_CLANG_FUNC_SIG
859 #define _func "int xaccTransGetSplitIndex(const Transaction *, const Split *)"
861 #define _func "xaccTransGetSplitIndex"
863 gchar *msg2 = _func
": assertion " _Q
"trans && split' failed";
865 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
868 QofBook *book = gnc_account_get_book (fixture->acct);
871 const guint numItems = 3;
875 test_add_error (&check1);
876 test_add_error (&check2);
877 hdlr1 = g_log_set_handler (
"gnc.account", loglevel,
878 (GLogFunc)test_checked_handler, &check1);
879 hdlr2 = g_log_set_handler (
"gnc.engine", loglevel,
880 (GLogFunc)test_checked_handler, &check2);
881 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
882 for (i = 0; i < numItems; i++)
885 xaccSplitSetAccount (split, parent);
891 g_assert (p_priv->children != NULL);
892 g_assert (p_priv->lots != NULL);
893 g_assert (p_priv->splits != NULL);
894 g_assert (p_priv->parent != NULL);
895 g_assert (p_priv->commodity != NULL);
896 g_assert_cmpint (check1.hits, ==, 0);
897 g_assert_cmpint (check2.hits, ==, 0);
899 p_priv->cleared_balance = gnc_numeric_create ( 5, 12);
900 p_priv->reconciled_balance = gnc_numeric_create ( 5, 12);
901 p_priv->balance = gnc_numeric_create ( 5, 12);
902 p_priv->balance_dirty = TRUE;
903 p_priv->sort_dirty = TRUE;
904 fixture->func->xaccFreeAccount (parent);
905 g_assert_cmpint (check1.hits, ==, 6);
906 g_assert_cmpint (check2.hits, ==, 6);
908 g_log_remove_handler (
"gnc.account", hdlr1);
909 g_log_remove_handler (
"gnc.engine", hdlr2);
910 test_clear_error_list ();
912 g_free (fixture->func);
968 test_xaccAccountCommitEdit (
Fixture *fixture, gconstpointer pData)
970 gchar *msg1 =
"[xaccFreeAccount()] instead of calling xaccFreeAccount(), please call \n"
971 " xaccAccountBeginEdit(); xaccAccountDestroy(); \n";
972 #ifdef USE_CLANG_FUNC_SIG
973 #define _func "int xaccTransGetSplitIndex(const Transaction *, const Split *)"
975 #define _func "xaccTransGetSplitIndex"
977 gchar *msg2 = _func
": assertion " _Q
"trans && split' failed";
979 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
983 TestSignal sig1, sig2;
984 QofBook *book = gnc_account_get_book (fixture->acct);
987 const guint numItems = 3;
990 test_add_error (&check1);
991 test_add_error (&check2);
992 hdlr1 = g_log_set_handler (
"gnc.account", loglevel,
993 (GLogFunc)test_checked_handler, &check1);
994 hdlr2 = g_log_set_handler (
"gnc.engine", loglevel,
995 (GLogFunc)test_checked_handler, &check2);
996 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
997 for (i = 0; i < numItems; i++)
1000 xaccSplitSetAccount (split, parent);
1006 g_assert (p_priv->children != NULL);
1007 g_assert (p_priv->lots != NULL);
1008 g_assert (p_priv->splits != NULL);
1009 g_assert (p_priv->parent != NULL);
1010 g_assert (p_priv->commodity != NULL);
1011 g_assert_cmpint (check1.hits, ==, 0);
1012 g_assert_cmpint (check2.hits, ==, 0);
1014 sig1 = test_signal_new (&parent->inst, QOF_EVENT_MODIFY, NULL);
1015 sig2 = test_signal_new (&parent->inst, QOF_EVENT_DESTROY, NULL);
1020 test_signal_assert_hits (sig1, 1);
1021 test_signal_assert_hits (sig2, 0);
1022 g_assert (p_priv->children != NULL);
1023 g_assert (p_priv->lots != NULL);
1024 g_assert (p_priv->splits != NULL);
1025 g_assert (p_priv->parent != NULL);
1026 g_assert (p_priv->commodity != NULL);
1027 g_assert_cmpint (check1.hits, ==, 0);
1028 g_assert_cmpint (check2.hits, ==, 0);
1035 test_signal_assert_hits (sig1, 2);
1036 test_signal_assert_hits (sig2, 1);
1037 g_assert_cmpint (check1.hits, ==, 2);
1038 g_assert_cmpint (check2.hits, ==, 12);
1040 test_signal_free (sig1);
1041 test_signal_free (sig2);
1042 g_log_remove_handler (
"gnc.account", hdlr1);
1043 g_log_remove_handler (
"gnc.engine", hdlr2);
1044 test_clear_error_list ();
1046 g_free (fixture->func);
1081 test_gnc_account_insert_remove_split (
Fixture *fixture, gconstpointer pData)
1083 QofBook *book = gnc_account_get_book (fixture->acct);
1087 TestSignal sig1, sig2, sig3;
1088 AccountPrivate *priv = fixture->func->get_private (fixture->acct);
1089 #ifdef USE_CLANG_FUNC_SIG
1090 #define _func "gboolean gnc_account_insert_split(Account *, Split *)"
1092 #define _func "gnc_account_insert_split"
1094 gchar *msg1 = _func
": assertion " _Q
"GNC_IS_ACCOUNT(acc)' failed";
1095 gchar *msg2 = _func
": assertion " _Q
"GNC_IS_SPLIT(s)' failed";
1097 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
1103 sig1 = test_signal_new (&fixture->acct->inst, QOF_EVENT_MODIFY, NULL);
1106 test_add_error (&check1);
1107 test_add_error (&check2);
1108 logger = g_log_set_handler (
"gnc.engine", loglevel,
1109 (GLogFunc)test_null_handler, &check3);
1110 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
1114 g_assert_cmpuint (g_list_length (priv->splits), == , 0);
1115 g_assert (!priv->sort_dirty);
1116 g_assert (!priv->balance_dirty);
1117 test_signal_assert_hits (sig1, 0);
1118 test_signal_assert_hits (sig2, 0);
1120 g_assert_cmpuint (g_list_length (priv->splits), == , 0);
1121 g_assert (!priv->sort_dirty);
1122 g_assert (!priv->balance_dirty);
1123 test_signal_assert_hits (sig1, 0);
1124 test_signal_assert_hits (sig2, 0);
1131 g_assert_cmpint (check1.hits, ==, 1);
1132 g_assert_cmpint (check2.hits, ==, 1);
1133 g_assert_cmpint (check3.hits, ==, 0);
1134 g_log_remove_handler (
"gnc.engine", logger);
1135 test_clear_error_list ();
1139 g_assert_cmpuint (g_list_length (priv->splits), == , 1);
1140 g_assert (!priv->sort_dirty);
1141 g_assert (priv->balance_dirty);
1142 test_signal_assert_hits (sig1, 1);
1143 test_signal_assert_hits (sig2, 1);
1147 test_signal_free (sig2);
1151 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1152 g_assert (!priv->sort_dirty);
1153 g_assert (priv->balance_dirty);
1154 test_signal_assert_hits (sig1, 2);
1155 test_signal_assert_hits (sig3, 1);
1157 test_signal_free (sig3);
1159 qof_instance_increase_editlevel (fixture->acct);
1161 qof_instance_decrease_editlevel (fixture->acct);
1162 g_assert_cmpuint (g_list_length (priv->splits), == , 3);
1163 g_assert (priv->sort_dirty);
1164 g_assert (priv->balance_dirty);
1165 test_signal_assert_hits (sig1, 3);
1166 test_signal_assert_hits (sig3, 1);
1169 test_signal_free (sig3);
1170 sig3 = test_signal_new (&fixture->acct->inst, GNC_EVENT_ITEM_REMOVED,
1173 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1174 g_assert (priv->sort_dirty);
1175 g_assert (!priv->balance_dirty);
1176 test_signal_assert_hits (sig1, 4);
1177 test_signal_assert_hits (sig3, 1);
1181 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1182 g_assert (priv->sort_dirty);
1183 g_assert (!priv->balance_dirty);
1184 test_signal_assert_hits (sig1, 4);
1185 test_signal_assert_hits (sig3, 1);
1188 test_signal_free (sig3);
1189 test_signal_free (sig1);
1225 test_xaccAccountInsertRemoveLot (
Fixture *fixture, gconstpointer pData)
1227 QofBook *book = gnc_account_get_book (fixture->acct);
1228 GNCLot *lot = gnc_lot_new (book);
1230 TestSignal sig1 = test_signal_new (QOF_INSTANCE (lot),
1231 QOF_EVENT_ADD, NULL);
1232 TestSignal sig2 = test_signal_new (&fixture->acct->inst,
1233 QOF_EVENT_MODIFY, NULL);
1234 TestSignal sig3 = test_signal_new (QOF_INSTANCE (lot),
1235 QOF_EVENT_REMOVE, NULL);
1236 TestSignal sig4 = test_signal_new (&parent->inst, QOF_EVENT_MODIFY, NULL);
1238 AccountPrivate *a_priv = fixture->func->get_private (fixture->acct);
1241 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1242 g_assert_cmpuint (g_list_length (p_priv->lots), == , 0);
1245 g_assert_cmpuint (g_list_length (a_priv->lots), == , 1);
1246 test_signal_assert_hits (sig1, 1);
1247 test_signal_assert_hits (sig2, 1);
1251 g_assert_cmpuint (g_list_length (a_priv->lots), == , 1);
1252 test_signal_assert_hits (sig1, 1);
1253 test_signal_assert_hits (sig2, 1);
1257 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1258 g_assert_cmpuint (g_list_length (p_priv->lots), == , 1);
1259 test_signal_assert_hits (sig1, 2);
1260 test_signal_assert_hits (sig4, 1);
1261 test_signal_assert_hits (sig2, 1);
1263 xaccAccountRemoveLot (parent, lot);
1268 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1269 g_assert_cmpuint (g_list_length (p_priv->lots), == , 0);
1270 test_signal_assert_hits (sig3, 1);
1271 test_signal_assert_hits (sig4, 2);
1272 test_signal_assert_hits (sig2, 1);
1276 gnc_lot_set_account (lot, NULL);
1278 g_assert_cmpuint (g_list_length (p_priv->lots), == , 1);
1280 gnc_lot_destroy (lot);
1282 g_assert_cmpuint (g_list_length (p_priv->lots), != , 0);
1283 test_signal_assert_hits (sig1, 3);
1286 test_signal_assert_hits (sig4, 3);
1289 test_signal_assert_hits (sig3, 1);
1290 test_signal_free (sig1);
1291 test_signal_free (sig2);
1292 test_signal_free (sig3);
1293 test_signal_free (sig4);
1316 test_xaccAccountRecomputeBalance (
Fixture *fixture, gconstpointer pData)
1318 AccountPrivate *priv = fixture->func->get_private (fixture->acct);
1319 gnc_numeric bal = gnc_numeric_zero (), rec_bal = gnc_numeric_zero (),
1320 clr_bal = gnc_numeric_zero ();
1324 g_assert (sdata != NULL);
1326 for (ind = 0; ind < sdata->num_txns; ind++)
1329 bal = gnc_numeric_add_fixed (bal, p.amount);
1330 if (p.reconciled !=
NREC)
1331 clr_bal = gnc_numeric_add_fixed (clr_bal, p.amount);
1332 if (p.reconciled ==
YREC || p.reconciled ==
FREC)
1333 rec_bal = gnc_numeric_add_fixed (rec_bal, p.amount);
1337 priv->balance_dirty = TRUE;
1343 g_assert (!priv->balance_dirty);
1350 test_xaccAccountOrder ( )
1352 Account *aa = NULL, *ab = NULL;
1362 qof_instance_increase_editlevel (aa);
1363 qof_instance_increase_editlevel (ab);
1364 g_object_set (G_OBJECT (aa),
1369 g_object_set (G_OBJECT (ab),
1378 g_object_set (G_OBJECT (ab),
"name",
"bar", NULL);
1380 g_object_set (G_OBJECT (ab),
"name",
"waldo", NULL);
1384 g_test_message (
"The next test should fail: There's an error in the sort"
1385 " sequence that causes ACCT_TYPE_BANK to sort last"
1386 " instead of first\n");
1390 g_object_set (G_OBJECT (ab),
1396 g_object_set (G_OBJECT (ab),
"code",
"2222",
1400 g_object_set (G_OBJECT (ab),
1406 qof_instance_decrease_editlevel (aa);
1407 qof_instance_decrease_editlevel (ab);
1413 g_object_unref (book);
1447 test_qofAccountSetParent (
Fixture *fixture, gconstpointer pData)
1452 g_assert (root != old_parent);
1457 func->qofAccountSetParent (fixture->acct, QOF_INSTANCE (root));
1459 g_assert (qof_instance_get_dirty (QOF_INSTANCE (fixture->acct)));
1460 g_assert (qof_instance_get_dirty (QOF_INSTANCE (root)));
1461 g_assert (qof_instance_get_dirty (QOF_INSTANCE (old_parent)));
1470 test_gnc_account_append_remove_child (
Fixture *fixture, gconstpointer pData)
1472 QofBook *book = gnc_account_get_book (fixture->acct);
1476 gchar *logdomain =
"gnc.account";
1477 gchar *msg1 =
"[gnc_account_append_child()] reparenting accounts across books is not correctly supported\n";
1478 gchar *msg2 =
"[gnc_account_remove_child()] account not a child of parent";
1479 guint log_handler = 0;
1480 TestErrorStruct check_warn = {G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL,
"gnc.account", msg1, 0 };
1481 TestErrorStruct check_err = {G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL,
"gnc.account", msg2, 0 };
1482 TestSignal sig1, sig2, sig3;
1485 *apriv = func->get_private (fixture->acct);
1487 sig1 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_ADD, NULL);
1488 sig2 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_DESTROY, NULL);
1489 sig3 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_CREATE, NULL);
1493 test_signal_assert_hits (sig1, 1);
1494 test_signal_assert_hits (sig2, 0);
1495 test_signal_assert_hits (sig3, 0);
1496 g_assert_cmpint (check_warn.hits, ==, 0);
1497 g_assert_cmpint (check_err.hits, ==, 0);
1498 g_assert (qof_instance_get_dirty (QOF_INSTANCE (froot)));
1499 g_assert (qof_instance_get_dirty (QOF_INSTANCE (account)));
1500 g_assert (g_list_find (frpriv->children, account));
1504 log_handler = g_log_set_handler (logdomain, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, (GLogFunc)test_null_handler, &check_warn);
1505 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check_warn);
1507 g_log_remove_handler (logdomain, log_handler);
1508 g_assert_cmpstr (msg1, == , check_warn.msg);
1510 test_signal_assert_hits (sig1, 2);
1511 test_signal_assert_hits (sig2, 1);
1512 test_signal_assert_hits (sig3, 1);
1513 g_assert_cmpint (check_warn.hits, ==, 1);
1514 g_assert_cmpint (check_err.hits, ==, 0);
1521 g_assert (qof_instance_get_dirty (QOF_INSTANCE (fixture->acct)));
1522 g_assert (g_list_find (frpriv->children, account) == NULL);
1523 g_assert (g_list_find (apriv->children, account));
1525 test_signal_free (sig1);
1526 test_signal_free (sig2);
1527 test_signal_free (sig3);
1528 sig1 = test_signal_new (&account->inst, QOF_EVENT_REMOVE, NULL);
1529 sig2 = test_signal_new (&(fixture->acct)->inst, QOF_EVENT_MODIFY, NULL);
1530 log_handler = g_log_set_handler (logdomain, G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL,
1531 (GLogFunc)test_null_handler, &check_err);
1532 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check_err);
1534 g_log_remove_handler (logdomain, log_handler);
1536 test_signal_assert_hits (sig1, 0);
1537 test_signal_assert_hits (sig2, 0);
1538 g_assert_cmpint (check_err.hits, ==, 1);
1539 g_assert_cmpint (check_warn.hits, ==, 1);
1543 g_assert (g_list_find (apriv->children, account) == NULL);
1544 test_signal_assert_hits (sig1, 1);
1545 test_signal_assert_hits (sig2, 1);
1546 g_assert_cmpint (check_warn.hits, ==, 1);
1547 g_assert_cmpint (check_err.hits, ==, 1);
1548 test_signal_free (sig1);
1549 test_signal_free (sig2);
1554 g_object_unref (fbook);
1571 test_gnc_account_n_descendants (
Fixture *fixture, gconstpointer pData)
1581 test_gnc_account_get_current_depth (
Fixture *fixture, gconstpointer pData)
1590 test_gnc_account_get_tree_depth (
Fixture *fixture, gconstpointer pData)
1603 print_account (gpointer item, gpointer data)
1606 gchar *name, *code, *desc;
1608 const gchar *typestr;
1609 g_object_get (account,
1613 "description", &desc,
1616 g_test_message (
"%s: %s, %s %s", typestr, code, name, desc);
1623 test_gnc_account_get_descendants (
Fixture *fixture, gconstpointer pData)
1628 g_assert (list != NULL);
1629 g_assert_cmpuint (g_list_length (list), == , 34);
1630 g_assert_cmpint (g_list_index (list, fixture->acct), == , 33);
1633 g_assert (list == NULL);
1639 test_gnc_account_get_descendants_sorted (
Fixture *fixture, gconstpointer pData)
1643 g_assert (list != NULL);
1644 g_list_foreach (list, print_account, NULL);
1645 g_assert_cmpuint (g_list_length (list), == , 34);
1646 g_assert_cmpint (g_list_index (list, fixture->acct), == , 10);
1653 test_gnc_account_lookup_by_name (
Fixture *fixture, gconstpointer pData)
1659 g_assert (target != NULL);
1660 g_object_get (target,
"code", &code, NULL);
1661 g_assert_cmpstr (code, == ,
"4000");
1663 g_assert (target != NULL);
1665 g_object_get (target,
"code", &code, NULL);
1666 g_assert_cmpstr (code, == ,
"4160");
1668 g_assert (target != NULL);
1670 g_object_get (target,
"code", &code, NULL);
1671 g_assert_cmpstr (code, == ,
"2300");
1673 g_assert (target == NULL);
1681 test_gnc_account_lookup_by_code (
Fixture *fixture, gconstpointer pData)
1687 g_assert (target != NULL);
1688 g_object_get (target,
"name", &name, NULL);
1689 g_assert_cmpstr (name, == ,
"ordinary");
1692 g_assert (target != NULL);
1693 g_object_get (target,
"name", &name, NULL);
1694 g_assert_cmpstr (name, == ,
"utilities");
1696 g_assert (target == NULL);
1704 test_gnc_account_lookup_by_full_name_helper (
Fixture *fixture,
1705 gconstpointer pData )
1708 gchar *names1[] = {
"income",
"taxable",
"int", NULL};
1709 gchar *names2[] = {
"income",
"exempt",
"int", NULL};
1710 gchar *names3[] = {
"expense",
"taxable",
"int", NULL};
1715 target = func->gnc_account_lookup_by_full_name_helper (root, names1);
1716 g_assert (target != NULL);
1717 g_object_get (target,
"code", &code, NULL);
1718 g_assert_cmpstr (code, == ,
"4160");
1720 target = func->gnc_account_lookup_by_full_name_helper (root, names2);
1721 g_assert (target != NULL);
1722 g_object_get (target,
"code", &code, NULL);
1723 g_assert_cmpstr (code, == ,
"4210");
1724 target = func->gnc_account_lookup_by_full_name_helper (root, names3);
1725 g_assert (target == NULL);
1732 test_gnc_account_lookup_by_full_name (
Fixture *fixture, gconstpointer pData)
1735 gchar *names1 =
"income:taxable:int";
1736 gchar *names2 =
"income:exempt:int";
1737 gchar *names3 =
"expense:taxable:int";
1742 g_assert (target != NULL);
1743 g_object_get (target,
"code", &code, NULL);
1744 g_assert_cmpstr (code, == ,
"4160");
1747 g_assert (target != NULL);
1748 g_object_get (target,
"code", &code, NULL);
1749 g_assert_cmpstr (code, == ,
"4210");
1751 g_assert (target == NULL);
1756 thunk (
Account *s, gpointer data)
1758 guint *counter = (guint*)data;
1759 g_assert (GNC_IS_ACCOUNT (s));
1764 thunk2 (
Account *s, gpointer data)
1766 guint *counter = (guint*)data;
1768 g_assert (GNC_IS_ACCOUNT (s));
1769 g_object_get (G_OBJECT (s),
"name", &name, NULL);
1770 if (!g_strcmp0 (name,
"int"))
1783 test_gnc_account_foreach_child (
Fixture *fixture, gconstpointer pData)
1789 g_assert_cmpint (counter, == , 2);
1815 test_gnc_account_foreach_descendant (
Fixture *fixture, gconstpointer pData)
1821 g_assert_cmpint (counter, == , 13);
1827 test_gnc_account_foreach_descendant_until (
Fixture *fixture, gconstpointer pData)
1836 g_assert_cmpint (counter, == , 11);
1837 g_assert (result == NULL);
1840 g_assert (result == expected);
1841 g_assert_cmpint (counter, == , 6);
1864 test_gnc_account_get_full_name (
Fixture *fixture, gconstpointer pData)
1868 g_assert (result != NULL);
1869 g_assert_cmpstr (result, == ,
"");
1872 g_assert (result != NULL);
1873 g_assert_cmpstr (result, == ,
"");
1876 g_assert (result != NULL);
1877 g_assert_cmpstr (result, == ,
"foo:baz:waldo");
1891 test_xaccAccountGetProjectedMinimumBalance (
Fixture *fixture, gconstpointer pData)
1900 g_assert (sdata != NULL);
1902 for (ind = 0; ind < min_ind; ind++)
1905 bal = gnc_numeric_add_fixed (bal, p.amount);
1908 val = xaccAccountGetProjectedMinimumBalance (fixture->acct);
1910 g_assert_cmpfloat (dval, == , 0.0);
1912 val = xaccAccountGetProjectedMinimumBalance (fixture->acct);
1914 g_assert_cmpfloat (dval, == , dbal);
1920 test_xaccAccountGetBalanceAsOfDate (
Fixture *fixture, gconstpointer pData)
1929 gint offset = 24 * 3600 * 3;
1930 g_assert (sdata != NULL);
1932 for (ind = 0; ind < min_ind; ind++)
1935 bal = gnc_numeric_add_fixed (bal, p.amount);
1942 g_assert_cmpfloat (dval, == , dbal);
1948 test_xaccAccountGetPresentBalance (
Fixture *fixture, gconstpointer pData)
1957 g_assert (sdata != NULL);
1959 for (ind = 0; ind < min_ind; ind++)
1962 bal = gnc_numeric_add_fixed (bal, p.amount);
1966 val = xaccAccountGetPresentBalance (fixture->acct);
1968 g_assert_cmpfloat (dval, == , dbal);
2005 bogus_lot_match_func_true (
GNCLot *lot, gpointer p_data)
2011 bogus_lot_match_func_false (
GNCLot *lot, gpointer p_data)
2016 static guint count_sorts = 0;
2018 bogus_lot_sort_func (gconstpointer a, gconstpointer b)
2025 test_xaccAccountFindOpenLots (
Fixture *fixture, gconstpointer pData)
2033 g_assert (g_list_length (lots) == 2);
2034 if (lots) g_list_free (lots);
2037 g_assert (g_list_length (lots) == 2);
2038 if (lots) g_list_free (lots);
2041 g_assert (g_list_length (lots) == 0);
2042 if (lots) g_list_free (lots);
2044 g_assert_cmpint (count_sorts, == , 1);
2045 g_assert (g_list_length (lots) == 2);
2046 if (lots) g_list_free (lots);
2051 bogus_for_each_lot_func (
GNCLot *lot, gpointer data)
2053 guint *count = data;
2055 return (*count > 4 ? lot : NULL);
2062 test_xaccAccountForEachLot (
Fixture *fixture, gconstpointer pData)
2066 guint count_calls = 0;
2070 g_assert_cmpint (count_calls, == , 3);
2072 g_assert_cmpint (count_calls, == , 5);
2094 test_xaccAccountHasAncestor (
Fixture *fixture, gconstpointer pData)
2118 test_xaccAccountType_Stuff (
void)
2121 gint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
2122 gchar *logdomain =
"gnc.account";
2123 gchar *msg1 = g_strdup_printf (
"[xaccAccountTypeEnumAsString()] asked to translate unknown account type %d.\n", ACCT_TYPE_LAST);
2124 gchar *msg2 =
"[xaccAccountStringToType()] asked to translate unknown account type string (null).\n";
2125 gchar *msg3 =
"[xaccAccountStringToType()] asked to translate unknown account type string LAST.\n";
2126 guint loghandler = 0;
2130 Account *acc = g_object_new (GNC_TYPE_ACCOUNT, NULL);
2132 for (type =
ACCT_TYPE_NONE; type < ACCT_TYPE_LAST; type = type + 1)
2135 const gchar *typestr;
2138 g_assert (type_name);
2144 typestr_uc = g_ascii_strup (typestr, strlen (typestr));
2147 gchar *cmpstr = g_strconcat (
"A/", type_name, NULL);
2148 g_assert_cmpstr (typestr_uc, == , cmpstr);
2153 gchar *cmpstr = g_strconcat (type_name,
" CARD", NULL);
2154 g_assert_cmpstr (typestr_uc, == , cmpstr);
2159 gchar *cmpstr = g_strconcat (type_name,
" FUND", NULL);
2160 g_assert_cmpstr (typestr_uc, == , cmpstr);
2164 g_assert_cmpstr (typestr_uc, == , type_name);
2165 g_free (typestr_uc);
2167 qof_instance_increase_editlevel (acc);
2168 g_object_set (acc,
"type", type, NULL);
2169 qof_instance_decrease_editlevel (acc);
2177 g_object_unref (acc);
2179 loghandler = g_log_set_handler (logdomain, loglevel,
2180 (GLogFunc)test_null_handler, &check1);
2181 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check1);
2183 g_assert_cmpint (check1.hits, ==, 1);
2185 g_log_remove_handler (logdomain, loghandler);
2187 loghandler = g_log_set_handler (logdomain, loglevel,
2188 (GLogFunc)test_null_handler, &check2);
2189 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check2);
2191 g_assert_cmpint (check2.hits, ==, 1);
2193 g_log_remove_handler (logdomain, loghandler);
2194 loghandler = g_log_set_handler (logdomain, loglevel,
2195 (GLogFunc)test_null_handler, &check3);
2196 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check3);
2198 g_assert_cmpint (check3.hits, ==, 1);
2200 g_log_remove_handler (logdomain, loghandler);
2209 test_xaccAccountType_Compatibility (
void)
2229 gchar *msg1 = g_strdup_printf (
"[xaccParentAccountTypesCompatibleWith()] bad account type: %d",
ACCT_TYPE_ROOT);
2230 gchar *msg2 = g_strdup_printf (
"[xaccParentAccountTypesCompatibleWith()] bad account type: %d",
ACCT_TYPE_SAVINGS);
2231 gchar *logdomain =
"gnc.account";
2232 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
2242 loghandler = g_log_set_handler (logdomain, loglevel,
2243 (GLogFunc)test_null_handler, &check1);
2244 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler,
2247 g_log_remove_handler (logdomain, loghandler);
2248 g_assert_cmpint (compat, == , 0);
2249 g_assert_cmpint (check1.hits, ==, 1);
2257 g_assert_cmpint (compat, == , bank_compat);
2259 g_assert_cmpint (compat, == , expense_compat);
2261 g_assert_cmpint (compat, == , equity_compat);
2263 g_assert_cmpint (compat, == , trading_compat);
2264 for (child =
ACCT_TYPE_NONE; child < ACCT_TYPE_LAST; child = child + 1)
2265 if (1 << child & compat)
2271 loghandler = g_log_set_handler (logdomain, loglevel,
2272 (GLogFunc)test_null_handler, &check2);
2273 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check2);
2275 g_log_remove_handler (logdomain, loghandler);
2276 g_assert_cmpint (compat, == , 0);
2277 g_assert_cmpint (check2.hits, ==, 1);
2310 test_xaccAccountFindSplitByDesc (
Fixture *fixture, gconstpointer pData)
2317 g_object_get (split,
"memo", &memo, NULL);
2318 g_assert_cmpstr (memo, == ,
"pepper_baz");
2325 test_xaccAccountFindTransByDesc (
Fixture *fixture, gconstpointer pData)
2332 g_object_get (txn,
"description", &desc, NULL);
2333 g_assert_cmpstr (desc, == ,
"pepper");
2340 test_gnc_account_join_children (
Fixture *fixture, gconstpointer pData)
2348 g_test_message (
"The following should fail because of account type incompatibility. It doesn't, which is a bug.");
2351 broker_desc + income_desc);
2359 test_gnc_account_merge_children (
Fixture *fixture, gconstpointer pData)
2368 TestSignal sig4, sig5;
2411 sig4 = test_signal_new (QOF_INSTANCE (div), QOF_EVENT_MODIFY, NULL);
2412 sig5 = test_signal_new (QOF_INSTANCE (div1), QOF_EVENT_MODIFY, NULL);
2413 qof_instance_increase_editlevel (div1);
2414 g_object_set (div1,
"name",
"div", NULL);
2415 qof_instance_decrease_editlevel (div1);
2418 test_signal_assert_hits (sig4, 1);
2419 test_signal_assert_hits (sig5, 3);
2420 test_signal_free (sig4);
2421 test_signal_free (sig5);
2459 g_object_get (txn,
"description", &txn_desc, NULL);
2460 result = g_strcmp0 (td->name, txn_desc) == 0;
2473 test_xaccAccountTreeForEachTransaction (
Fixture *fixture, gconstpointer pData )
2479 g_assert_cmpint (td.count, == , 9);
2480 g_assert_cmpint (result, == , 0);
2484 g_assert_cmpint (td.count, == , result);
2485 g_assert_cmpint (result, < , 9);
2491 test_xaccAccountForEachTransaction (
Fixture *fixture, gconstpointer pData )
2498 g_assert_cmpint (td.count, == , 0);
2501 g_assert_cmpint (td.count, == , 9);
2502 g_assert_cmpint (result, == , 0);
2506 g_assert_cmpint (td.count, == , result);
2507 g_assert_cmpint (result, < , 9);
2512 test_suite_account (
void)
2515 GNC_TEST_ADD_FUNC (suitename,
"gnc set account separator", test_gnc_set_account_separator);
2516 GNC_TEST_ADD_FUNC (suitename,
"gnc account name violations errmsg", test_gnc_account_name_violations_errmsg);
2517 GNC_TEST_ADD (suitename,
"gnc account list name violations",
Fixture, &bad_data, setup, test_gnc_account_list_name_violations, teardown);
2518 GNC_TEST_ADD_FUNC (suitename,
"account create and destroy", test_gnc_account_create_and_destroy);
2519 GNC_TEST_ADD (suitename,
"book set/get root account",
Fixture, NULL, setup, test_gnc_book_set_get_root_account, teardown);
2520 GNC_TEST_ADD_FUNC (suitename,
"xaccMallocAccount", test_xaccMallocAccount);
2522 GNC_TEST_ADD_FUNC (suitename,
"gnc account create root", test_gnc_account_create_root);
2523 GNC_TEST_ADD (suitename,
"xaccCloneAccount",
Fixture, NULL, setup, test_xaccCloneAccount, teardown );
2525 GNC_TEST_ADD (suitename,
"xaccFreeAccountChildren",
Fixture, &good_data, setup, test_xaccFreeAccountChildren, NULL);
2527 GNC_TEST_ADD (suitename,
"xaccFreeAccount",
Fixture, &good_data, setup, test_xaccFreeAccount, NULL );
2528 GNC_TEST_ADD (suitename,
"xaccAccountCommitEdit",
Fixture, &good_data, setup, test_xaccAccountCommitEdit, NULL );
2531 GNC_TEST_ADD (suitename,
"gnc account insert & remove split",
Fixture, NULL, setup, test_gnc_account_insert_remove_split, teardown );
2532 GNC_TEST_ADD (suitename,
"xaccAccount Insert and Remove Lot",
Fixture, &good_data, setup, test_xaccAccountInsertRemoveLot, teardown );
2533 GNC_TEST_ADD (suitename,
"xaccAccountRecomputeBalance",
Fixture, &some_data, setup, test_xaccAccountRecomputeBalance, teardown );
2534 GNC_TEST_ADD_FUNC (suitename,
"xaccAccountOrder", test_xaccAccountOrder );
2535 GNC_TEST_ADD (suitename,
"qofAccountSetParent",
Fixture, &some_data, setup, test_qofAccountSetParent, teardown );
2536 GNC_TEST_ADD (suitename,
"gnc account append/remove child",
Fixture, NULL, setup, test_gnc_account_append_remove_child, teardown );
2537 GNC_TEST_ADD (suitename,
"gnc account n descendants",
Fixture, &some_data, setup, test_gnc_account_n_descendants, teardown );
2538 GNC_TEST_ADD (suitename,
"gnc account get current depth",
Fixture, &some_data, setup, test_gnc_account_get_current_depth, teardown );
2539 GNC_TEST_ADD (suitename,
"gnc account get tree depth",
Fixture, &complex, setup, test_gnc_account_get_tree_depth, teardown );
2540 GNC_TEST_ADD (suitename,
"gnc account get descendants",
Fixture, &complex, setup, test_gnc_account_get_descendants, teardown );
2541 GNC_TEST_ADD (suitename,
"gnc account get descendants sorted",
Fixture, &complex, setup, test_gnc_account_get_descendants_sorted, teardown );
2542 GNC_TEST_ADD (suitename,
"gnc account lookup by name",
Fixture, &complex, setup, test_gnc_account_lookup_by_name, teardown );
2543 GNC_TEST_ADD (suitename,
"gnc account lookup by code",
Fixture, &complex, setup, test_gnc_account_lookup_by_code, teardown );
2544 GNC_TEST_ADD (suitename,
"gnc account lookup by full name helper",
Fixture, &complex, setup, test_gnc_account_lookup_by_full_name_helper, teardown );
2545 GNC_TEST_ADD (suitename,
"gnc account lookup by full name",
Fixture, &complex, setup, test_gnc_account_lookup_by_full_name, teardown );
2546 GNC_TEST_ADD (suitename,
"gnc account foreach child",
Fixture, &complex, setup, test_gnc_account_foreach_child, teardown );
2547 GNC_TEST_ADD (suitename,
"gnc account foreach descendant",
Fixture, &complex, setup, test_gnc_account_foreach_descendant, teardown );
2548 GNC_TEST_ADD (suitename,
"gnc account foreach descendant until",
Fixture, &complex, setup, test_gnc_account_foreach_descendant_until, teardown );
2549 GNC_TEST_ADD (suitename,
"gnc account get full name",
Fixture, &good_data, setup, test_gnc_account_get_full_name, teardown );
2550 GNC_TEST_ADD (suitename,
"xaccAccountGetProjectedMinimumBalance",
Fixture, &some_data, setup, test_xaccAccountGetProjectedMinimumBalance, teardown );
2551 GNC_TEST_ADD (suitename,
"xaccAccountGetBalanceAsOfDate",
Fixture, &some_data, setup, test_xaccAccountGetBalanceAsOfDate, teardown );
2552 GNC_TEST_ADD (suitename,
"xaccAccountGetPresentBalance",
Fixture, &some_data, setup, test_xaccAccountGetPresentBalance, teardown );
2553 GNC_TEST_ADD (suitename,
"xaccAccountFindOpenLots",
Fixture, &complex_data, setup, test_xaccAccountFindOpenLots, teardown );
2554 GNC_TEST_ADD (suitename,
"xaccAccountForEachLot",
Fixture, &complex_data, setup, test_xaccAccountForEachLot, teardown );
2556 GNC_TEST_ADD (suitename,
"xaccAccountHasAncestor",
Fixture, &complex, setup, test_xaccAccountHasAncestor, teardown );
2557 GNC_TEST_ADD_FUNC (suitename,
"AccountType Stuff", test_xaccAccountType_Stuff );
2558 GNC_TEST_ADD_FUNC (suitename,
"AccountType Compatibility", test_xaccAccountType_Compatibility);
2559 GNC_TEST_ADD (suitename,
"xaccAccountFindSplitByDesc",
Fixture, &complex_data, setup, test_xaccAccountFindSplitByDesc, teardown );
2560 GNC_TEST_ADD (suitename,
"xaccAccountFindTransByDesc",
Fixture, &complex_data, setup, test_xaccAccountFindTransByDesc, teardown );
2561 GNC_TEST_ADD (suitename,
"gnc account join children",
Fixture, &complex, setup, test_gnc_account_join_children, teardown );
2562 GNC_TEST_ADD (suitename,
"gnc account merge children",
Fixture, &complex_data, setup, test_gnc_account_merge_children, teardown );
2563 GNC_TEST_ADD (suitename,
"xaccAccountForEachTransaction",
Fixture, &complex_data, setup, test_xaccAccountForEachTransaction, teardown );
2564 GNC_TEST_ADD (suitename,
"xaccAccountTreeForEachTransaction",
Fixture, &complex_data, setup, test_xaccAccountTreeForEachTransaction, teardown );
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Account * gnc_account_get_parent(const Account *acc)
gint xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc, void *data)
int xaccAccountTreeForEachTransaction(Account *acc, TransactionCallback proc, void *data)
Transaction * xaccMallocTransaction(QofBook *book)
void gnc_account_append_child(Account *new_parent, Account *child)
const GncGUID * qof_instance_get_guid(gconstpointer)
gpointer xaccAccountForEachLot(const Account *acc, gpointer(*proc)(GNCLot *lot, gpointer user_data), gpointer user_data)
GList * gnc_account_get_descendants_sorted(const Account *account)
gint gnc_account_n_descendants(const Account *account)
SplitList * xaccAccountGetSplitList(const Account *acc)
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
void xaccAccountSetNotes(Account *acc, const char *str)
gboolean xaccAccountIsPriced(const Account *acc)
QofInstance * qof_collection_lookup_entity(const QofCollection *, const GncGUID *)
Account * gnc_account_create_root(QofBook *book)
gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb)
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
void xaccAccountSetCode(Account *acc, const char *str)
QofBook * qof_book_new(void)
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
void gnc_account_set_policy(Account *acc, GNCPolicy *policy)
void gnc_lot_add_split(GNCLot *lot, Split *split)
void xaccTransSetDescription(Transaction *trans, const char *desc)
gboolean gnc_account_remove_split(Account *acc, Split *s)
gboolean gnc_numeric_zero_p(gnc_numeric a)
const char * xaccAccountTypeEnumAsString(GNCAccountType type)
void xaccSplitSetReconcile(Split *split, char recn)
GList * gnc_account_list_name_violations(QofBook *book, const gchar *separator)
void xaccAccountInsertLot(Account *acc, GNCLot *lot)
gboolean qof_commit_edit(QofInstance *inst)
void xaccAccountSetLastNum(Account *acc, const char *num)
void xaccTransSetDatePostedGDate(Transaction *trans, GDate date)
void xaccAccountDestroy(Account *acc)
Account * gnc_account_lookup_by_name(const Account *parent, const char *name)
void gnc_account_remove_child(Account *parent, Account *child)
int xaccAccountOrder(const Account *aa, const Account *ab)
Split * xaccAccountFindSplitByDesc(const Account *acc, const char *description)
gdouble gnc_numeric_to_double(gnc_numeric n)
GNCAccountType xaccAccountStringToEnum(const char *str)
gchar * gnc_account_get_full_name(const Account *account)
gboolean xaccAccountTypesCompatible(GNCAccountType parent_type, GNCAccountType child_type)
gchar * gnc_account_name_violations_errmsg(const gchar *separator, GList *invalid_account_names)
void xaccAccountSetColor(Account *acc, const char *str)
Transaction * xaccAccountFindTransByDesc(const Account *acc, const char *description)
void gnc_account_foreach_child(const Account *acc, AccountCb thunk, gpointer user_data)
Account * gnc_account_lookup_by_code(const Account *parent, const char *code)
void xaccSplitSetMemo(Split *split, const char *memo)
gnc_commodity * gnc_commodity_new(QofBook *book, const char *fullname, const char *name_space, const char *mnemonic, const char *cusip, int fraction)
LotList * xaccAccountGetLotList(const Account *acc)
void xaccAccountRecomputeBalance(Account *acc)
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Additional event handling code.
Account * xaccCloneAccount(const Account *from, QofBook *book)
void xaccTransBeginEdit(Transaction *trans)
void gnc_account_join_children(Account *to_parent, Account *from_parent)
gnc_numeric xaccAccountGetBalanceAsOfDate(Account *acc, time64 date)
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
Split * xaccMallocSplit(QofBook *book)
gboolean gnc_account_insert_split(Account *acc, Split *s)
GList * gnc_account_get_descendants(const Account *account)
guint32 xaccParentAccountTypesCompatibleWith(GNCAccountType type)
GList * gnc_account_get_children(const Account *account)
void xaccAccountBeginEdit(Account *acc)
gboolean xaccAccountHasAncestor(const Account *acc, const Account *ancestor)
gint qof_instance_guid_compare(const gconstpointer ptr1, const gconstpointer ptr2)
gint gnc_account_get_current_depth(const Account *account)
Account * xaccMallocAccount(QofBook *book)
time64 gnc_time(time64 *tbuf)
get the current local time
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
Account * gnc_lot_get_account(const GNCLot *lot)
void xaccAccountSetDescription(Account *acc, const char *str)
LotList * xaccAccountFindOpenLots(const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func)
Account * gnc_account_get_root(Account *acc)
const char * xaccAccountGetTypeStr(GNCAccountType type)
#define GNC_EVENT_ITEM_ADDED
void xaccAccountCommitEdit(Account *acc)
void xaccAccountSetName(Account *acc, const char *str)
void gnc_account_merge_children(Account *parent)
void qof_book_destroy(QofBook *book)
void gnc_gdate_set_time64(GDate *gd, time64 time)
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
gint gnc_account_get_tree_depth(const Account *account)
GNCPolicy * xaccGetFIFOPolicy(void)