~siretart/gnucash/ubuntu-fullsource

« back to all changes in this revision

Viewing changes to src/engine/test/test-scm-query.c

  • Committer: Reinhard Tartler
  • Date: 2008-08-03 07:25:46 UTC
  • Revision ID: siretart@tauware.de-20080803072546-y6p8xda8zpfi62ys
import gnucash_2.2.4.orig.tar.gz

The original tarball had the md5sum: 27e660297dc5b8ce574515779d05a5a5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "config.h"
 
3
#include <glib.h>
 
4
#include <libguile.h>
 
5
 
 
6
#include "engine-helpers.h"
 
7
#include "gnc-module.h"
 
8
#include "test-engine-stuff.h"
 
9
#include "test-stuff.h"
 
10
#include "Query.h"
 
11
#include "TransLog.h"
 
12
 
 
13
 
 
14
static void
 
15
test_query (Query *q)
 
16
{
 
17
  SCM scm_q;
 
18
  Query *q2;
 
19
 
 
20
  scm_q = gnc_query2scm (q);
 
21
 
 
22
  q2 = gnc_scm2query (scm_q);
 
23
 
 
24
  if (!xaccQueryEqual (q, q2))
 
25
  {
 
26
    failure ("queries don't match");
 
27
    scm_display (scm_q, SCM_UNDEFINED);
 
28
    scm_newline (SCM_UNDEFINED);
 
29
    scm_q = gnc_query2scm (q2);
 
30
    scm_display (scm_q, SCM_UNDEFINED);
 
31
    scm_newline (SCM_UNDEFINED);
 
32
    exit (1);
 
33
  }
 
34
  else
 
35
  {
 
36
    success ("queries match");
 
37
  }
 
38
 
 
39
  xaccFreeQuery (q2);
 
40
}
 
41
 
 
42
static void
 
43
run_tests (void)
 
44
{
 
45
  Query *q;
 
46
  int i;
 
47
 
 
48
  test_query (NULL);
 
49
 
 
50
  q = xaccMallocQuery ();
 
51
  test_query (q);
 
52
  xaccFreeQuery (q);
 
53
 
 
54
  for (i = 0; i < 50; i++)
 
55
  {
 
56
    q = get_random_query ();
 
57
    test_query (q);
 
58
    xaccFreeQuery (q);
 
59
  }
 
60
}
 
61
 
 
62
static void
 
63
main_helper (void *closure, int argc, char **argv)
 
64
{
 
65
  gnc_module_load("gnucash/engine", 0);
 
66
 
 
67
  xaccLogDisable ();
 
68
 
 
69
  /* scm conversion doesn't handle binary atm */
 
70
  kvp_exclude_type (KVP_TYPE_BINARY);
 
71
 
 
72
  run_tests ();
 
73
 
 
74
  print_test_results ();
 
75
 
 
76
  exit (get_rv ());
 
77
}
 
78
 
 
79
int
 
80
main (int argc, char **argv)
 
81
{
 
82
  scm_boot_guile (argc, argv, main_helper, NULL);
 
83
  return 0;
 
84
}