28 #include <glib/gi18n.h>
30 #include "cashobjects.h"
31 #include "test-stuff.h"
33 #define TEST_MODULE_NAME "object-test"
34 #define TEST_MODULE_DESC "Test Object"
37 static const char * printable (gpointer obj);
38 static void test_printable (
const char *name, gpointer obj);
39 static void test_foreach (
QofBook *,
const char *);
61 do_test ((NULL != book),
"book null");
69 "lookup our installed object");
71 "lookup non-existant object object");
75 "test description return");
78 test_foreach (book, TEST_MODULE_NAME);
79 test_printable (TEST_MODULE_NAME, (gpointer)1);
87 do_test (col != NULL,
"foreach: NULL collection");
88 success (
"called foreach callback");
93 static void foreachCB (
QofInstance *ent, gpointer u_d)
95 do_test (FALSE,
"FAIL");
99 printable (gpointer obj)
101 do_test (obj != NULL,
"printable: object is NULL");
102 success (
"called printable callback");
103 return ((
const char *)obj);
107 test_foreach (
QofBook *book,
const char *name)
112 do_test (res == 0,
"object: Foreach: NULL, NULL, NULL");
114 do_test (res == 0,
"object: Foreach: NULL, NULL, foreachCB");
117 do_test (res == 0,
"object: Foreach: NULL, book, NULL");
119 do_test (res == 0,
"object: Foreach: NULL, book, foreachCB");
122 do_test (res == 0,
"object: Foreach: name, NULL, NULL");
124 do_test (res == 0,
"object: Foreach: name, NULL, foreachCB");
127 do_test (res != 0,
"object: Foreach: name, book, NULL");
131 do_test (res != 0,
"object: Foreach: name, book, foreachCB");
135 test_printable (
const char *name, gpointer obj)
140 "object: Printable: NULL, NULL");
142 "object: Printable: NULL, object");
144 "object: Printable: mod_name, NULL");
146 do_test (res != NULL,
"object: Printable: mod_name, object");
150 main (
int argc,
char **argv)
153 if (cashobjects_register())
156 print_test_results();
const char * qof_object_get_type_label(QofIdTypeConst type_name)
QofBook * qof_book_new(void)
#define QOF_OBJECT_VERSION
const QofObject * qof_object_lookup(QofIdTypeConst type_name)
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
void qof_close(void)
Safely close down the Query Object Framework.
const char * qof_object_printable(QofIdTypeConst type_name, gpointer instance)
gboolean qof_object_register(const QofObject *object)
void qof_init(void)
Initialise the Query Object Framework.