mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Work on test infrastructure.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5658 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
995e7d7d27
commit
bcae323c49
@ -19,7 +19,7 @@
|
|||||||
static gboolean glist_strings_only = FALSE;
|
static gboolean glist_strings_only = FALSE;
|
||||||
|
|
||||||
static GHashTable *exclude_kvp_types = NULL;
|
static GHashTable *exclude_kvp_types = NULL;
|
||||||
static gint kvp_max_depth = G_MAXINT;
|
static gint kvp_max_depth = 5;
|
||||||
static gint kvp_frame_max_elements = 10;
|
static gint kvp_frame_max_elements = 10;
|
||||||
|
|
||||||
static gint max_group_depth = 4;
|
static gint max_group_depth = 4;
|
||||||
@ -218,11 +218,17 @@ get_random_glist_depth (gint depth)
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
kvp_value_t kvpt;
|
kvp_value_t kvpt;
|
||||||
|
kvp_value *value;
|
||||||
|
|
||||||
kvpt = glist_strings_only ? KVP_TYPE_STRING : -2;
|
kvpt = glist_strings_only ? KVP_TYPE_STRING : -2;
|
||||||
|
|
||||||
ret = g_list_prepend(ret,
|
do
|
||||||
get_random_kvp_value_depth (kvpt, depth + 1));
|
{
|
||||||
|
value = get_random_kvp_value_depth (kvpt, depth + 1);
|
||||||
|
}
|
||||||
|
while (!value);
|
||||||
|
|
||||||
|
ret = g_list_prepend(ret, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -258,6 +264,7 @@ get_random_kvp_frame_depth (gint depth)
|
|||||||
{
|
{
|
||||||
kvp_frame *ret;
|
kvp_frame *ret;
|
||||||
int vals_to_add;
|
int vals_to_add;
|
||||||
|
gboolean val_added;
|
||||||
|
|
||||||
if (depth >= kvp_max_depth)
|
if (depth >= kvp_max_depth)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -265,6 +272,7 @@ get_random_kvp_frame_depth (gint depth)
|
|||||||
ret = kvp_frame_new();
|
ret = kvp_frame_new();
|
||||||
|
|
||||||
vals_to_add = get_random_int_in_range(1,kvp_frame_max_elements);
|
vals_to_add = get_random_int_in_range(1,kvp_frame_max_elements);
|
||||||
|
val_added = FALSE;
|
||||||
|
|
||||||
for(;vals_to_add > 0; vals_to_add--)
|
for(;vals_to_add > 0; vals_to_add--)
|
||||||
{
|
{
|
||||||
@ -278,12 +286,16 @@ get_random_kvp_frame_depth (gint depth)
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!val)
|
if (!val)
|
||||||
{
|
{
|
||||||
|
if (!val_added)
|
||||||
vals_to_add++;
|
vals_to_add++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val_added = TRUE;
|
||||||
|
|
||||||
kvp_frame_set_slot_nc(ret, key, val);
|
kvp_frame_set_slot_nc(ret, key, val);
|
||||||
|
|
||||||
g_free(key);
|
g_free(key);
|
||||||
@ -305,12 +317,12 @@ get_random_kvp_value_depth (int type, gint depth)
|
|||||||
|
|
||||||
if (datype == -1)
|
if (datype == -1)
|
||||||
{
|
{
|
||||||
datype = get_random_int_in_range(KVP_TYPE_GINT64, KVP_TYPE_FRAME + 1);
|
datype = get_random_int_in_range(KVP_TYPE_GINT64, KVP_TYPE_FRAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datype == -2)
|
if (datype == -2)
|
||||||
{
|
{
|
||||||
datype = get_random_int_in_range(KVP_TYPE_GINT64, KVP_TYPE_FRAME);
|
datype = get_random_int_in_range(KVP_TYPE_GINT64, KVP_TYPE_FRAME - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datype == KVP_TYPE_FRAME && depth >= kvp_max_depth)
|
if (datype == KVP_TYPE_FRAME && depth >= kvp_max_depth)
|
||||||
@ -440,7 +452,7 @@ get_random_group_depth(GNCSession *session, int depth)
|
|||||||
AccountGroup *group;
|
AccountGroup *group;
|
||||||
int num_accounts;
|
int num_accounts;
|
||||||
|
|
||||||
if (depth == 0)
|
if (depth <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
group = xaccMallocAccountGroup (session);
|
group = xaccMallocAccountGroup (session);
|
||||||
@ -508,7 +520,7 @@ set_split_random_string(Split *spl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char possible_chars[] = { 'c', 'y', 'f', 'n' };
|
static char possible_chars[] = { 'c', 'y', 'f', 'n', 'v' };
|
||||||
|
|
||||||
Split*
|
Split*
|
||||||
get_random_split(GNCSession *session, gnc_numeric num)
|
get_random_split(GNCSession *session, gnc_numeric num)
|
||||||
@ -542,6 +554,12 @@ get_random_split(GNCSession *session, gnc_numeric num)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
make_random_changes_to_split (Split *split)
|
||||||
|
{
|
||||||
|
g_return_if_fail (split);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_tran_random_string(Transaction* trn,
|
set_tran_random_string(Transaction* trn,
|
||||||
void(*func)(Transaction *act, const gchar*str))
|
void(*func)(Transaction *act, const gchar*str))
|
||||||
|
@ -59,4 +59,6 @@ GNCSession * get_random_session (void);
|
|||||||
void add_random_transactions_to_session (GNCSession *session,
|
void add_random_transactions_to_session (GNCSession *session,
|
||||||
gint num_transactions);
|
gint num_transactions);
|
||||||
|
|
||||||
|
void make_random_changes_to_split (Split *split);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -142,7 +142,7 @@ do_test_call(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
do_test_args(
|
do_test_args(
|
||||||
gboolean result,
|
gboolean result,
|
||||||
const char* test_title,
|
const char* test_title,
|
||||||
@ -160,6 +160,8 @@ do_test_args(
|
|||||||
vfailure_args( test_title, filename, line, format, ap );
|
vfailure_args( test_title, filename, line, format, ap );
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -199,7 +201,10 @@ get_random_boolean(void)
|
|||||||
gint
|
gint
|
||||||
get_random_int_in_range(int start, int end)
|
get_random_int_in_range(int start, int end)
|
||||||
{
|
{
|
||||||
return start + (int)((double)end * rand() / (RAND_MAX + 1.0));
|
return CLAMP (start + (int)((double)(end - start + 1) * rand() /
|
||||||
|
(RAND_MAX + 1.0)),
|
||||||
|
start,
|
||||||
|
end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *random_chars = NULL;
|
static char *random_chars = NULL;
|
||||||
|
@ -63,7 +63,7 @@ gboolean do_test_call(
|
|||||||
const char* test_title,
|
const char* test_title,
|
||||||
const char* filename,
|
const char* filename,
|
||||||
int line );
|
int line );
|
||||||
void do_test_args(
|
gboolean do_test_args(
|
||||||
gboolean result,
|
gboolean result,
|
||||||
const char* test_title,
|
const char* test_title,
|
||||||
const char* filename,
|
const char* filename,
|
||||||
|
Loading…
Reference in New Issue
Block a user