31 #include "gnc-module.h"
34 #include "test-stuff.h"
36 #define TEST_MODULE_NAME "business-test"
37 #define TEST_MODULE_DESC "Test Business"
40 static GList * get_list (
QofBook *, gboolean show_all);
41 static const char * printable (gpointer obj);
42 static void test_printable (
const char *name, gpointer obj);
43 static void test_get_list (
QofBook *,
const char *);
45 static GncBusinessObject bus_obj =
56 static void test_business (
void)
60 do_test (!gncBusinessRegister (NULL),
"register NULL");
61 do_test (gncBusinessRegister (&bus_obj),
"register test object");
62 do_test (!gncBusinessRegister (&bus_obj),
"register test object again");
63 do_test (gncBusinessLookup (TEST_MODULE_NAME) == &bus_obj,
64 "lookup our installed object");
65 do_test (gncBusinessLookup (
"snm98sn snml say dyikh9y9ha") == NULL,
66 "lookup non-existant business object");
68 do_test (!g_strcmp0 (gncBusinessGetTypeLabel (TEST_MODULE_NAME),
70 "test description return");
73 test_get_list ((
QofBook*)1, TEST_MODULE_NAME);
74 test_printable (TEST_MODULE_NAME, (gpointer)1);
78 get_list (
QofBook *book, gboolean show_all)
80 do_test (book != NULL,
"get_list: NULL business");
81 success (
"called get_list callback");
86 printable (gpointer obj)
88 do_test (obj != NULL,
"printable: object is NULL");
89 success (
"called printable callback");
90 return ((
const char *)obj);
94 test_get_list (
QofBook *book,
const char *name)
99 "business: GetList: NULL, NULL, FALSE");
101 "business: GetList: NULL, mod_name, FALSE");
103 "business: GetList: book, NULL, FALSE");
105 do_test (res != NULL,
"business: GetList: book, mod_name, FALSE");
109 test_printable (
const char *name, gpointer obj)
113 do_test (gncBusinessPrintable (NULL, NULL) == NULL,
114 "business: Printable: NULL, NULL");
115 do_test (gncBusinessPrintable (NULL, obj) == NULL,
116 "business: Printable: NULL, object");
117 do_test (gncBusinessPrintable (name, NULL) == NULL,
118 "business: Printable: mod_name, NULL");
119 res = gncBusinessPrintable (name, obj);
120 do_test (res != NULL,
"business: Printable: mod_name, object");
124 main_helper (
void *closure,
int argc,
char **argv)
126 gnc_module_load(
"gnucash/engine", 0);
128 print_test_results();
134 main (
int argc,
char **argv)
136 g_setenv (
"GNC_UNINSTALLED",
"1", TRUE);
GList * gncBusinessGetList(QofBook *book, QofIdTypeConst type_name, gboolean all_including_inactive)