|
GnuCash 2.4.99
|
00001 00002 #include "config.h" 00003 #include <glib.h> 00004 #include <libguile.h> 00005 #include "guile-mappings.h" 00006 00007 #include "engine-helpers.h" 00008 #include "gnc-module.h" 00009 #include "test-engine-stuff.h" 00010 #include "test-stuff.h" 00011 #include "Query.h" 00012 #include "TransLog.h" 00013 00014 00015 static void 00016 test_query (Query *q, SCM val2str) 00017 { 00018 SCM scm_q; 00019 SCM str_q; 00020 SCM args = SCM_EOL; 00021 00022 scm_q = gnc_query2scm (q); 00023 args = scm_cons (scm_q, SCM_EOL); 00024 str_q = scm_apply (val2str, args, SCM_EOL); 00025 00026 args = scm_cons (scm_makfrom0str ("'"), scm_cons (str_q, SCM_EOL)); 00027 str_q = scm_string_append (args); 00028 00029 scm_display (str_q, SCM_UNDEFINED); 00030 scm_newline (SCM_UNDEFINED); 00031 scm_newline (SCM_UNDEFINED); 00032 } 00033 00034 static void 00035 run_tests (int count) 00036 { 00037 Query *q; 00038 SCM val2str; 00039 int i; 00040 00041 val2str = scm_c_eval_string ("gnc:value->string"); 00042 g_return_if_fail (scm_is_procedure (val2str)); 00043 00044 for (i = 0; i < count; i++) 00045 { 00046 q = get_random_query (); 00047 test_query (q, val2str); 00048 qof_query_destroy (q); 00049 } 00050 success (""); 00051 } 00052 00053 static void 00054 main_helper (void *closure, int argc, char **argv) 00055 { 00056 int count = 50; 00057 00058 gnc_module_load("gnucash/engine", 0); 00059 gnc_module_load("gnucash/app-utils", 0); 00060 00061 if (argc > 1) 00062 count = atoi (argv[1]); 00063 00064 if (count < 0) 00065 count = 0; 00066 00067 xaccLogDisable (); 00068 00069 /* scm conversion doesn't handle binary atm */ 00070 kvp_exclude_type (KVP_TYPE_BINARY); 00071 00072 run_tests (count); 00073 00074 print_test_results (); 00075 00076 exit (get_rv ()); 00077 } 00078 00079 int 00080 main (int argc, char **argv) 00081 { 00082 scm_boot_guile (argc, argv, main_helper, NULL); 00083 return 0; 00084 }
1.7.4