1
/*********************************************************************
3
* Test the business code.
5
* Copyright (c) 2001 Derek Atkins <warlord@MIT.EDU>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of
10
* the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, contact:
20
* Free Software Foundation Voice: +1-617-542-5942
21
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22
* Boston, MA 02110-1301, USA gnu@gnu.org
24
*********************************************************************/
31
#include "gnc-module.h"
33
#include "gncBusiness.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 = {
55
static void test_business (void)
57
/* Test the global registration and lookup functions */
59
do_test (!gncBusinessRegister (NULL), "register NULL");
60
do_test (gncBusinessRegister (&bus_obj), "register test object");
61
do_test (!gncBusinessRegister (&bus_obj), "register test object again");
62
do_test (gncBusinessLookup (TEST_MODULE_NAME) == &bus_obj,
63
"lookup our installed object");
64
do_test (gncBusinessLookup ("snm98sn snml say dyikh9y9ha") == NULL,
65
"lookup non-existant business object");
67
do_test (!safe_strcmp (gncBusinessGetTypeLabel (TEST_MODULE_NAME),
69
"test description return");
72
test_get_list ((QofBook*)1, TEST_MODULE_NAME);
73
test_printable (TEST_MODULE_NAME, (gpointer)1);
77
get_list (QofBook *book, gboolean show_all)
79
do_test (book != NULL, "get_list: NULL business");
80
success ("called get_list callback");
85
printable (gpointer obj)
87
do_test (obj != NULL, "printable: object is NULL");
88
success ("called printable callback");
89
return ((const char *)obj);
93
test_get_list (QofBook *book, const char *name)
97
do_test (gncBusinessGetList (NULL, NULL, FALSE) == NULL,
98
"business: GetList: NULL, NULL, FALSE");
99
do_test (gncBusinessGetList (NULL, name, FALSE) == NULL,
100
"business: GetList: NULL, mod_name, FALSE");
101
do_test (gncBusinessGetList (book, NULL, FALSE) == NULL,
102
"business: GetList: book, NULL, FALSE");
103
res = gncBusinessGetList (book, name, FALSE);
104
do_test (res != NULL, "business: GetList: book, mod_name, FALSE");
108
test_printable (const char *name, gpointer obj)
112
do_test (gncBusinessPrintable (NULL, NULL) == NULL,
113
"business: Printable: NULL, NULL");
114
do_test (gncBusinessPrintable (NULL, obj) == NULL,
115
"business: Printable: NULL, object");
116
do_test (gncBusinessPrintable (name, NULL) == NULL,
117
"business: Printable: mod_name, NULL");
118
res = gncBusinessPrintable (name, obj);
119
do_test (res != NULL, "business: Printable: mod_name, object");
123
main_helper (void *closure, int argc, char **argv)
125
gnc_module_load("gnucash/business-core", 0);
127
print_test_results();
133
main (int argc, char **argv)
135
// scm_boot_guile (argc, argv, main_helper, NULL);