GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test-querynew.c
1 /***************************************************************************
2  * test-querynew.c
3  *
4  * Tue Sep 27 19:18:57 2005
5  * Copyright 2005 GnuCash team
6  ****************************************************************************/
7 /*
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301, USA.
22  */
23 
24 #include "config.h"
25 #include <glib.h>
26 #include <stdio.h>
27 #include <qof.h>
28 #include <test-stuff.h>
29 #include <unittest-support.h>
30 #include "../cashobjects.h"
31 
32 #define TEST_MODULE_NAME "TestModuleName"
33 #define TEST_CORE "TestCoreType"
34 #define TEST_PARAM "test-param"
35 #define BAD_PARAM "bad-param"
36 
37 static int test_sort (gpointer a, gpointer b)
38 {
39  return 0;
40 }
41 
42 static int test_core_param (gpointer a)
43 {
44  return 0;
45 }
46 
47 static void test_class (void)
48 {
49  static QofParam params[] =
50  {
51  { TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param, NULL },
52  { NULL },
53  };
54 
55  gchar *msg1 = "qof_class_get_parameter: assertion `obj_name' failed";
56  gchar *msg2 = "qof_class_get_parameter: assertion `parameter' failed";
57  gchar *logdomain = "qof";
58  guint loglevel = G_LOG_LEVEL_CRITICAL;
59  TestErrorStruct check1 = { loglevel, logdomain, msg1 };
60  TestErrorStruct check2 = { loglevel, logdomain, msg2 };
61  test_add_error (&check1);
62  test_add_error (&check2);
63  g_log_set_handler (logdomain, loglevel,
64  (GLogFunc)test_list_handler, NULL);
65 
66 
67  qof_class_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params);
68 
69  do_test (qof_class_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
70  == &params[0], "qof_class_get_parameter");
71  do_test (qof_class_get_parameter (NULL, NULL) == NULL,
72  "qof_class_get_parameter (NULL, NULL)");
73  do_test (qof_class_get_parameter (TEST_MODULE_NAME, NULL) == NULL,
74  "qof_class_get_parameter (TEST_MODULE_NAME, NULL)");
75  do_test (qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL,
76  "qof_class_get_parameter (TEST_MODULE_NAME, BAD_PARAM)");
77  do_test (qof_class_get_parameter (NULL, TEST_PARAM) == NULL,
78  "qof_class_get_parameter (NULL, TEST_PARAM)");
79 
80  do_test (qof_class_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
81  == (QofAccessFunc)test_core_param,
82  "qof_class_get_parameter_getter");
83 
84  do_test (g_strcmp0 (qof_class_get_parameter_type (TEST_MODULE_NAME,
85  TEST_PARAM),
86  TEST_CORE) == 0, "qof_class_get_parameter_type");
87 
88  /* do_test (qof_class_get_default_sort (TEST_MODULE_NAME) == test_sort,
89  "qof_class_get_default_sort");
90  do_test (qof_class_get_default_sort (NULL) == NULL,
91  "qof_class_get_default_sort (NULL)");*/
92  test_clear_error_list ();
93 }
94 
95 static void test_query_core (void)
96 {
97 
98 }
99 
100 static void test_querynew (void)
101 {
102 }
103 
104 int
105 main (int argc, char **argv)
106 {
107  qof_init();
108  if (cashobjects_register())
109  {
110  test_query_core();
111  test_class();
112  test_querynew();
113  }
114  qof_close();
115  print_test_results();
116  return get_rv();
117 }
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_fcn, const QofParam *params)
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
Definition: qofclass.h:177
QofAccessFunc qof_class_get_parameter_getter(QofIdTypeConst obj_name, const char *parameter)
const QofParam * qof_class_get_parameter(QofIdTypeConst obj_name, const char *parameter)
int(* QofSortFunc)(gconstpointer, gconstpointer)
Definition: qofclass.h:222
void qof_close(void)
Safely close down the Query Object Framework.
void qof_init(void)
Initialise the Query Object Framework.
QofType qof_class_get_parameter_type(QofIdTypeConst obj_name, const char *param_name)