mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
d1422bd6be
commit
58fd1ba067
@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
* src/backend/file/Makefile.am: link against libcore-utils.
|
* 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>
|
2006-02-05 Neil Williams <linux@codehelp.co.uk>
|
||||||
|
|
||||||
* lib/libqof/qof/qoflog.c :
|
* lib/libqof/qof/qoflog.c :
|
||||||
|
@ -872,6 +872,7 @@ static void
|
|||||||
make_random_group (QofBook *book, AccountGroup *group)
|
make_random_group (QofBook *book, AccountGroup *group)
|
||||||
{
|
{
|
||||||
int depth;
|
int depth;
|
||||||
|
GList *account_list;
|
||||||
|
|
||||||
g_return_if_fail (book);
|
g_return_if_fail (book);
|
||||||
g_return_if_fail (group);
|
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);
|
depth = get_random_int_in_range (1, max_group_depth);
|
||||||
|
|
||||||
make_random_group_depth (book, 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 *
|
AccountGroup *
|
||||||
@ -1398,7 +1405,12 @@ get_random_transaction_with_currency(QofBook *book,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Gotta have at least two different accounts */
|
/* 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);
|
trans = xaccMallocTransaction(book);
|
||||||
|
|
||||||
@ -1420,6 +1432,7 @@ get_random_transaction_with_currency(QofBook *book,
|
|||||||
xaccTransSetSlots_nc(trans, f);
|
xaccTransSetSlots_nc(trans, f);
|
||||||
|
|
||||||
add_random_splits(book, trans, account_list);
|
add_random_splits(book, trans, account_list);
|
||||||
|
g_list_free(account_list);
|
||||||
|
|
||||||
if (get_random_int_in_range (1, 10) == 1)
|
if (get_random_int_in_range (1, 10) == 1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user