32 #include "test-stuff.h"
34 #include "test-file-stuff.h"
35 #include "cashobjects.h"
36 #include "gnc-xml-helper.h"
39 #include "sixtp-parsers.h"
40 #include "sixtp-utils.h"
41 #include "sixtp-dom-parsers.h"
42 #include "sixtp-dom-generators.h"
46 #define GNC_V2_STRING "gnc-v2"
47 const gchar *gnc_v2_xml_version_string = GNC_V2_STRING;
50 test_dom_tree_to_commodity_ref(
void)
53 for (i = 0; i < 20; i++)
64 test_str1 = get_random_string();
65 test_str2 = get_random_string();
68 test_node = commodity_ref_to_dom_tree(
"test-com", test_com1);
70 test_com2 = dom_tree_to_commodity_ref_no_engine(test_node, book);
73 "dom_tree_to_commodity_ref_no_engine");
75 xmlFreeNode(test_node);
86 test_dom_tree_to_text(
void)
90 for (i = 0; i < 20; i++)
96 test_node = xmlNewNode(NULL, BAD_CAST
"test-node");
97 test_string1 = get_random_string();
99 xmlNodeAddContent(test_node, BAD_CAST test_string1);
101 test_string2 = dom_tree_to_text(test_node);
105 failure_args(
"dom_tree_to_text", __FILE__, __LINE__,
106 "null return from dom_tree_to_text");
107 xmlElemDump(stdout, NULL, test_node);
109 else if (g_strcmp0(test_string1, test_string2) == 0)
111 success_args(
"dom_tree_to_text", __FILE__, __LINE__,
"with string %s",
116 failure_args(
"dom_tree_to_text", __FILE__, __LINE__,
117 "with string %s", test_string1);
120 xmlFreeNode(test_node);
121 g_free(test_string1);
122 if (test_string2) g_free(test_string2);
128 test_dom_tree_to_timespec(
void)
131 for (i = 0; i < 20; i++)
135 xmlNodePtr test_node;
137 test_spec1 = get_random_timespec();
139 test_node = timespec_to_dom_tree(
"test-spec", test_spec1);
141 test_spec2 = dom_tree_to_timespec(test_node);
143 if (!dom_tree_valid_timespec(&test_spec2, (
const xmlChar*)
"test-spec"))
145 failure_args(
"dom_tree_to_timespec",
146 __FILE__, __LINE__,
"NULL return");
147 printf(
"Node looks like:\n");
148 xmlElemDump(stdout, NULL, test_node);
154 success(
"dom_tree_to_timespec");
158 failure(
"dom_tree_to_timespec");
159 printf(
"Node looks like:\n");
160 xmlElemDump(stdout, NULL, test_node);
162 printf(
"Secs are %" G_GUINT64_FORMAT
" vs %" G_GUINT64_FORMAT
" :: ",
165 printf(
"NSecs are %ld vs %ld\n",
171 xmlFreeNode(test_node);
180 xmlNodePtr to_gen = NULL;
182 to_gen = gnc_numeric_to_dom_tree(
"test-num", &to_test);
185 ret =
"no dom tree created";
189 to_compare = dom_tree_to_gnc_numeric(to_gen);
192 ret =
"no gnc_numeric parsed";
198 ret =
"numerics compared different";
216 test_dom_tree_to_gnc_numeric(
void)
220 for (i = 0; i < 20; i++)
222 gchar *message = NULL;
224 message = test_gnc_nums_internal(get_random_gnc_numeric(
GNC_DENOM_AUTO));
226 do_test_args(message == NULL,
"dom_tree_to_gnc_numeric",
227 __FILE__, __LINE__, message);
231 gchar *message = NULL;
233 message = test_gnc_nums_internal
234 (gnc_numeric_create(18768786810LL, 100000));
236 do_test_args(message == NULL,
"gnc_num 18768786810/100000",
237 __FILE__, __LINE__, message);
243 test_dom_tree_to_guid(
void)
246 for (i = 0; i < 20; i++)
250 xmlNodePtr test_node;
252 test_guid1 = get_random_guid();
254 if (!(test_node = guid_to_dom_tree(
"test-guid", test_guid1)))
256 failure_args(
"guid_to_dom_tree", __FILE__, __LINE__,
257 "conversion to dom tree failed");
260 test_guid2 = dom_tree_to_guid(test_node);
263 "dom_tree_to_guid" );
265 xmlFreeNode(test_node);
272 main(
int argc,
char **argv)
275 cashobjects_register();
276 test_dom_tree_to_guid();
278 test_dom_tree_to_commodity_ref();
280 test_dom_tree_to_text();
282 test_dom_tree_to_timespec();
284 test_dom_tree_to_gnc_numeric();
286 print_test_results();
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
QofBook * qof_book_new(void)
Use a 64-bit unsigned int timespec.
gint timespec_cmp(const Timespec *ta, const Timespec *tb)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
gnc_commodity * gnc_commodity_new(QofBook *book, const char *fullname, const char *name_space, const char *mnemonic, const char *cusip, int fraction)
All type declarations for the whole Gnucash engine.
void qof_close(void)
Safely close down the Query Object Framework.
void qof_init(void)
Initialise the Query Object Framework.
Commodity handling public routines.
void gnc_commodity_destroy(gnc_commodity *cm)
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
void qof_book_destroy(QofBook *book)