2015-09-29 14:08:48 -05:00
|
|
|
/********************************************************************\
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
|
2021-03-22 15:30:41 -05:00
|
|
|
#include <config.h>
|
|
|
|
#include <glib.h>
|
2015-09-24 13:28:07 -05:00
|
|
|
#include <libguile.h>
|
2021-03-22 15:30:41 -05:00
|
|
|
#include "guile-mappings.h"
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2015-09-24 13:28:07 -05:00
|
|
|
extern "C"
|
|
|
|
{
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2019-10-05 09:48:37 -05:00
|
|
|
#include "gnc-engine-guile.h"
|
2002-06-04 21:56:15 -05:00
|
|
|
#include "test-engine-stuff.h"
|
|
|
|
#include "test-stuff.h"
|
|
|
|
#include "Query.h"
|
|
|
|
#include "TransLog.h"
|
2015-09-24 13:28:07 -05:00
|
|
|
}
|
2002-06-04 21:56:15 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
test_query (Query *q, SCM val2str)
|
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
SCM scm_q;
|
|
|
|
SCM str_q;
|
|
|
|
SCM args = SCM_EOL;
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
scm_q = gnc_query2scm (q);
|
|
|
|
args = scm_cons (scm_q, SCM_EOL);
|
|
|
|
str_q = scm_apply (val2str, args, SCM_EOL);
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2013-12-13 14:21:41 -06:00
|
|
|
args = scm_cons (scm_from_utf8_string ("'"), scm_cons (str_q, SCM_EOL));
|
2009-12-29 14:12:48 -06:00
|
|
|
str_q = scm_string_append (args);
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
scm_display (str_q, SCM_UNDEFINED);
|
|
|
|
scm_newline (SCM_UNDEFINED);
|
|
|
|
scm_newline (SCM_UNDEFINED);
|
2002-06-04 21:56:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_tests (int count)
|
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
Query *q;
|
|
|
|
SCM val2str;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
val2str = scm_c_eval_string ("gnc:value->string");
|
2009-12-31 08:41:12 -06:00
|
|
|
g_return_if_fail (scm_is_procedure (val2str));
|
2009-12-29 14:12:48 -06:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
q = get_random_query ();
|
|
|
|
test_query (q, val2str);
|
2010-10-13 11:16:04 -05:00
|
|
|
qof_query_destroy (q);
|
2009-12-29 14:12:48 -06:00
|
|
|
}
|
|
|
|
success ("");
|
2002-06-04 21:56:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-22 02:15:53 -06:00
|
|
|
main_helper (void *closure, int argc, char **argv)
|
2002-06-04 21:56:15 -05:00
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
int count = 50;
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2019-11-26 11:27:13 -06:00
|
|
|
scm_c_use_module("gnucash app-utils");
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (argc > 1)
|
|
|
|
count = atoi (argv[1]);
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
if (count < 0)
|
|
|
|
count = 0;
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
xaccLogDisable ();
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
run_tests (count);
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
print_test_results ();
|
2002-06-04 21:56:15 -05:00
|
|
|
|
2009-12-29 14:12:48 -06:00
|
|
|
exit (get_rv ());
|
2002-06-04 21:56:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2009-12-29 14:12:48 -06:00
|
|
|
scm_boot_guile (argc, argv, main_helper, NULL);
|
|
|
|
return 0;
|
2002-06-04 21:56:15 -05:00
|
|
|
}
|