mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move test.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5183 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -6,4 +6,5 @@ test-load-engine
|
||||
test-commodities
|
||||
test-freq-spec
|
||||
test-resolve-file-path
|
||||
test-scm-query
|
||||
test-split-vs-account
|
||||
|
||||
@@ -11,6 +11,8 @@ LDADD = \
|
||||
${top_srcdir}/src/gnc-module/libgncmodule.la \
|
||||
${top_srcdir}/src/test-core/libgncmod-test.la \
|
||||
../libgncmod-engine.la \
|
||||
../libgw-engine.la \
|
||||
../libgw-glib.la \
|
||||
../test-core/libgncmod-test-engine.la \
|
||||
${GLIB_LIBS} \
|
||||
-lltdl
|
||||
@@ -21,6 +23,7 @@ TESTS = \
|
||||
test-commodities \
|
||||
test-freq-spec \
|
||||
test-resolve-file-path \
|
||||
test-scm-query \
|
||||
test-split-vs-account
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
@@ -34,4 +37,5 @@ bin_PROGRAMS = \
|
||||
test-freq-spec \
|
||||
test-load-engine \
|
||||
test-resolve-file-path \
|
||||
test-scm-query \
|
||||
test-split-vs-account
|
||||
|
||||
75
src/engine/test/test-scm-query.c
Normal file
75
src/engine/test/test-scm-query.c
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
#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"
|
||||
|
||||
|
||||
static void
|
||||
test_query (Query *q)
|
||||
{
|
||||
SCM scm_q;
|
||||
Query *q2;
|
||||
|
||||
scm_q = gnc_query2scm (q);
|
||||
|
||||
q2 = gnc_scm2query (scm_q);
|
||||
|
||||
if (!xaccQueryEqual (q, q2))
|
||||
{
|
||||
failure ("queries don't match");
|
||||
gh_display (scm_q); gh_newline ();
|
||||
scm_q = gnc_query2scm (q2);
|
||||
gh_display (scm_q); gh_newline ();
|
||||
exit (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
success ("queries match");
|
||||
}
|
||||
|
||||
xaccFreeQuery (q2);
|
||||
}
|
||||
|
||||
static void
|
||||
run_tests (void)
|
||||
{
|
||||
Query *q;
|
||||
int i;
|
||||
|
||||
test_query (NULL);
|
||||
|
||||
q = xaccMallocQuery ();
|
||||
test_query (q);
|
||||
xaccFreeQuery (q);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
q = get_random_query ();
|
||||
test_query (q);
|
||||
xaccFreeQuery (q);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
main_helper (int argc, char **argv)
|
||||
{
|
||||
|
||||
gnc_module_load("gnucash/engine", 0);
|
||||
run_tests ();
|
||||
|
||||
print_test_results ();
|
||||
|
||||
exit (get_rv ());
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gh_enter (argc, argv, main_helper);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user