2001-08-18 20:07:03 +00:00
|
|
|
|
2006-09-05 18:00:11 +00:00
|
|
|
#include "config.h"
|
2001-08-18 20:07:03 +00:00
|
|
|
#include <glib.h>
|
2003-02-22 08:15:53 +00:00
|
|
|
#include <libguile.h>
|
2001-08-18 20:07:03 +00:00
|
|
|
|
|
|
|
|
#include "engine-helpers.h"
|
|
|
|
|
#include "gnc-module.h"
|
|
|
|
|
#include "test-engine-stuff.h"
|
|
|
|
|
#include "test-stuff.h"
|
|
|
|
|
#include "Query.h"
|
2001-11-05 09:18:07 +00:00
|
|
|
#include "TransLog.h"
|
2001-08-18 20:07:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_query (Query *q)
|
|
|
|
|
{
|
2010-02-18 05:31:54 +00:00
|
|
|
SCM scm_q;
|
|
|
|
|
Query *q2;
|
|
|
|
|
|
|
|
|
|
scm_q = gnc_query2scm (q);
|
|
|
|
|
|
|
|
|
|
q2 = gnc_scm2query (scm_q);
|
|
|
|
|
|
2010-10-13 16:16:04 +00:00
|
|
|
if (!qof_query_equal (q, q2))
|
2010-02-18 05:31:54 +00:00
|
|
|
{
|
|
|
|
|
failure ("queries don't match");
|
|
|
|
|
scm_display (scm_q, SCM_UNDEFINED);
|
|
|
|
|
scm_newline (SCM_UNDEFINED);
|
|
|
|
|
scm_q = gnc_query2scm (q2);
|
|
|
|
|
scm_display (scm_q, SCM_UNDEFINED);
|
|
|
|
|
scm_newline (SCM_UNDEFINED);
|
|
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
success ("queries match");
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-13 16:16:04 +00:00
|
|
|
qof_query_destroy (q2);
|
2001-08-18 20:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
run_tests (void)
|
|
|
|
|
{
|
2010-02-18 05:31:54 +00:00
|
|
|
Query *q;
|
|
|
|
|
int i;
|
2001-08-18 20:07:03 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
test_query (NULL);
|
2001-08-18 20:07:03 +00:00
|
|
|
|
2010-10-13 16:16:04 +00:00
|
|
|
q = qof_query_create_for(GNC_ID_SPLIT);
|
2001-08-18 20:07:03 +00:00
|
|
|
test_query (q);
|
2010-10-13 16:16:04 +00:00
|
|
|
qof_query_destroy (q);
|
2010-02-18 05:31:54 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < 50; i++)
|
|
|
|
|
{
|
|
|
|
|
q = get_random_query ();
|
|
|
|
|
test_query (q);
|
2010-10-13 16:16:04 +00:00
|
|
|
qof_query_destroy (q);
|
2010-02-18 05:31:54 +00:00
|
|
|
}
|
2001-08-18 20:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-02-22 08:15:53 +00:00
|
|
|
main_helper (void *closure, int argc, char **argv)
|
2001-08-18 20:07:03 +00:00
|
|
|
{
|
2010-02-18 05:31:54 +00:00
|
|
|
gnc_module_load("gnucash/engine", 0);
|
2001-11-05 09:18:07 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
xaccLogDisable ();
|
2001-11-05 09:18:07 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
/* scm conversion doesn't handle binary atm */
|
|
|
|
|
kvp_exclude_type (KVP_TYPE_BINARY);
|
2001-11-06 00:49:46 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
run_tests ();
|
2001-08-18 20:07:03 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
print_test_results ();
|
2001-08-18 20:07:03 +00:00
|
|
|
|
2010-02-18 05:31:54 +00:00
|
|
|
exit (get_rv ());
|
2001-08-18 20:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
2010-02-18 05:31:54 +00:00
|
|
|
scm_boot_guile (argc, argv, main_helper, NULL);
|
|
|
|
|
return 0;
|
2001-08-18 20:07:03 +00:00
|
|
|
}
|