2001-08-07 23:29:04 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
2003-02-22 08:15:53 +00:00
|
|
|
#include <libguile.h>
|
2001-08-07 23:29:04 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
2001-10-26 12:10:06 +00:00
|
|
|
#include "gnc-module.h"
|
2001-08-07 23:29:04 +00:00
|
|
|
#include "gnc-xml-helper.h"
|
|
|
|
|
#include "gnc-xml.h"
|
|
|
|
|
#include "gnc-engine-util.h"
|
2001-09-29 00:08:44 +00:00
|
|
|
#include "gnc-engine.h"
|
2001-08-07 23:29:04 +00:00
|
|
|
|
|
|
|
|
#include "sixtp-parsers.h"
|
|
|
|
|
|
|
|
|
|
#include "sixtp-dom-parsers.h"
|
|
|
|
|
#include "TransLog.h"
|
|
|
|
|
#include "io-gncxml-gen.h"
|
|
|
|
|
|
2001-08-18 20:33:51 +00:00
|
|
|
#include "test-stuff.h"
|
|
|
|
|
#include "test-engine-stuff.h"
|
|
|
|
|
#include "test-file-stuff.h"
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
#include "AccountP.h"
|
2001-08-07 23:29:04 +00:00
|
|
|
#include "Transaction.h"
|
2002-12-28 21:25:58 +00:00
|
|
|
#include "TransactionP.h"
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-11-24 12:10:42 +00:00
|
|
|
static GNCBook *book;
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
extern gboolean gnc_transaction_xml_v2_testing;
|
|
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
static xmlNodePtr
|
|
|
|
|
find_appropriate_node(xmlNodePtr node, Split *spl)
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr mark;
|
|
|
|
|
|
|
|
|
|
for(mark = node->xmlChildrenNode; mark; mark = mark->next)
|
|
|
|
|
{
|
|
|
|
|
gboolean account_guid_good = FALSE;
|
|
|
|
|
gboolean amount_good = FALSE;
|
|
|
|
|
xmlNodePtr mark2;
|
|
|
|
|
|
|
|
|
|
for(mark2 = mark->xmlChildrenNode; mark2; mark2 = mark2->next)
|
|
|
|
|
{
|
|
|
|
|
if(safe_strcmp(mark2->name, "split:value") == 0)
|
|
|
|
|
{
|
|
|
|
|
gnc_numeric *num = dom_tree_to_gnc_numeric(mark2);
|
|
|
|
|
|
2002-06-18 22:21:46 +00:00
|
|
|
if(gnc_numeric_equal(*num, xaccSplitGetValue(spl)))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
amount_good = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free(num);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark2->name, "split:account") == 0)
|
|
|
|
|
{
|
|
|
|
|
GUID *accid = dom_tree_to_guid(mark2);
|
2001-12-06 09:30:25 +00:00
|
|
|
Account *account = xaccSplitGetAccount (spl);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
if(guid_equal(accid, xaccAccountGetGUID(account)))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
account_guid_good = TRUE;
|
|
|
|
|
}
|
|
|
|
|
g_free(accid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(account_guid_good && amount_good)
|
|
|
|
|
{
|
|
|
|
|
return mark;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-18 21:38:35 +00:00
|
|
|
static char *
|
2001-08-07 23:29:04 +00:00
|
|
|
equals_node_val_vs_split_internal(xmlNodePtr node, Split* spl)
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr mark;
|
|
|
|
|
|
|
|
|
|
for(mark = node->childs; mark != NULL; mark = mark->next)
|
|
|
|
|
{
|
|
|
|
|
if(safe_strcmp(mark->name, "split:id") == 0)
|
|
|
|
|
{
|
|
|
|
|
GUID *id = dom_tree_to_guid(mark);
|
|
|
|
|
|
|
|
|
|
if(!guid_equal(id, xaccSplitGetGUID(spl)))
|
|
|
|
|
{
|
|
|
|
|
g_free(id);
|
2002-06-18 21:38:35 +00:00
|
|
|
return "ids differ";
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(id);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "split:memo") == 0)
|
|
|
|
|
{
|
|
|
|
|
char *memo = dom_tree_to_text(mark);
|
|
|
|
|
|
|
|
|
|
if(safe_strcmp(memo, xaccSplitGetMemo(spl)) != 0)
|
|
|
|
|
{
|
|
|
|
|
g_free(memo);
|
2002-06-18 21:38:35 +00:00
|
|
|
return "memos differ";
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(memo);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "split:reconciled-state") == 0)
|
|
|
|
|
{
|
|
|
|
|
char *rs = dom_tree_to_text(mark);
|
|
|
|
|
|
|
|
|
|
if(rs[0] != xaccSplitGetReconcile(spl))
|
|
|
|
|
{
|
|
|
|
|
g_free(rs);
|
2002-06-18 21:38:35 +00:00
|
|
|
return "states differ";
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(rs);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "split:value") == 0)
|
|
|
|
|
{
|
|
|
|
|
gnc_numeric *num = dom_tree_to_gnc_numeric(mark);
|
2003-09-01 15:08:26 +00:00
|
|
|
gnc_numeric val = xaccSplitGetValue(spl);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2002-10-15 02:01:09 +00:00
|
|
|
if(!gnc_numeric_equal(*num, val))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
g_free(num);
|
2002-06-18 22:21:46 +00:00
|
|
|
return g_strdup_printf ("values differ: %lld/%lld v %lld/%lld",
|
2003-09-01 15:08:26 +00:00
|
|
|
(*num).num, (*num).denom,
|
|
|
|
|
val.num, val.denom);
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(num);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "split:quantity") == 0)
|
|
|
|
|
{
|
|
|
|
|
gnc_numeric *num = dom_tree_to_gnc_numeric(mark);
|
2003-09-01 15:08:26 +00:00
|
|
|
gnc_numeric val = xaccSplitGetAmount(spl);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2002-10-15 02:01:09 +00:00
|
|
|
if (!gnc_numeric_equal(*num, val)) {
|
2002-10-06 22:31:05 +00:00
|
|
|
return g_strdup_printf( "quantities differ under _equal: %lld/%lld v %lld/%lld",
|
|
|
|
|
(*num).num, (*num).denom,
|
|
|
|
|
val.num, val.denom );
|
|
|
|
|
}
|
2002-10-15 02:01:09 +00:00
|
|
|
if(!gnc_numeric_equal(*num, val))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
g_free(num);
|
2002-06-18 22:21:46 +00:00
|
|
|
return g_strdup_printf ("quantities differ: %lld/%lld v %lld/%lld",
|
2003-09-01 15:08:26 +00:00
|
|
|
(*num).num, (*num).denom,
|
|
|
|
|
val.num, val.denom);
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(num);
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "split:account") == 0)
|
|
|
|
|
{
|
|
|
|
|
GUID *id = dom_tree_to_guid(mark);
|
2001-12-06 09:30:25 +00:00
|
|
|
Account *account = xaccSplitGetAccount (spl);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
if(!guid_equal(id, xaccAccountGetGUID(account)))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
g_free(id);
|
2002-06-18 21:38:35 +00:00
|
|
|
return "accounts differ";
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
g_free(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-18 21:38:35 +00:00
|
|
|
return NULL;
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
2002-06-18 21:38:35 +00:00
|
|
|
static char *
|
2001-08-07 23:29:04 +00:00
|
|
|
equals_node_val_vs_splits(xmlNodePtr node, const Transaction *trn)
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr spl_node;
|
|
|
|
|
Split *spl_mark;
|
2002-06-18 21:38:35 +00:00
|
|
|
char *msg;
|
2001-08-07 23:29:04 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail(node, FALSE);
|
|
|
|
|
g_return_val_if_fail(node->xmlChildrenNode, FALSE);
|
|
|
|
|
|
|
|
|
|
for(i = 0, spl_mark = xaccTransGetSplit((Transaction*)trn, i);
|
|
|
|
|
spl_mark;
|
|
|
|
|
i++, spl_mark = xaccTransGetSplit((Transaction*)trn, i))
|
|
|
|
|
{
|
|
|
|
|
spl_node = find_appropriate_node(node, spl_mark);
|
|
|
|
|
|
|
|
|
|
if(!spl_node)
|
|
|
|
|
{
|
2002-06-18 21:38:35 +00:00
|
|
|
return "no matching split found";
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
2003-09-01 15:08:26 +00:00
|
|
|
msg = equals_node_val_vs_split_internal(spl_node, spl_mark);
|
2002-06-18 21:38:35 +00:00
|
|
|
if(msg != NULL)
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
2002-06-18 21:38:35 +00:00
|
|
|
return msg;
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-18 21:38:35 +00:00
|
|
|
return NULL;
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gchar*
|
|
|
|
|
node_and_transaction_equal(xmlNodePtr node, Transaction *trn)
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr mark;
|
|
|
|
|
|
2001-10-11 11:35:50 +00:00
|
|
|
while (safe_strcmp (node->name, "text") == 0)
|
|
|
|
|
node = node->next;
|
|
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
if(!check_dom_tree_version(node, "2.0.0"))
|
|
|
|
|
{
|
|
|
|
|
return "version wrong. Not 2.0.0 or not there";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!node->name || safe_strcmp(node->name, "gnc:transaction"))
|
|
|
|
|
{
|
|
|
|
|
return "Name of toplevel node is bad";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(mark = node->xmlChildrenNode; mark; mark = mark->next)
|
|
|
|
|
{
|
2001-10-11 11:35:50 +00:00
|
|
|
if(safe_strcmp(mark->name, "text") == 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:id") == 0)
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_guid(mark, xaccTransGetGUID(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "ids differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:currency") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_commodity(
|
2002-01-02 04:28:32 +00:00
|
|
|
mark, xaccTransGetCurrency(trn), xaccTransGetBook(trn)))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
return g_strdup("currencies differ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:num") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_string(mark, xaccTransGetNum(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "nums differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:date-posted") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_date(mark, xaccTransRetDatePostedTS(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "posted dates differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:date-entered") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_date(mark, xaccTransRetDateEnteredTS(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "entered dates differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:description") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_string(mark, xaccTransGetDescription(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "descriptions differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:slots") == 0)
|
|
|
|
|
{
|
|
|
|
|
if(!equals_node_val_vs_kvp_frame(mark, xaccTransGetSlots(trn)))
|
|
|
|
|
{
|
|
|
|
|
return "slots differ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(safe_strcmp(mark->name, "trn:splits") == 0)
|
|
|
|
|
{
|
2003-09-01 15:08:26 +00:00
|
|
|
char *msg = equals_node_val_vs_splits (mark, trn);
|
2002-06-18 21:38:35 +00:00
|
|
|
if(msg != NULL)
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
2003-09-01 15:08:26 +00:00
|
|
|
return msg;
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "unknown node";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
really_get_rid_of_transaction(Transaction *trn)
|
|
|
|
|
{
|
|
|
|
|
xaccTransBeginEdit(trn);
|
|
|
|
|
xaccTransDestroy(trn);
|
|
|
|
|
xaccTransCommitEdit(trn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct tran_data_struct
|
|
|
|
|
{
|
|
|
|
|
Transaction *trn;
|
2001-10-11 11:35:50 +00:00
|
|
|
Transaction *new_trn;
|
2001-09-29 00:08:44 +00:00
|
|
|
gnc_commodity *com;
|
2001-08-07 23:29:04 +00:00
|
|
|
int value;
|
|
|
|
|
};
|
|
|
|
|
typedef struct tran_data_struct tran_data;
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
test_add_transaction(const char *tag, gpointer globaldata, gpointer data)
|
|
|
|
|
{
|
2001-09-29 00:08:44 +00:00
|
|
|
Transaction *trans = data;
|
2001-08-07 23:29:04 +00:00
|
|
|
tran_data *gdata = (tran_data*)globaldata;
|
2001-09-29 00:08:44 +00:00
|
|
|
|
|
|
|
|
xaccTransBeginEdit (trans);
|
|
|
|
|
xaccTransSetCurrency (trans, gdata->com);
|
|
|
|
|
xaccTransCommitEdit (trans);
|
|
|
|
|
|
2003-06-16 03:51:01 +00:00
|
|
|
if (!do_test_args(xaccTransEqual(gdata->trn, trans, TRUE, TRUE, TRUE, FALSE),
|
2003-09-01 15:08:26 +00:00
|
|
|
"gnc_transaction_sixtp_parser_create",
|
|
|
|
|
__FILE__, __LINE__,
|
|
|
|
|
"%d", gdata->value))
|
2002-06-05 21:59:35 +00:00
|
|
|
return FALSE;
|
2001-09-29 00:08:44 +00:00
|
|
|
|
2001-10-11 11:35:50 +00:00
|
|
|
gdata->new_trn = trans;
|
2001-09-29 00:08:44 +00:00
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_transaction(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2001-10-11 11:35:50 +00:00
|
|
|
|
2002-06-05 21:59:35 +00:00
|
|
|
for(i = 0; i < 50; i++)
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
Transaction *ran_trn;
|
|
|
|
|
xmlNodePtr test_node;
|
2001-09-29 00:08:44 +00:00
|
|
|
gnc_commodity *com;
|
|
|
|
|
gchar *compare_msg;
|
2001-08-07 23:29:04 +00:00
|
|
|
gchar *filename1;
|
|
|
|
|
int fd;
|
|
|
|
|
|
2001-11-24 12:10:42 +00:00
|
|
|
ran_trn = get_random_transaction(book);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
{
|
2003-09-01 15:08:26 +00:00
|
|
|
/* xaccAccountInsertSplit can reorder the splits. */
|
2002-12-28 21:25:58 +00:00
|
|
|
GList * list = g_list_copy(xaccTransGetSplitList (ran_trn));
|
|
|
|
|
GList * node = list;
|
2001-12-06 09:30:25 +00:00
|
|
|
for ( ; node; node = node->next)
|
|
|
|
|
{
|
|
|
|
|
Split * s = node->data;
|
|
|
|
|
Account * a = xaccMallocAccount(book);
|
|
|
|
|
|
|
|
|
|
xaccAccountBeginEdit (a);
|
|
|
|
|
xaccAccountSetCommoditySCU (a, xaccSplitGetAmount (s).denom);
|
|
|
|
|
xaccAccountInsertSplit (a, s);
|
|
|
|
|
xaccAccountCommitEdit (a);
|
|
|
|
|
}
|
2003-09-01 15:08:26 +00:00
|
|
|
g_list_free(list);
|
2001-12-06 09:30:25 +00:00
|
|
|
}
|
|
|
|
|
|
2001-09-29 00:08:44 +00:00
|
|
|
com = xaccTransGetCurrency (ran_trn);
|
|
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
test_node = gnc_transaction_dom_tree_create(ran_trn);
|
|
|
|
|
if(!test_node)
|
|
|
|
|
{
|
|
|
|
|
failure_args("transaction_xml", __FILE__, __LINE__,
|
|
|
|
|
"gnc_transaction_dom_tree_create returned NULL");
|
|
|
|
|
really_get_rid_of_transaction(ran_trn);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((compare_msg = node_and_transaction_equal(test_node, ran_trn)) !=
|
|
|
|
|
NULL)
|
|
|
|
|
{
|
|
|
|
|
failure_args("transaction_xml", __FILE__, __LINE__,
|
|
|
|
|
"node and transaction were not equal: %s",
|
|
|
|
|
compare_msg);
|
|
|
|
|
xmlElemDump(stdout, NULL, test_node);
|
|
|
|
|
printf("\n");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
xmlFreeNode(test_node);
|
|
|
|
|
really_get_rid_of_transaction(ran_trn);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
success_args("transaction_xml", __FILE__, __LINE__, "%d", i );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filename1 = g_strdup_printf("test_file_XXXXXX");
|
|
|
|
|
|
|
|
|
|
fd = mkstemp(filename1);
|
|
|
|
|
|
|
|
|
|
write_dom_node_to_file(test_node, fd);
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
{
|
|
|
|
|
GList * node = xaccTransGetSplitList (ran_trn);
|
|
|
|
|
for ( ; node; node = node->next)
|
|
|
|
|
{
|
|
|
|
|
Split * s = node->data;
|
|
|
|
|
Account * a1 = xaccSplitGetAccount(s);
|
|
|
|
|
Account * a2 = xaccMallocAccount(book);
|
|
|
|
|
|
|
|
|
|
xaccAccountBeginEdit (a2);
|
|
|
|
|
xaccAccountSetCommoditySCU (a2, xaccAccountGetCommoditySCU (a1));
|
|
|
|
|
xaccAccountSetGUID (a2, xaccAccountGetGUID (a1));
|
|
|
|
|
xaccAccountCommitEdit (a2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
sixtp *parser;
|
|
|
|
|
tran_data data;
|
|
|
|
|
|
|
|
|
|
data.trn = ran_trn;
|
2001-09-29 00:08:44 +00:00
|
|
|
data.com = com;
|
2001-08-07 23:29:04 +00:00
|
|
|
data.value = i;
|
2001-12-06 09:30:25 +00:00
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
parser = gnc_transaction_sixtp_parser_create();
|
|
|
|
|
|
|
|
|
|
if(!gnc_xml_parse_file(parser, filename1, test_add_transaction,
|
2001-11-24 12:10:42 +00:00
|
|
|
(gpointer)&data, book))
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
|
|
|
|
failure_args("gnc_xml_parse_file returned FALSE",
|
2003-09-01 15:08:26 +00:00
|
|
|
__FILE__, __LINE__, "%d", i);
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
2001-10-11 11:35:50 +00:00
|
|
|
else
|
|
|
|
|
really_get_rid_of_transaction (data.new_trn);
|
2001-08-07 23:29:04 +00:00
|
|
|
|
|
|
|
|
/* no handling of circular data structures. We'll do that later */
|
|
|
|
|
/* sixtp_destroy(parser); */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unlink(filename1);
|
|
|
|
|
g_free(filename1);
|
|
|
|
|
really_get_rid_of_transaction(ran_trn);
|
|
|
|
|
xmlFreeNode(test_node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
test_real_transaction(const char *tag, gpointer global_data, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
const char *msg;
|
|
|
|
|
|
|
|
|
|
msg = node_and_transaction_equal((xmlNodePtr)global_data,
|
|
|
|
|
(Transaction*)data);
|
|
|
|
|
do_test_args(msg == NULL, "test_real_transaction",
|
|
|
|
|
__FILE__, __LINE__, msg);
|
|
|
|
|
really_get_rid_of_transaction((Transaction*)data);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-03 10:07:45 +00:00
|
|
|
static void
|
2003-02-22 08:15:53 +00:00
|
|
|
guile_main (void *closure, int argc, char **argv)
|
2001-08-07 23:29:04 +00:00
|
|
|
{
|
2001-10-03 10:07:45 +00:00
|
|
|
gnc_module_system_init();
|
|
|
|
|
gnc_module_load("gnucash/engine", 0);
|
|
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
xaccLogDisable();
|
2001-10-03 10:07:45 +00:00
|
|
|
|
2001-12-06 09:30:25 +00:00
|
|
|
gnc_transaction_xml_v2_testing = TRUE;
|
|
|
|
|
|
2001-11-24 12:10:42 +00:00
|
|
|
book = gnc_book_new ();
|
2001-10-03 10:07:45 +00:00
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
test_files_in_dir(argc, argv, test_real_transaction,
|
|
|
|
|
gnc_transaction_sixtp_parser_create(),
|
2001-11-24 12:10:42 +00:00
|
|
|
"gnc:transaction", book);
|
2001-08-07 23:29:04 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
test_transaction();
|
|
|
|
|
}
|
2001-10-03 10:07:45 +00:00
|
|
|
|
2001-08-07 23:29:04 +00:00
|
|
|
print_test_results();
|
|
|
|
|
exit(get_rv());
|
|
|
|
|
}
|
2001-10-03 10:07:45 +00:00
|
|
|
|
|
|
|
|
int
|
2003-02-22 08:15:53 +00:00
|
|
|
main (int argc, char ** argv)
|
2001-10-03 10:07:45 +00:00
|
|
|
{
|
2003-02-22 08:15:53 +00:00
|
|
|
scm_boot_guile (argc, argv, guile_main, NULL);
|
2001-10-03 10:07:45 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|