28 #include "qofsession-p.h"
29 #include "cashobjects.h"
30 #include "test-dbi-stuff.h"
31 #include <unittest-support.h>
39 #include "../gnc-backend-dbi-priv.h"
41 G_GNUC_UNUSED
static QofLogModule log_module =
"test-dbi";
44 static void do_test (G_GNUC_UNUSED gboolean
foo, G_GNUC_UNUSED gchar* bar)
65 Account* root_1 = gnc_book_get_root_account( book_1 );
66 Account* root_2 = gnc_book_get_root_account( book_2 );
73 compare_single_tx(
QofInstance* inst, gpointer user_data )
86 do_compare( book_1, book_2, GNC_ID_TRANS,
87 compare_single_tx,
"Transaction lists match" );
95 for (sxitem = sxes->sx_list; sxitem != NULL; sxitem = sxitem->next)
109 #define TEST_GDATES_EQUAL(gd1, gd2) \
110 if (g_date_valid (gd1)) \
112 g_assert (g_date_valid (gd2)); \
113 g_assert (g_date_compare (gd1, gd2) == 0);\
117 compare_recurrences (GList *rl_1, GList *rl_2)
119 GList *ritem1, *ritem2;
124 g_assert (rl_2 != NULL);
125 g_assert_cmpint (g_list_length (rl_1), ==, g_list_length (rl_2));
126 for (ritem1 = rl_1, ritem2 = rl_2; ritem1 != NULL && ritem2 != NULL;
127 ritem1 = g_list_next (ritem1), ritem2 = g_list_next (ritem2))
129 Recurrence *r1 = ritem1->data, *r2 = ritem2->data;
131 TEST_GDATES_EQUAL (&r1->start, &r2->start);
132 g_assert_cmpint (r1->ptype, ==, r2->ptype);
133 g_assert_cmpint (r1->mult, ==, r2->mult);
134 g_assert_cmpint (r1->wadj, ==, r2->wadj);
139 compare_single_sx(
QofInstance* inst, gpointer user_data )
146 g_assert (sx_2 != NULL);
147 g_assert_cmpstr (sx_1->name, ==, sx_2->name);
148 compare_recurrences (sx_2->schedule, sx_1->schedule);
149 TEST_GDATES_EQUAL(&sx_2->last_date, &sx_1->last_date);
150 TEST_GDATES_EQUAL(&sx_2->start_date, &sx_1->start_date);
151 TEST_GDATES_EQUAL(&sx_2->end_date, &sx_1->end_date);
152 g_assert_cmpint (sx_2->num_occurances_total, ==,
153 sx_1->num_occurances_total);
154 g_assert_cmpint (sx_2->num_occurances_remain, ==,
155 sx_1->num_occurances_remain);
156 g_assert_cmpint (sx_2->instance_num, ==, sx_1->instance_num);
157 g_assert_cmpint (sx_2->enabled, ==, sx_1->enabled);
158 g_assert_cmpint (sx_2->autoCreateOption, ==, sx_1->autoCreateOption);
159 g_assert_cmpint (sx_2->autoCreateNotify, ==, sx_1->autoCreateNotify);
160 g_assert_cmpint (sx_2->advanceCreateDays, ==, sx_1->advanceCreateDays);
161 g_assert_cmpint (sx_2->advanceRemindDays, ==, sx_1->advanceRemindDays);
167 do_compare( book_1, book_2, GNC_ID_SCHEDXACTION,
168 compare_single_sx,
"Scheduled transaction lists match" );
175 compare_single_lot(
QofInstance* inst, gpointer user_data )
178 GNCLot *lot_1 = GNC_LOT(inst);
181 GList *split1, *splits1, *splits2;
188 qof_instance_get_slots (QOF_INSTANCE (lot_2))) == 0);
191 g_assert_cmpint (g_list_length (splits1), ==, g_list_length (splits2));
192 for (split1 = splits1; split1 != NULL; split1 = g_list_next (split1))
195 g_assert (GNC_IS_SPLIT (split1->data));
198 g_assert (GNC_IS_SPLIT (split2));
199 g_assert (
xaccSplitEqual (split1->data, split2, TRUE, TRUE, TRUE));
206 do_compare( book_1, book_2, GNC_ID_LOT, compare_single_lot,
"Lot lists match" );
214 GSList *index_list, *iter;
216 index_list = conn->provider->get_index_list( be->conn );
217 g_test_message (
"Returned from index list\n");
218 g_assert (index_list != NULL);
219 g_assert_cmpint (g_slist_length( index_list ), ==, 4);
220 for ( iter = index_list; iter != NULL; iter = g_slist_next( iter) )
223 conn->provider->drop_index (be->conn, iter->data);
224 g_assert (DBI_ERROR_NONE == dbi_conn_error( conn->conn, &errmsg));
227 g_slist_free( index_list );
235 do_compare( book_1, book_2, GNC_ID_TRANS,
236 compare_single_tx,
"Transaction lists match" );
243 compare_account_trees( book_1, book_2 );
244 compare_pricedbs( book_1, book_2 );
245 compare_txs( book_1, book_2 );
246 compare_sxs( book_1, book_2 );
247 compare_lots( book_1, book_2 );
const GncGUID * qof_instance_get_guid(gconstpointer)
gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb)
API for Transactions and Splits (journal entries)
void qof_collection_foreach(const QofCollection *, QofInstanceForeachCB, gpointer user_data)
gboolean xaccSplitEqual(const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits)
Transaction * xaccTransLookup(const GncGUID *guid, QofBook *book)
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
gboolean xaccTransEqual(const Transaction *ta, const Transaction *tb, gboolean check_guids, gboolean check_splits, gboolean check_balances, gboolean assume_ordered)
Account handling public routines.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
SplitList * gnc_lot_get_split_list(const GNCLot *lot)
Anchor Scheduled Transaction info in a book. See src/doc/books.txt for design overview.
gboolean xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
gboolean xaccAccountGetHidden(const Account *acc)
gboolean gnc_lot_is_closed(GNCLot *lot)
void xaccAccountSetHidden(Account *acc, gboolean val)
struct KvpFrameImpl KvpFrame
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
Account * gnc_lot_get_account(const GNCLot *lot)
QofBackend * qof_book_get_backend(const QofBook *book)
Retrieve the backend used by this book.
API for Transactions and Splits (journal entries)
Commodity handling public routines.
const gchar * QofLogModule