A few test changes to make sure we don't fail when we're very unlucky.

- make sure a random group always has at least two accounts
	  - fix "make random transaction" to tell us when we don't
	    have at least two accounts.
	  - free the results of xaccGroupGetSubAccounts().



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13124 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2006-02-05 20:38:46 +00:00
parent d1422bd6be
commit 58fd1ba067
2 changed files with 20 additions and 1 deletions

View File

@ -8,6 +8,12 @@
* src/backend/file/Makefile.am: link against libcore-utils.
* src/engine/test/test-engine-stuff.c:
- make sure a random group always has at least two accounts
- fix "make random transaction" to tell us when we don't
have at least two accounts.
- free the results of xaccGroupGetSubAccounts().
2006-02-05 Neil Williams <linux@codehelp.co.uk>
* lib/libqof/qof/qoflog.c :

View File

@ -872,6 +872,7 @@ static void
make_random_group (QofBook *book, AccountGroup *group)
{
int depth;
GList *account_list;
g_return_if_fail (book);
g_return_if_fail (group);
@ -880,6 +881,12 @@ make_random_group (QofBook *book, AccountGroup *group)
depth = get_random_int_in_range (1, max_group_depth);
make_random_group_depth (book, group, depth);
/* Make sure we have at least two accounts! */
account_list = xaccGroupGetSubAccounts (xaccGetAccountGroup (book));
if (1 >= g_list_length (account_list))
make_random_group_depth (book, group, 1);
g_list_free(account_list);
}
AccountGroup *
@ -1398,7 +1405,12 @@ get_random_transaction_with_currency(QofBook *book,
}
/* Gotta have at least two different accounts */
if (1 >= g_list_length (account_list)) return NULL;
if (1 >= g_list_length (account_list)) {
failure_args("engine-stuff", __FILE__, __LINE__,
"get_random_transaction_with_currency: account_list too short");
g_list_free(account_list);
return NULL;
}
trans = xaccMallocTransaction(book);
@ -1420,6 +1432,7 @@ get_random_transaction_with_currency(QofBook *book,
xaccTransSetSlots_nc(trans, f);
add_random_splits(book, trans, account_list);
g_list_free(account_list);
if (get_random_int_in_range (1, 10) == 1)
{