30 #include <qofinstance-p.h>
32 #include "gncEmployeeP.h"
33 #include "gncCustomerP.h"
35 #include "gncInvoiceP.h"
36 #include "test-stuff.h"
41 test_string_fcn (
QofBook *book,
const char *message,
46 test_numeric_fcn (
QofBook *book,
const char *message,
51 test_bool_fcn (
QofBook *book,
const char *message,
57 test_gint_fcn (
QofBook *book,
const char *message,
72 do_test (gncEmployeeCreate (NULL) == NULL,
"employee create NULL");
73 employee = gncEmployeeCreate (book);
74 do_test (employee != NULL,
"employee create");
78 gncEmployeeBeginEdit (employee);
79 gncEmployeeDestroy (employee);
80 success (
"create/destroy");
87 test_string_fcn (book,
"Id", gncEmployeeSetID, gncEmployeeGetID);
88 test_string_fcn (book,
"Username", gncEmployeeSetUsername, gncEmployeeGetUsername);
89 test_string_fcn (book,
"Language", gncEmployeeSetLanguage, gncEmployeeGetLanguage);
90 test_string_fcn (book,
"Acl", gncEmployeeSetAcl, gncEmployeeGetAcl);
92 test_numeric_fcn (book,
"Workday", gncEmployeeSetWorkday, gncEmployeeGetWorkday);
93 test_numeric_fcn (book,
"Rate", gncEmployeeSetRate, gncEmployeeGetRate);
95 test_bool_fcn (book,
"Active", gncEmployeeSetActive, gncEmployeeGetActive);
97 do_test (gncEmployeeGetAddr (employee) != NULL,
"Addr");
100 employee = gncEmployeeCreate (book);
102 gncEmployeeSetGUID (employee, &guid);
109 do_test (list != NULL,
"getList all");
110 do_test (g_list_length (list) == count,
"correct length: all");
114 do_test (list != NULL,
"getList active");
115 do_test (g_list_length (list) == 1,
"correct length: active");
119 const char *str = get_random_string();
123 addr = gncEmployeeGetAddr (employee);
124 gncAddressSetName (addr, str);
126 do_test (res != NULL,
"Printable NULL?");
127 do_test (g_strcmp0 (str, res) == 0,
"Printable equals");
134 test_string_fcn (
QofBook *book,
const char *message,
139 char const *str = get_random_string ();
141 do_test (!gncEmployeeIsDirty (employee),
"test if start dirty");
142 gncEmployeeBeginEdit (employee);
145 do_test (gncEmployeeIsDirty (employee),
"test dirty later");
146 gncEmployeeCommitEdit (employee);
153 do_test (g_strcmp0 (
get (employee), str) == 0, message);
154 gncEmployeeSetActive (employee, FALSE);
159 test_numeric_fcn (
QofBook *book,
const char *message,
166 do_test (!gncEmployeeIsDirty (employee),
"test if start dirty");
167 gncEmployeeBeginEdit (employee);
170 do_test (gncEmployeeIsDirty (employee),
"test dirty later");
171 gncEmployeeCommitEdit (employee);
179 gncEmployeeSetActive (employee, FALSE);
184 test_bool_fcn (
QofBook *book,
const char *message,
189 gboolean num = get_random_boolean ();
191 do_test (!gncEmployeeIsDirty (employee),
"test if start dirty");
192 gncEmployeeBeginEdit (employee);
193 set (employee, FALSE);
194 set (employee, TRUE);
197 do_test (gncEmployeeIsDirty (employee),
"test dirty later");
198 gncEmployeeCommitEdit (employee);
205 do_test (
get (employee) == num, message);
206 gncEmployeeSetActive (employee, FALSE);
212 test_gint_fcn (
QofBook *book,
const char *message,
219 do_test (!gncEmployeeIsDirty (employee),
"test if start dirty");
220 gncEmployeeBeginEdit (employee);
223 do_test (gncEmployeeIsDirty (employee),
"test dirty later");
224 gncEmployeeCommitEdit (employee);
231 do_test (
get (employee) == num, message);
232 gncEmployeeSetActive (employee, FALSE);
238 main (
int argc,
char **argv)
241 do_test (gncInvoiceRegister(),
"Cannot register GncInvoice");
242 do_test (gncJobRegister (),
"Cannot register GncJob");
243 do_test (gncCustomerRegister(),
"Cannot register GncCustomer");
244 do_test (gncEmployeeRegister(),
"Cannot register GncEmployee");
246 print_test_results();
void guid_replace(GncGUID *guid)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
const GncGUID * qof_instance_get_guid(gconstpointer)
QofBook * qof_instance_get_book(gconstpointer)
QofBook * qof_book_new(void)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
void qof_close(void)
Safely close down the Query Object Framework.
GList * gncBusinessGetList(QofBook *book, QofIdTypeConst type_name, gboolean all_including_inactive)
const char * qof_object_printable(QofIdTypeConst type_name, gpointer instance)
void qof_init(void)
Initialise the Query Object Framework.
void qof_book_destroy(QofBook *book)