25 #include <unittest-support.h>
30 static const gchar *suitename =
"/engine/Budget";
31 void test_suite_budget(
void);
108 {
"waldo_baz",
"baz",
NREC, { -150000, 100}, {0, 1}, 0},
109 {
"waldo_meh",
"meh",
NREC, {150000, 100}, {0, 1}, 0}
114 {
"pepper_baz",
"baz",
CREC, { -12345, 100}, {0, 1}, 0},
115 {
"pepper_meh",
"meh",
CREC, {12345, 100}, {0, 1}, 0}
120 {
"salt_baz",
"baz",
YREC, { -31415, 100}, {0, 1}, 0},
121 {
"salt_meh",
"meh",
YREC, {31415, 100}, {0, 1}, 0}
126 {
"pork_baz",
"baz",
YREC, {23746, 100}, {0, 1}, 0},
127 {
"pork_meh",
"meh",
YREC, { -23746, 100}, {0, 1}, 0}
132 {
"sausage_baz",
"baz",
NREC, { -1143, 100}, {0, 1}, 0},
133 {
"sausage_meh",
"meh",
NREC, {1143, 100}, {0, 1}, 0}
187 {
"funding_money",
"money",
NREC, {1000000, 100}, {0, 1}, 0},
188 {
"funding_gift",
"gift",
NREC, {1000000, 100}, {0, 1}, 0}
193 {
"waldo_baz",
"baz",
NREC, {1500, 1}, {150899, 100}, 1},
194 {
"waldo_money",
"money",
NREC, { -150899, 100}, {0, 1}, 0}
199 {
"pepper_baz",
"baz",
CREC, { -500, 1}, { -69101, 100}, 1},
200 {
"pepper_money",
"money",
CREC, {69101, 100}, {0, 1}, 0}
205 {
"salt_baz",
"baz",
YREC, {1000, 1}, {120899, 10}, 2},
206 {
"salt_money",
"money",
YREC, { -120899, 100}, {0, 1}, 0}
211 {
"pork_baz",
"baz",
YREC, { -1000, 1}, { -79101, 100}, 1},
212 {
"pork_money",
"money",
YREC, {79101, 100}, {0, 1}, 0}
217 {
"sausage_baz",
"baz",
NREC, { -500, 1}, { -74101, 100}, 2},
218 {
"sausage_mmoney",
"money",
NREC, {74101, 100}, {0, 1}, 0}
223 {
"pork_baz2",
"baz2",
YREC, { -1000, 1}, { -79101, 100}, 1},
224 {
"pork_money",
"money",
YREC, {79101, 100}, {0, 1}, 0}
229 {
"sausage_baz2",
"baz2",
NREC, { -500, 1}, { -74101, 100}, 2},
230 {
"sausage_mmoney",
"money",
NREC, {74101, 100}, {0, 1}, 0}
235 {
"links_baz",
"baz",
NREC, {500, 1}, {60899, 100}, 3},
236 {
"links_mmoney",
"money",
NREC, { -60899, 100}, {0, 1}, 0}
241 static SetupData complex = {G_N_ELEMENTS (complex_accts),
245 static SetupData complex_data = {G_N_ELEMENTS (complex_accts),
247 G_N_ELEMENTS (lot_txns),
254 QofBook *book = gnc_account_get_book (parent);
259 g_assert (acct != NULL);
260 xaccSplitSetParent (split, txn);
266 "amount", &(p->amount),
267 "value", &(p->value),
274 if (p->lotnum > g_list_length (lotlist))
275 lot = gnc_lot_new (book);
277 lot = GNC_LOT (g_list_nth_data (lotlist, p->lotnum - 1));
284 setup (
Fixture *fixture, gconstpointer pData)
291 GHashTable *accts = g_hash_table_new (g_str_hash, g_str_equal);
294 g_hash_table_insert (accts,
"root", root);
295 fixture->func = _utest_account_fill_functions ();
298 fixture->acct = root;
304 for (ind = 0; ind < parms->num_accounts; ind++)
308 if (p.parent && strlen (p.parent) > 0)
310 Account *parent = g_hash_table_lookup (accts, p.parent);
311 g_assert (parent != NULL);
321 g_hash_table_insert (accts, p.name, acct);
338 for (ind = 0; ind < parms->num_txns; ind++)
342 GDate *date = g_date_new ();
347 if (p.date_offset < 0)
348 g_date_subtract_days (date, (guint)(-p.date_offset));
350 g_date_add_days (date, (guint)(p.date_offset));
352 insert_split (root, txn, &p.splits[0]);
353 insert_split (root, txn, &p.splits[1]);
357 fixture->acct = acct;
358 g_hash_table_destroy (accts);
359 gnc_set_account_separator (
":");
363 teardown (
Fixture *fixture, gconstpointer pData)
365 Account *child = fixture->acct;
368 g_free (fixture->func);
388 test_gnc_set_account_separator ()
391 const gunichar pass_sep = 0xE5A;
392 const gunichar fail_sep = 0x92A;
393 const gunichar default_sep =
':';
394 gunichar sep = gnc_get_account_separator ();
396 g_assert (sep == default_sep);
397 memset (sep_str, 0,
sizeof (sep_str));
398 g_unichar_to_utf8 (fail_sep, sep_str);
399 gnc_set_account_separator (sep_str);
400 sep = gnc_get_account_separator ();
401 g_assert (sep != fail_sep);
402 g_assert (sep == default_sep);
403 memset (sep_str, 0,
sizeof (sep_str));
404 g_unichar_to_utf8 (pass_sep, sep_str);
405 gnc_set_account_separator (sep_str);
406 sep = gnc_get_account_separator ();
407 g_assert (sep == pass_sep);
413 test_gnc_account_name_violations_errmsg ()
415 GList *badnames = NULL, *nonames = NULL, *node = NULL;
416 gchar *separator =
":", *message, *validation_message, *account_list = NULL;
418 badnames = g_list_prepend (badnames, g_strdup (
"Foo:bar"));
419 badnames = g_list_prepend (badnames, g_strdup (
"baz"));
420 badnames = g_list_prepend (badnames, g_strdup (
"waldo:pepper"));
422 for (node = badnames; node; node = g_list_next (node))
425 account_list = g_strdup (node->data);
428 gchar *tmp_list = g_strconcat ( account_list,
"\n",
430 g_free (account_list);
431 account_list = tmp_list;
435 g_assert (message == NULL);
436 validation_message = g_strdup_printf (
437 "The separator character \"%s\" is used in one or more account "
438 "names.\n\nThis will result in unexpected behaviour. "
439 "Either change the account names or choose another separator "
440 "character.\n\nBelow you will find the list of invalid account names:\n"
441 "%s", separator, account_list);
443 g_assert_cmpstr ( message, == , validation_message);
444 g_free (validation_message);
451 test_gnc_account_list_name_violations (
Fixture *fixture, gconstpointer pData)
453 guint log_level = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
454 gchar *log_domain =
"gnc.engine";
455 gchar *msg =
"gnc_account_list_name_violations: assertion `separator != NULL' failed";
457 GList *results, *res_iter;
459 QofBook *book = gnc_account_get_book (fixture->acct);
463 GLogFunc oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
464 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
466 g_assert_cmpint (check.hits, ==, 1);
468 g_assert_cmpint (check.hits, ==, 2);
470 g_log_set_default_handler (oldlogger, NULL);
472 g_assert_cmpuint (g_list_length (results), == , 2);
473 g_assert_cmpint (check.hits, ==, 2);
474 for (res_iter = results; res_iter; res_iter = g_list_next (res_iter))
475 test_free (res_iter->data);
476 g_list_free (results);
527 test_gnc_account_create_and_destroy (
void)
529 Account *acc = g_object_new (GNC_TYPE_ACCOUNT, NULL);
530 gchar *name, *fname, *code, *desc, *color, *notes, *tax_code, *tax_src;
533 gint commo_scu, mark;
534 gboolean non_std_scu, sort_dirty, bal_dirty, tax_rel, hide, hold;
536 gnc_numeric *start_bal, *start_clr_bal, *start_rec_bal;
544 "description", &desc,
549 "commodity_scu", &commo_scu,
550 "non-std-scu", &non_std_scu,
551 "sort-dirty", &sort_dirty,
552 "balance-dirty", &bal_dirty,
553 "start-balance", &start_bal,
554 "start-cleared-balance", &start_clr_bal,
555 "start-reconciled-balance", &start_rec_bal,
556 "end-balance", &end_bal,
557 "end-cleared-balance", &end_clr_bal,
558 "end-reconciled-balance", &end_rec_bal,
561 "tax-related", &tax_rel,
562 "tax-code", &tax_code,
563 "tax-source", &tax_src,
564 "tax-copy-number", ©_num,
566 "placeholder", &hold,
569 g_assert_cmpstr (name, == ,
"");
570 g_assert_cmpstr (fname, == ,
"");
571 g_assert_cmpstr (code, == ,
"");
572 g_assert_cmpstr (desc, == ,
"");
577 g_assert (!commo_scu);
578 g_assert (!non_std_scu);
579 g_assert (!sort_dirty);
580 g_assert (!bal_dirty);
590 g_assert (!tax_code);
592 g_assert (copy_num == 1);
608 g_object_unref (acc);
641 test_gnc_book_set_get_root_account (
Fixture *fixture, gconstpointer pData)
643 guint log_level = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
644 gchar *log_domain =
"gnc.account";
645 gchar *msg =
"[gnc_book_set_root_account()] cannot mix and match books freely!";
650 QofBook *book2 = gnc_account_get_book (fixture->acct);
651 acc1 = gnc_book_get_root_account (NULL);
656 acc1 = gnc_book_get_root_account (book1);
658 g_assert (acc1 != fixture->acct);
662 oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
663 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler,
665 gnc_book_set_root_account (book1, fixture->acct);
666 g_assert (gnc_book_get_root_account (book1) == acc1);
667 g_assert_cmpint (check.hits, ==, 1);
668 g_log_set_default_handler (oldlogger, NULL);
670 gnc_book_set_root_account (book2, fixture->acct);
671 g_assert (gnc_book_get_root_account (book2) == fixture->acct);
674 gnc_book_set_root_account (book1, acc2);
675 g_assert (gnc_book_get_root_account (book1) != acc1);
676 g_assert (gnc_book_get_root_account (book1) == acc2);
681 g_object_unref (book1);
682 g_object_unref (acc2);
689 test_xaccMallocAccount (
void)
693 TestSignal signal = test_signal_new (NULL, QOF_EVENT_CREATE, NULL);
695 g_assert (acc != NULL);
696 test_signal_assert_hits (signal, 1);
697 test_signal_free (signal);
698 g_object_unref (book);
699 g_object_unref (acc);
706 test_gnc_account_create_root (
void)
715 g_assert (func->coll_get_root_account (coll) == NULL);
718 g_object_get (acc,
"name", &name, NULL);
719 g_assert_cmpstr (name, == ,
"Root Account");
720 g_assert (gnc_book_get_root_account (book) == acc);
721 g_object_unref (book);
722 g_object_unref (acc);
731 test_xaccCloneAccount (
Fixture *fixture, gconstpointer pData)
734 QofBook *book = gnc_account_get_book (fixture->acct);
735 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
736 gchar *msg1 =
"xaccCloneAccount: assertion `GNC_IS_ACCOUNT(from)' failed";
737 gchar *msg2 =
"xaccCloneAccount: assertion `QOF_IS_BOOK(book)' failed";
741 oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
742 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
744 g_assert (clone == NULL);
745 g_assert_cmpint (check.hits, ==, 1);
748 g_assert (clone == NULL);
749 g_assert_cmpint (check.hits, ==, 2);
750 g_log_set_default_handler (oldlogger, NULL);
754 acct_p = fixture->func->get_private (fixture->acct);
755 clone_p = fixture->func->get_private (clone);
756 g_assert (clone_p->type == acct_p->type);
757 g_assert (clone_p->accountName == acct_p->accountName);
758 g_assert (clone_p->accountCode == acct_p->accountCode);
759 g_assert (clone_p->description == acct_p->description);
761 fixture->acct->inst.kvp_data) == 0);
763 g_assert (clone_p->commodity_scu == acct_p->commodity_scu);
764 g_assert (clone_p->non_standard_scu == acct_p->non_standard_scu);
766 g_object_unref (clone);
779 test_xaccFreeAccountChildren (
Fixture *fixture, gconstpointer pData)
783 g_assert_cmpuint (g_list_length (priv->children), > , 0);
784 fixture->func->xaccFreeAccountChildren (root);
787 g_assert_cmpuint (g_list_length (priv->children), == , 0);
790 g_free (fixture->func);
829 test_xaccFreeAccount (
Fixture *fixture, gconstpointer pData)
831 gchar *msg1 =
"[xaccFreeAccount()] instead of calling xaccFreeAccount(), please call \n"
832 " xaccAccountBeginEdit(); xaccAccountDestroy(); \n";
833 gchar *msg2 =
"xaccTransGetSplitIndex: assertion `trans && split' failed";
834 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
837 QofBook *book = gnc_account_get_book (fixture->acct);
840 const guint numItems = 3;
844 test_add_error (&check1);
845 test_add_error (&check2);
846 hdlr1 = g_log_set_handler (
"gnc.account", loglevel,
847 (GLogFunc)test_checked_handler, &check1);
848 hdlr2 = g_log_set_handler (
"gnc.engine", loglevel,
849 (GLogFunc)test_checked_handler, &check2);
850 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
851 for (i = 0; i < numItems; i++)
854 xaccSplitSetAccount (split, parent);
860 g_assert (p_priv->children != NULL);
861 g_assert (p_priv->lots != NULL);
862 g_assert (p_priv->splits != NULL);
863 g_assert (p_priv->parent != NULL);
864 g_assert (p_priv->commodity != NULL);
865 g_assert_cmpint (check1.hits, ==, 0);
866 g_assert_cmpint (check2.hits, ==, 0);
868 p_priv->cleared_balance = gnc_numeric_create ( 5, 12);
869 p_priv->reconciled_balance = gnc_numeric_create ( 5, 12);
870 p_priv->balance = gnc_numeric_create ( 5, 12);
871 p_priv->balance_dirty = TRUE;
872 p_priv->sort_dirty = TRUE;
873 fixture->func->xaccFreeAccount (parent);
874 g_assert_cmpint (check1.hits, ==, 6);
875 g_assert_cmpint (check2.hits, ==, 6);
877 g_log_remove_handler (
"gnc.account", hdlr1);
878 g_log_remove_handler (
"gnc.engine", hdlr2);
879 test_clear_error_list ();
881 g_free (fixture->func);
937 test_xaccAccountCommitEdit (
Fixture *fixture, gconstpointer pData)
939 gchar *msg1 =
"[xaccFreeAccount()] instead of calling xaccFreeAccount(), please call \n"
940 " xaccAccountBeginEdit(); xaccAccountDestroy(); \n";
941 gchar *msg2 =
"xaccTransGetSplitIndex: assertion `trans && split' failed";
942 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
946 TestSignal sig1, sig2;
947 QofBook *book = gnc_account_get_book (fixture->acct);
950 const guint numItems = 3;
953 test_add_error (&check1);
954 test_add_error (&check2);
955 hdlr1 = g_log_set_handler (
"gnc.account", loglevel,
956 (GLogFunc)test_checked_handler, &check1);
957 hdlr2 = g_log_set_handler (
"gnc.engine", loglevel,
958 (GLogFunc)test_checked_handler, &check2);
959 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
960 for (i = 0; i < numItems; i++)
963 xaccSplitSetAccount (split, parent);
969 g_assert (p_priv->children != NULL);
970 g_assert (p_priv->lots != NULL);
971 g_assert (p_priv->splits != NULL);
972 g_assert (p_priv->parent != NULL);
973 g_assert (p_priv->commodity != NULL);
974 g_assert_cmpint (check1.hits, ==, 0);
975 g_assert_cmpint (check2.hits, ==, 0);
977 sig1 = test_signal_new (&parent->inst, QOF_EVENT_MODIFY, NULL);
978 sig2 = test_signal_new (&parent->inst, QOF_EVENT_DESTROY, NULL);
983 test_signal_assert_hits (sig1, 1);
984 test_signal_assert_hits (sig2, 0);
985 g_assert (p_priv->children != NULL);
986 g_assert (p_priv->lots != NULL);
987 g_assert (p_priv->splits != NULL);
988 g_assert (p_priv->parent != NULL);
989 g_assert (p_priv->commodity != NULL);
990 g_assert_cmpint (check1.hits, ==, 0);
991 g_assert_cmpint (check2.hits, ==, 0);
998 test_signal_assert_hits (sig1, 2);
999 test_signal_assert_hits (sig2, 1);
1000 g_assert_cmpint (check1.hits, ==, 2);
1001 g_assert_cmpint (check2.hits, ==, 12);
1003 test_signal_free (sig1);
1004 test_signal_free (sig2);
1005 g_log_remove_handler (
"gnc.account", hdlr1);
1006 g_log_remove_handler (
"gnc.engine", hdlr2);
1007 test_clear_error_list ();
1009 g_free (fixture->func);
1044 test_gnc_account_insert_remove_split (
Fixture *fixture, gconstpointer pData)
1046 QofBook *book = gnc_account_get_book (fixture->acct);
1050 TestSignal sig1, sig2, sig3;
1051 AccountPrivate *priv = fixture->func->get_private (fixture->acct);
1052 gchar *msg1 =
"gnc_account_insert_split: assertion `GNC_IS_ACCOUNT(acc)' failed";
1053 gchar *msg2 =
"gnc_account_insert_split: assertion `GNC_IS_SPLIT(s)' failed";
1054 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
1060 sig1 = test_signal_new (&fixture->acct->inst, QOF_EVENT_MODIFY, NULL);
1063 test_add_error (&check1);
1064 test_add_error (&check2);
1065 logger = g_log_set_handler (
"gnc.engine", loglevel,
1066 (GLogFunc)test_null_handler, &check3);
1067 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
1071 g_assert_cmpuint (g_list_length (priv->splits), == , 0);
1072 g_assert (!priv->sort_dirty);
1073 g_assert (!priv->balance_dirty);
1074 test_signal_assert_hits (sig1, 0);
1075 test_signal_assert_hits (sig2, 0);
1077 g_assert_cmpuint (g_list_length (priv->splits), == , 0);
1078 g_assert (!priv->sort_dirty);
1079 g_assert (!priv->balance_dirty);
1080 test_signal_assert_hits (sig1, 0);
1081 test_signal_assert_hits (sig2, 0);
1088 g_assert_cmpint (check1.hits, ==, 1);
1089 g_assert_cmpint (check2.hits, ==, 1);
1090 g_assert_cmpint (check3.hits, ==, 0);
1091 g_log_remove_handler (
"gnc.engine", logger);
1092 test_clear_error_list ();
1096 g_assert_cmpuint (g_list_length (priv->splits), == , 1);
1097 g_assert (!priv->sort_dirty);
1098 g_assert (priv->balance_dirty);
1099 test_signal_assert_hits (sig1, 1);
1100 test_signal_assert_hits (sig2, 1);
1104 test_signal_free (sig2);
1108 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1109 g_assert (!priv->sort_dirty);
1110 g_assert (priv->balance_dirty);
1111 test_signal_assert_hits (sig1, 2);
1112 test_signal_assert_hits (sig3, 1);
1114 test_signal_free (sig3);
1116 qof_instance_increase_editlevel (fixture->acct);
1118 qof_instance_decrease_editlevel (fixture->acct);
1119 g_assert_cmpuint (g_list_length (priv->splits), == , 3);
1120 g_assert (priv->sort_dirty);
1121 g_assert (priv->balance_dirty);
1122 test_signal_assert_hits (sig1, 3);
1123 test_signal_assert_hits (sig3, 1);
1126 test_signal_free (sig3);
1127 sig3 = test_signal_new (&fixture->acct->inst, GNC_EVENT_ITEM_REMOVED,
1130 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1131 g_assert (priv->sort_dirty);
1132 g_assert (!priv->balance_dirty);
1133 test_signal_assert_hits (sig1, 4);
1134 test_signal_assert_hits (sig3, 1);
1138 g_assert_cmpuint (g_list_length (priv->splits), == , 2);
1139 g_assert (priv->sort_dirty);
1140 g_assert (!priv->balance_dirty);
1141 test_signal_assert_hits (sig1, 4);
1142 test_signal_assert_hits (sig3, 1);
1145 test_signal_free (sig3);
1146 test_signal_free (sig1);
1182 test_xaccAccountInsertRemoveLot (
Fixture *fixture, gconstpointer pData)
1184 QofBook *book = gnc_account_get_book (fixture->acct);
1185 GNCLot *lot = gnc_lot_new (book);
1187 TestSignal sig1 = test_signal_new (QOF_INSTANCE (lot),
1188 QOF_EVENT_ADD, NULL);
1189 TestSignal sig2 = test_signal_new (&fixture->acct->inst,
1190 QOF_EVENT_MODIFY, NULL);
1191 TestSignal sig3 = test_signal_new (QOF_INSTANCE (lot),
1192 QOF_EVENT_REMOVE, NULL);
1193 TestSignal sig4 = test_signal_new (&parent->inst, QOF_EVENT_MODIFY, NULL);
1195 AccountPrivate *a_priv = fixture->func->get_private (fixture->acct);
1198 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1199 g_assert_cmpuint (g_list_length (p_priv->lots), == , 0);
1202 g_assert_cmpuint (g_list_length (a_priv->lots), == , 1);
1203 test_signal_assert_hits (sig1, 1);
1204 test_signal_assert_hits (sig2, 1);
1208 g_assert_cmpuint (g_list_length (a_priv->lots), == , 1);
1209 test_signal_assert_hits (sig1, 1);
1210 test_signal_assert_hits (sig2, 1);
1214 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1215 g_assert_cmpuint (g_list_length (p_priv->lots), == , 1);
1216 test_signal_assert_hits (sig1, 2);
1217 test_signal_assert_hits (sig4, 1);
1218 test_signal_assert_hits (sig2, 1);
1220 xaccAccountRemoveLot (parent, lot);
1225 g_assert_cmpuint (g_list_length (a_priv->lots), == , 0);
1226 g_assert_cmpuint (g_list_length (p_priv->lots), == , 0);
1227 test_signal_assert_hits (sig3, 1);
1228 test_signal_assert_hits (sig4, 2);
1229 test_signal_assert_hits (sig2, 1);
1233 gnc_lot_set_account (lot, NULL);
1235 g_assert_cmpuint (g_list_length (p_priv->lots), == , 1);
1237 gnc_lot_destroy (lot);
1239 g_assert_cmpuint (g_list_length (p_priv->lots), != , 0);
1240 test_signal_assert_hits (sig1, 3);
1243 test_signal_assert_hits (sig4, 3);
1246 test_signal_assert_hits (sig3, 1);
1247 test_signal_free (sig1);
1248 test_signal_free (sig2);
1249 test_signal_free (sig3);
1250 test_signal_free (sig4);
1273 test_xaccAccountRecomputeBalance (
Fixture *fixture, gconstpointer pData)
1275 AccountPrivate *priv = fixture->func->get_private (fixture->acct);
1276 gnc_numeric bal = gnc_numeric_zero (), rec_bal = gnc_numeric_zero (),
1277 clr_bal = gnc_numeric_zero ();
1281 g_assert (sdata != NULL);
1283 for (ind = 0; ind < sdata->num_txns; ind++)
1286 bal = gnc_numeric_add_fixed (bal, p.amount);
1287 if (p.reconciled !=
NREC)
1288 clr_bal = gnc_numeric_add_fixed (clr_bal, p.amount);
1289 if (p.reconciled ==
YREC || p.reconciled ==
FREC)
1290 rec_bal = gnc_numeric_add_fixed (rec_bal, p.amount);
1294 priv->balance_dirty = TRUE;
1300 g_assert (!priv->balance_dirty);
1307 test_xaccAccountOrder ( )
1309 Account *aa = NULL, *ab = NULL;
1319 g_object_set (G_OBJECT (aa),
1324 g_object_set (G_OBJECT (ab),
1333 g_object_set (G_OBJECT (ab),
"name",
"bar", NULL);
1335 g_object_set (G_OBJECT (ab),
"name",
"waldo", NULL);
1339 g_test_message (
"The next test should fail: There's an error in the sort"
1340 " sequence that causes ACCT_TYPE_BANK to sort last"
1341 " instead of first\n");
1345 g_object_set (G_OBJECT (ab),
1351 g_object_set (G_OBJECT (ab),
"code",
"2222",
1355 g_object_set (G_OBJECT (ab),
1366 g_object_unref (book);
1400 test_qofAccountSetParent (
Fixture *fixture, gconstpointer pData)
1405 g_assert (root != old_parent);
1410 func->qofAccountSetParent (fixture->acct, QOF_INSTANCE (root));
1412 g_assert (qof_instance_get_dirty (QOF_INSTANCE (fixture->acct)));
1413 g_assert (qof_instance_get_dirty (QOF_INSTANCE (root)));
1414 g_assert (qof_instance_get_dirty (QOF_INSTANCE (old_parent)));
1423 test_gnc_account_append_remove_child (
Fixture *fixture, gconstpointer pData)
1425 QofBook *book = gnc_account_get_book (fixture->acct);
1429 gchar *logdomain =
"gnc.account";
1430 gchar *msg1 =
"[gnc_account_append_child()] reparenting accounts across books is not correctly supported\n";
1431 gchar *msg2 =
"[gnc_account_remove_child()] account not a child of parent";
1432 guint log_handler = 0;
1433 TestErrorStruct check_warn = {G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL,
"gnc.account", msg1, 0 };
1434 TestErrorStruct check_err = {G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL,
"gnc.account", msg2, 0 };
1435 TestSignal sig1, sig2, sig3;
1438 *apriv = func->get_private (fixture->acct);
1440 sig1 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_ADD, NULL);
1441 sig2 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_DESTROY, NULL);
1442 sig3 = test_signal_new (QOF_INSTANCE (account), QOF_EVENT_CREATE, NULL);
1446 test_signal_assert_hits (sig1, 1);
1447 test_signal_assert_hits (sig2, 0);
1448 test_signal_assert_hits (sig3, 0);
1449 g_assert_cmpint (check_warn.hits, ==, 0);
1450 g_assert_cmpint (check_err.hits, ==, 0);
1451 g_assert (qof_instance_get_dirty (QOF_INSTANCE (froot)));
1452 g_assert (qof_instance_get_dirty (QOF_INSTANCE (account)));
1453 g_assert (g_list_find (frpriv->children, account));
1457 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);
1458 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check_warn);
1460 g_log_remove_handler (logdomain, log_handler);
1461 g_assert_cmpstr (msg1, == , check_warn.msg);
1463 test_signal_assert_hits (sig1, 2);
1464 test_signal_assert_hits (sig2, 1);
1465 test_signal_assert_hits (sig3, 1);
1466 g_assert_cmpint (check_warn.hits, ==, 1);
1467 g_assert_cmpint (check_err.hits, ==, 0);
1474 g_assert (qof_instance_get_dirty (QOF_INSTANCE (fixture->acct)));
1475 g_assert (g_list_find (frpriv->children, account) == NULL);
1476 g_assert (g_list_find (apriv->children, account));
1478 test_signal_free (sig1);
1479 test_signal_free (sig2);
1480 test_signal_free (sig3);
1481 sig1 = test_signal_new (&account->inst, QOF_EVENT_REMOVE, NULL);
1482 sig2 = test_signal_new (&(fixture->acct)->inst, QOF_EVENT_MODIFY, NULL);
1483 log_handler = g_log_set_handler (logdomain, G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL,
1484 (GLogFunc)test_null_handler, &check_err);
1485 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check_err);
1487 g_log_remove_handler (logdomain, log_handler);
1489 test_signal_assert_hits (sig1, 0);
1490 test_signal_assert_hits (sig2, 0);
1491 g_assert_cmpint (check_err.hits, ==, 1);
1492 g_assert_cmpint (check_warn.hits, ==, 1);
1496 g_assert (g_list_find (apriv->children, account) == NULL);
1497 test_signal_assert_hits (sig1, 1);
1498 test_signal_assert_hits (sig2, 1);
1499 g_assert_cmpint (check_warn.hits, ==, 1);
1500 g_assert_cmpint (check_err.hits, ==, 1);
1501 test_signal_free (sig1);
1502 test_signal_free (sig2);
1507 g_object_unref (fbook);
1524 test_gnc_account_n_descendants (
Fixture *fixture, gconstpointer pData)
1534 test_gnc_account_get_current_depth (
Fixture *fixture, gconstpointer pData)
1543 test_gnc_account_get_tree_depth (
Fixture *fixture, gconstpointer pData)
1556 print_account (gpointer item, gpointer data)
1559 gchar *name, *code, *desc;
1561 const gchar *typestr;
1562 g_object_get (account,
1566 "description", &desc,
1569 g_test_message (
"%s: %s, %s %s", typestr, code, name, desc);
1576 test_gnc_account_get_descendants (
Fixture *fixture, gconstpointer pData)
1581 g_assert (list != NULL);
1582 g_assert_cmpuint (g_list_length (list), == , 34);
1583 g_assert_cmpint (g_list_index (list, fixture->acct), == , 33);
1586 g_assert (list == NULL);
1592 test_gnc_account_get_descendants_sorted (
Fixture *fixture, gconstpointer pData)
1596 g_assert (list != NULL);
1597 g_list_foreach (list, print_account, NULL);
1598 g_assert_cmpuint (g_list_length (list), == , 34);
1599 g_assert_cmpint (g_list_index (list, fixture->acct), == , 10);
1606 test_gnc_account_lookup_by_name (
Fixture *fixture, gconstpointer pData)
1612 g_assert (target != NULL);
1613 g_object_get (target,
"code", &code, NULL);
1614 g_assert_cmpstr (code, == ,
"4000");
1616 g_assert (target != NULL);
1618 g_object_get (target,
"code", &code, NULL);
1619 g_assert_cmpstr (code, == ,
"4160");
1621 g_assert (target != NULL);
1623 g_object_get (target,
"code", &code, NULL);
1624 g_assert_cmpstr (code, == ,
"2300");
1626 g_assert (target == NULL);
1634 test_gnc_account_lookup_by_code (
Fixture *fixture, gconstpointer pData)
1640 g_assert (target != NULL);
1641 g_object_get (target,
"name", &name, NULL);
1642 g_assert_cmpstr (name, == ,
"ordinary");
1645 g_assert (target != NULL);
1646 g_object_get (target,
"name", &name, NULL);
1647 g_assert_cmpstr (name, == ,
"utilities");
1649 g_assert (target == NULL);
1657 test_gnc_account_lookup_by_full_name_helper (
Fixture *fixture,
1658 gconstpointer pData )
1661 gchar *names1[] = {
"income",
"taxable",
"int", NULL};
1662 gchar *names2[] = {
"income",
"exempt",
"int", NULL};
1663 gchar *names3[] = {
"expense",
"taxable",
"int", NULL};
1668 target = func->gnc_account_lookup_by_full_name_helper (root, names1);
1669 g_assert (target != NULL);
1670 g_object_get (target,
"code", &code, NULL);
1671 g_assert_cmpstr (code, == ,
"4160");
1673 target = func->gnc_account_lookup_by_full_name_helper (root, names2);
1674 g_assert (target != NULL);
1675 g_object_get (target,
"code", &code, NULL);
1676 g_assert_cmpstr (code, == ,
"4210");
1677 target = func->gnc_account_lookup_by_full_name_helper (root, names3);
1678 g_assert (target == NULL);
1685 test_gnc_account_lookup_by_full_name (
Fixture *fixture, gconstpointer pData)
1688 gchar *names1 =
"income:taxable:int";
1689 gchar *names2 =
"income:exempt:int";
1690 gchar *names3 =
"expense:taxable:int";
1695 g_assert (target != NULL);
1696 g_object_get (target,
"code", &code, NULL);
1697 g_assert_cmpstr (code, == ,
"4160");
1700 g_assert (target != NULL);
1701 g_object_get (target,
"code", &code, NULL);
1702 g_assert_cmpstr (code, == ,
"4210");
1704 g_assert (target == NULL);
1709 thunk (
Account *s, gpointer data)
1711 guint *counter = (guint*)data;
1712 g_assert (GNC_IS_ACCOUNT (s));
1717 thunk2 (
Account *s, gpointer data)
1719 guint *counter = (guint*)data;
1721 g_assert (GNC_IS_ACCOUNT (s));
1722 g_object_get (G_OBJECT (s),
"name", &name, NULL);
1723 if (!g_strcmp0 (name,
"int"))
1736 test_gnc_account_foreach_child (
Fixture *fixture, gconstpointer pData)
1742 g_assert_cmpint (counter, == , 2);
1768 test_gnc_account_foreach_descendant (
Fixture *fixture, gconstpointer pData)
1774 g_assert_cmpint (counter, == , 13);
1780 test_gnc_account_foreach_descendant_until (
Fixture *fixture, gconstpointer pData)
1789 g_assert_cmpint (counter, == , 11);
1790 g_assert (result == NULL);
1793 g_assert (result == expected);
1794 g_assert_cmpint (counter, == , 6);
1817 test_gnc_account_get_full_name (
Fixture *fixture, gconstpointer pData)
1821 g_assert (result != NULL);
1822 g_assert_cmpstr (result, == ,
"");
1825 g_assert (result != NULL);
1826 g_assert_cmpstr (result, == ,
"");
1829 g_assert (result != NULL);
1830 g_assert_cmpstr (result, == ,
"foo:baz:waldo");
1844 test_xaccAccountGetProjectedMinimumBalance (
Fixture *fixture, gconstpointer pData)
1853 g_assert (sdata != NULL);
1855 for (ind = 0; ind < min_ind; ind++)
1858 bal = gnc_numeric_add_fixed (bal, p.amount);
1861 val = xaccAccountGetProjectedMinimumBalance (fixture->acct);
1863 g_assert_cmpfloat (dval, == , 0.0);
1865 val = xaccAccountGetProjectedMinimumBalance (fixture->acct);
1867 g_assert_cmpfloat (dval, == , dbal);
1873 test_xaccAccountGetBalanceAsOfDate (
Fixture *fixture, gconstpointer pData)
1882 gint offset = 24 * 3600 * 3;
1883 g_assert (sdata != NULL);
1885 for (ind = 0; ind < min_ind; ind++)
1888 bal = gnc_numeric_add_fixed (bal, p.amount);
1895 g_assert_cmpfloat (dval, == , dbal);
1901 test_xaccAccountGetPresentBalance (
Fixture *fixture, gconstpointer pData)
1910 g_assert (sdata != NULL);
1912 for (ind = 0; ind < min_ind; ind++)
1915 bal = gnc_numeric_add_fixed (bal, p.amount);
1919 val = xaccAccountGetPresentBalance (fixture->acct);
1921 g_assert_cmpfloat (dval, == , dbal);
1958 bogus_lot_match_func_true (
GNCLot *lot, gpointer p_data)
1964 bogus_lot_match_func_false (
GNCLot *lot, gpointer p_data)
1969 static guint count_sorts = 0;
1971 bogus_lot_sort_func (gconstpointer a, gconstpointer b)
1978 test_xaccAccountFindOpenLots (
Fixture *fixture, gconstpointer pData)
1986 g_assert (g_list_length (lots) == 2);
1987 if (lots) g_list_free (lots);
1990 g_assert (g_list_length (lots) == 2);
1991 if (lots) g_list_free (lots);
1994 g_assert (g_list_length (lots) == 0);
1995 if (lots) g_list_free (lots);
1997 g_assert_cmpint (count_sorts, == , 1);
1998 g_assert (g_list_length (lots) == 2);
1999 if (lots) g_list_free (lots);
2004 bogus_for_each_lot_func (
GNCLot *lot, gpointer data)
2006 guint *count = data;
2008 return (*count > 4 ? lot : NULL);
2015 test_xaccAccountForEachLot (
Fixture *fixture, gconstpointer pData)
2019 guint count_calls = 0;
2023 g_assert_cmpint (count_calls, == , 3);
2025 g_assert_cmpint (count_calls, == , 5);
2047 test_xaccAccountHasAncestor (
Fixture *fixture, gconstpointer pData)
2071 test_xaccAccountType_Stuff (
void)
2074 gint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
2075 gchar *logdomain =
"gnc.account";
2076 gchar *msg1 = g_strdup_printf (
"[xaccAccountTypeEnumAsString()] asked to translate unknown account type %d.\n", ACCT_TYPE_LAST);
2077 gchar *msg2 =
"[xaccAccountStringToType()] asked to translate unknown account type string (null).\n";
2078 gchar *msg3 =
"[xaccAccountStringToType()] asked to translate unknown account type string LAST.\n";
2079 guint loghandler = 0;
2083 Account *acc = g_object_new (GNC_TYPE_ACCOUNT, NULL);
2088 const gchar *typestr;
2091 g_assert (
typename);
2097 typestr_uc = g_ascii_strup (typestr, strlen (typestr));
2100 gchar *cmpstr = g_strconcat (
"A/",
typename, NULL);
2101 g_assert_cmpstr (typestr_uc, == , cmpstr);
2106 gchar *cmpstr = g_strconcat (
typename,
" CARD", NULL);
2107 g_assert_cmpstr (typestr_uc, == , cmpstr);
2112 gchar *cmpstr = g_strconcat (
typename,
" FUND", NULL);
2113 g_assert_cmpstr (typestr_uc, == , cmpstr);
2117 g_assert_cmpstr (typestr_uc, == ,
typename);
2118 g_free (typestr_uc);
2120 g_object_set (acc,
"type", type, NULL);
2128 g_object_unref (acc);
2130 loghandler = g_log_set_handler (logdomain, loglevel,
2131 (GLogFunc)test_null_handler, &check1);
2132 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check1);
2134 g_assert_cmpint (check1.hits, ==, 1);
2136 g_log_remove_handler (logdomain, loghandler);
2138 loghandler = g_log_set_handler (logdomain, loglevel,
2139 (GLogFunc)test_null_handler, &check2);
2140 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check2);
2142 g_assert_cmpint (check2.hits, ==, 1);
2144 g_log_remove_handler (logdomain, loghandler);
2145 loghandler = g_log_set_handler (logdomain, loglevel,
2146 (GLogFunc)test_null_handler, &check3);
2147 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check3);
2149 g_assert_cmpint (check3.hits, ==, 1);
2151 g_log_remove_handler (logdomain, loghandler);
2160 test_xaccAccountType_Compatibility (
void)
2180 gchar *msg1 = g_strdup_printf (
"[xaccParentAccountTypesCompatibleWith()] bad account type: %d",
ACCT_TYPE_ROOT);
2181 gchar *msg2 = g_strdup_printf (
"[xaccParentAccountTypesCompatibleWith()] bad account type: %d",
ACCT_TYPE_SAVINGS);
2182 gchar *logdomain =
"gnc.account";
2183 guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
2193 loghandler = g_log_set_handler (logdomain, loglevel,
2194 (GLogFunc)test_null_handler, &check1);
2195 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler,
2198 g_log_remove_handler (logdomain, loghandler);
2199 g_assert_cmpint (compat, == , 0);
2200 g_assert_cmpint (check1.hits, ==, 1);
2208 g_assert_cmpint (compat, == , bank_compat);
2210 g_assert_cmpint (compat, == , expense_compat);
2212 g_assert_cmpint (compat, == , equity_compat);
2214 g_assert_cmpint (compat, == , trading_compat);
2216 if (1 << child & compat)
2222 loghandler = g_log_set_handler (logdomain, loglevel,
2223 (GLogFunc)test_null_handler, &check2);
2224 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check2);
2226 g_log_remove_handler (logdomain, loghandler);
2227 g_assert_cmpint (compat, == , 0);
2228 g_assert_cmpint (check2.hits, ==, 1);
2261 test_xaccAccountFindSplitByDesc (
Fixture *fixture, gconstpointer pData)
2268 g_object_get (split,
"memo", &memo, NULL);
2269 g_assert_cmpstr (memo, == ,
"pepper_baz");
2276 test_xaccAccountFindTransByDesc (
Fixture *fixture, gconstpointer pData)
2283 g_object_get (txn,
"description", &desc, NULL);
2284 g_assert_cmpstr (desc, == ,
"pepper");
2291 test_gnc_account_join_children (
Fixture *fixture, gconstpointer pData)
2299 g_test_message (
"The following should fail because of account type incompatibility. It doesn't, which is a bug.");
2302 broker_desc + income_desc);
2310 test_gnc_account_merge_children (
Fixture *fixture, gconstpointer pData)
2319 TestSignal sig4, sig5;
2362 sig4 = test_signal_new (QOF_INSTANCE (div), QOF_EVENT_MODIFY, NULL);
2363 sig5 = test_signal_new (QOF_INSTANCE (div1), QOF_EVENT_MODIFY, NULL);
2364 g_object_set (div1,
"name",
"div", NULL);
2367 test_signal_assert_hits (sig4, 1);
2368 test_signal_assert_hits (sig5, 4);
2369 test_signal_free (sig4);
2370 test_signal_free (sig5);
2408 g_object_get (txn,
"description", &txn_desc, NULL);
2409 result = g_strcmp0 (td->name, txn_desc) == 0;
2422 test_xaccAccountTreeForEachTransaction (
Fixture *fixture, gconstpointer pData )
2428 g_assert_cmpint (td.count, == , 9);
2429 g_assert_cmpint (result, == , 0);
2433 g_assert_cmpint (td.count, == , result);
2434 g_assert_cmpint (result, < , 9);
2440 test_xaccAccountForEachTransaction (
Fixture *fixture, gconstpointer pData )
2447 g_assert_cmpint (td.count, == , 0);
2450 g_assert_cmpint (td.count, == , 9);
2451 g_assert_cmpint (result, == , 0);
2455 g_assert_cmpint (td.count, == , result);
2456 g_assert_cmpint (result, < , 9);
2461 test_gnc_set_budget_name()
2466 g_assert(strcmp(gnc_budget_get_name(budget),
"Unnamed Budget") == 0);
2468 g_assert(strcmp(gnc_budget_get_name(budget),
"New Budget") == 0);
2474 test_gnc_set_budget_description()
2479 g_assert(strcmp(gnc_budget_get_description(budget),
"") == 0);
2481 g_assert(strcmp(gnc_budget_get_description(budget),
"New Budget") == 0);
2487 test_gnc_set_budget_num_periods()
2492 g_assert_cmpint(gnc_budget_get_num_periods(budget), ==, 12);
2494 g_assert_cmpint(gnc_budget_get_num_periods(budget), ==, 20);
2500 test_gnc_set_budget_recurrence()
2515 PeriodInfo period_info[] = { { G_DATE_JANUARY, 31 }, { G_DATE_FEBRUARY, 29 }, { G_DATE_MARCH, 31 }, { G_DATE_APRIL, 30 }, { G_DATE_MAY, 31 }, { G_DATE_JUNE, 30 },
2516 { G_DATE_JULY, 31 }, { G_DATE_AUGUST, 31 }, { G_DATE_SEPTEMBER, 30 }, { G_DATE_OCTOBER, 31 }, { G_DATE_NOVEMBER, 30 }, { G_DATE_DECEMBER, 31 }
2519 r = gnc_budget_get_recurrence(budget);
2520 g_assert_cmpint(r->ptype, ==, PERIOD_MONTH);
2521 g_assert_cmpint(r->mult, ==, 1);
2522 g_assert_cmpint(r->wadj, ==, WEEKEND_ADJ_NONE);
2524 g_date_set_dmy(&start_date, 1, G_DATE_JANUARY, 2012);
2525 recurrenceSet(&new_r, 1, PERIOD_MONTH, &start_date, WEEKEND_ADJ_NONE);
2526 gnc_budget_set_recurrence(budget, &new_r);
2528 r = gnc_budget_get_recurrence(budget);
2529 g_assert_cmpint(r->ptype, ==, PERIOD_MONTH);
2530 g_assert_cmpint(r->mult, ==, 1);
2531 g_assert_cmpint(r->wadj, ==, WEEKEND_ADJ_NONE);
2533 for (i = 0; i < 12; ++i)
2538 g_assert_cmpint(g_date_get_day(&period_start), ==, 1);
2539 g_assert_cmpint(g_date_get_day(&period_end), ==, period_info[i].end_day);
2540 g_assert_cmpint(g_date_get_month(&period_start), ==, period_info[i].month);
2541 g_assert_cmpint(g_date_get_month(&period_end), ==, period_info[i].month);
2542 g_assert_cmpint(g_date_get_year(&period_start), ==, 2012);
2543 g_assert_cmpint(g_date_get_year(&period_end), ==, 2012);
2550 test_gnc_set_budget_account_period_value()
2557 guint log_level = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL;
2558 gchar *log_domain =
"gnc.engine";
2559 gchar *msg =
"[gnc_budget_set_account_period_value()] Period 12 does not exist";
2566 g_assert(!gnc_budget_is_account_period_value_set(budget, acc, 0));
2567 gnc_budget_set_account_period_value(budget, acc, 0, gnc_numeric_create(100,1));
2568 g_assert(gnc_budget_is_account_period_value_set(budget, acc, 0));
2569 val = gnc_budget_get_account_period_value(budget, acc, 0);
2574 oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
2575 g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
2576 gnc_budget_set_account_period_value(budget, acc, 12, gnc_numeric_create(100,1));
2577 g_assert_cmpint (check.hits, ==, 1);
2578 g_log_set_default_handler (oldlogger, NULL);
2580 g_object_unref(book);
2581 g_object_unref(acc);
2586 test_suite_budget(
void)
2589 GNC_TEST_ADD_FUNC(suitename,
"gnc_budget_set_name()", test_gnc_set_budget_name);
2590 GNC_TEST_ADD_FUNC(suitename,
"gnc_budget_set_description()", test_gnc_set_budget_description);
2591 GNC_TEST_ADD_FUNC(suitename,
"gnc_budget_set_num_periods()", test_gnc_set_budget_num_periods);
2592 GNC_TEST_ADD_FUNC(suitename,
"gnc_budget_set_recurrence()", test_gnc_set_budget_recurrence);
2593 GNC_TEST_ADD_FUNC(suitename,
"gnc_budget_set_account_period_value()", test_gnc_set_budget_account_period_value);
2596 GNC_TEST_ADD_FUNC (suitename,
"gnc set account separator", test_gnc_set_account_separator);
2597 GNC_TEST_ADD_FUNC (suitename,
"gnc account name violations errmsg", test_gnc_account_name_violations_errmsg);
2598 GNC_TEST_ADD (suitename,
"gnc account list name violations",
Fixture, &bad_data, setup, test_gnc_account_list_name_violations, teardown);
2599 GNC_TEST_ADD_FUNC (suitename,
"account create and destroy", test_gnc_account_create_and_destroy);
2600 GNC_TEST_ADD (suitename,
"book set/get root account",
Fixture, NULL, setup, test_gnc_book_set_get_root_account, teardown);
2601 GNC_TEST_ADD_FUNC (suitename,
"xaccMallocAccount", test_xaccMallocAccount);
2603 GNC_TEST_ADD_FUNC (suitename,
"gnc account create root", test_gnc_account_create_root);
2604 GNC_TEST_ADD (suitename,
"xaccCloneAccount",
Fixture, NULL, setup, test_xaccCloneAccount, teardown );
2606 GNC_TEST_ADD (suitename,
"xaccFreeAccountChildren",
Fixture, &good_data, setup, test_xaccFreeAccountChildren, NULL);
2608 GNC_TEST_ADD (suitename,
"xaccFreeAccount",
Fixture, &good_data, setup, test_xaccFreeAccount, NULL );
2609 GNC_TEST_ADD (suitename,
"xaccAccountCommitEdit",
Fixture, &good_data, setup, test_xaccAccountCommitEdit, NULL );
2612 GNC_TEST_ADD (suitename,
"gnc account insert & remove split",
Fixture, NULL, setup, test_gnc_account_insert_remove_split, teardown );
2613 GNC_TEST_ADD (suitename,
"xaccAccount Insert and Remove Lot",
Fixture, &good_data, setup, test_xaccAccountInsertRemoveLot, teardown );
2614 GNC_TEST_ADD (suitename,
"xaccAccountRecomputeBalance",
Fixture, &some_data, setup, test_xaccAccountRecomputeBalance, teardown );
2615 GNC_TEST_ADD_FUNC (suitename,
"xaccAccountOrder", test_xaccAccountOrder );
2616 GNC_TEST_ADD (suitename,
"qofAccountSetParent",
Fixture, &some_data, setup, test_qofAccountSetParent, teardown );
2617 GNC_TEST_ADD (suitename,
"gnc account append/remove child",
Fixture, NULL, setup, test_gnc_account_append_remove_child, teardown );
2618 GNC_TEST_ADD (suitename,
"gnc account n descendants",
Fixture, &some_data, setup, test_gnc_account_n_descendants, teardown );
2619 GNC_TEST_ADD (suitename,
"gnc account get current depth",
Fixture, &some_data, setup, test_gnc_account_get_current_depth, teardown );
2620 GNC_TEST_ADD (suitename,
"gnc account get tree depth",
Fixture, &complex, setup, test_gnc_account_get_tree_depth, teardown );
2621 GNC_TEST_ADD (suitename,
"gnc account get descendants",
Fixture, &complex, setup, test_gnc_account_get_descendants, teardown );
2622 GNC_TEST_ADD (suitename,
"gnc account get descendants sorted",
Fixture, &complex, setup, test_gnc_account_get_descendants_sorted, teardown );
2623 GNC_TEST_ADD (suitename,
"gnc account lookup by name",
Fixture, &complex, setup, test_gnc_account_lookup_by_name, teardown );
2624 GNC_TEST_ADD (suitename,
"gnc account lookup by code",
Fixture, &complex, setup, test_gnc_account_lookup_by_code, teardown );
2625 GNC_TEST_ADD (suitename,
"gnc account lookup by full name helper",
Fixture, &complex, setup, test_gnc_account_lookup_by_full_name_helper, teardown );
2626 GNC_TEST_ADD (suitename,
"gnc account lookup by full name",
Fixture, &complex, setup, test_gnc_account_lookup_by_full_name, teardown );
2627 GNC_TEST_ADD (suitename,
"gnc account foreach child",
Fixture, &complex, setup, test_gnc_account_foreach_child, teardown );
2628 GNC_TEST_ADD (suitename,
"gnc account foreach descendant",
Fixture, &complex, setup, test_gnc_account_foreach_descendant, teardown );
2629 GNC_TEST_ADD (suitename,
"gnc account foreach descendant until",
Fixture, &complex, setup, test_gnc_account_foreach_descendant_until, teardown );
2630 GNC_TEST_ADD (suitename,
"gnc account get full name",
Fixture, &good_data, setup, test_gnc_account_get_full_name, teardown );
2631 GNC_TEST_ADD (suitename,
"xaccAccountGetProjectedMinimumBalance",
Fixture, &some_data, setup, test_xaccAccountGetProjectedMinimumBalance, teardown );
2632 GNC_TEST_ADD (suitename,
"xaccAccountGetBalanceAsOfDate",
Fixture, &some_data, setup, test_xaccAccountGetBalanceAsOfDate, teardown );
2633 GNC_TEST_ADD (suitename,
"xaccAccountGetPresentBalance",
Fixture, &some_data, setup, test_xaccAccountGetPresentBalance, teardown );
2634 GNC_TEST_ADD (suitename,
"xaccAccountFindOpenLots",
Fixture, &complex_data, setup, test_xaccAccountFindOpenLots, teardown );
2635 GNC_TEST_ADD (suitename,
"xaccAccountForEachLot",
Fixture, &complex_data, setup, test_xaccAccountForEachLot, teardown );
2637 GNC_TEST_ADD (suitename,
"xaccAccountHasAncestor",
Fixture, &complex, setup, test_xaccAccountHasAncestor, teardown );
2638 GNC_TEST_ADD_FUNC (suitename,
"AccountType Stuff", test_xaccAccountType_Stuff );
2639 GNC_TEST_ADD_FUNC (suitename,
"AccountType Compatibility", test_xaccAccountType_Compatibility);
2640 GNC_TEST_ADD (suitename,
"xaccAccountFindSplitByDesc",
Fixture, &complex_data, setup, test_xaccAccountFindSplitByDesc, teardown );
2641 GNC_TEST_ADD (suitename,
"xaccAccountFindTransByDesc",
Fixture, &complex_data, setup, test_xaccAccountFindTransByDesc, teardown );
2642 GNC_TEST_ADD (suitename,
"gnc account join children",
Fixture, &complex, setup, test_gnc_account_join_children, teardown );
2643 GNC_TEST_ADD (suitename,
"gnc account merge children",
Fixture, &complex_data, setup, test_gnc_account_merge_children, teardown );
2644 GNC_TEST_ADD (suitename,
"xaccAccountForEachTransaction",
Fixture, &complex_data, setup, test_xaccAccountForEachTransaction, teardown );
2645 GNC_TEST_ADD (suitename,
"xaccAccountTreeForEachTransaction",
Fixture, &complex_data, setup, test_xaccAccountTreeForEachTransaction, teardown );
void xaccAccountSetType(Account *acc, GNCAccountType tip)
void gnc_budget_set_num_periods(GncBudget *budget, guint num_periods)
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)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
void gnc_budget_destroy(GncBudget *budget)
Timespec gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
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)
GncBudget * gnc_budget_new(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)
Timespec gnc_budget_get_period_start_date(const GncBudget *budget, guint period_num)
Split * xaccAccountFindSplitByDesc(const Account *acc, const char *description)
GDate timespec_to_gdate(Timespec ts)
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)
void gnc_budget_set_name(GncBudget *budget, const gchar *name)
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)
void gnc_budget_set_description(GncBudget *budget, const gchar *description)
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)