add test-scm-print-import and test-print-queries

(The latter is not actually run, but is useful to me now)


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6945 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2002-06-04 22:40:45 +00:00
parent d66d0583d9
commit 146d414c73
4 changed files with 107 additions and 4 deletions

View File

@ -25,13 +25,14 @@ TESTS = \
test-group-vs-book \
test-object \
test-period \
test-query \
test-querynew \
test-query \
test-resolve-file-path \
test-split-vs-account \
test-transaction-voiding \
test-freq-spec \
test-scm-query
test-scm-query \
test-scm-query-import
GNC_TEST_DEPS := \
--gnc-module-dir ${top_builddir}/src/gnc-module \
@ -59,11 +60,14 @@ noinst_PROGRAMS = \
test-resolve-file-path \
test-scm-query \
test-split-vs-account \
test-transaction-voiding
test-transaction-voiding \
test-print-queries
EXTRA_DIST = \
test-create-account \
test-create-account.scm
test-create-account.scm \
test-scm-query-import \
test-scm-query-import.scm
clean:
rm -f translog.*

View File

@ -0,0 +1,65 @@
#include <glib.h>
#include <guile/gh.h>
#include "engine-helpers.h"
#include "gnc-module.h"
#include "test-engine-stuff.h"
#include "test-stuff.h"
#include "Query.h"
#include "TransLog.h"
static void
test_query (Query *q)
{
SCM scm_q;
scm_q = gnc_query2scm (q);
gh_display (scm_q); gh_newline (); gh_newline ();
}
static void
run_tests (int count)
{
Query *q;
int i;
for (i = 0; i < count; i++) {
q = get_random_query ();
test_query (q);
xaccFreeQuery (q);
}
success ("");
}
static void
main_helper (int argc, char **argv)
{
int count = 50;
gnc_module_load("gnucash/engine", 0);
if (argc > 1)
count = atoi (argv[1]);
if (count < 0)
count = 0;
xaccLogDisable ();
/* scm conversion doesn't handle binary atm */
kvp_exclude_type (KVP_TYPE_BINARY);
run_tests (count);
print_test_results ();
exit (get_rv ());
}
int
main (int argc, char **argv)
{
gh_enter (argc, argv, main_helper);
return 0;
}

View File

@ -0,0 +1,2 @@
#!/bin/sh
guile -l $SRCDIR/test-scm-query-import.scm -c "(exit (run-test))"

View File

@ -0,0 +1,32 @@
;; test-scm-query-import.scm
;; load the engine and test the import of some old-style scheme queries
(use-modules (gnucash gnc-module))
(define query-list
(list
'((terms (((pd-account pr-account #t acct-match-any ("39d55759e0561fe7c7a5b6a99deb17a0"))))) (primary-sort by-standard) (secondary-sort by-none) (tertiary-sort by-none) (primary-increasing #t) (secondary-increasing #t) (tertiary-increasing #t) (max-splits -1))
))
(define (run-test)
(gnc:module-system-init)
(gnc:module-load "gnucash/engine" 0)
(let* ((session (gnc:session-new))
(book (gnc:session-get-book session))
(failures #f))
(for-each
(lambda (query-scm)
(let* ((q (gnc:scm->query query-scm))
(q2 (gnc:query->scm q)))
(if (or (null? q) (not q))
(begin
(set! failures #t)
(display query-scm)
(display "\n")
(display q2)
(display "\n")))))
query-list)
(not failures)))