QOF
0.8.7
|
00001 /********************************************************************* 00002 * test-book-merge.c -- test implementation api for QoFBook merge * 00003 * Copyright (C) 2004-2005 Neil Williams <linux@codehelp.co.uk> * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, contact: * 00017 * * 00018 * Free Software Foundation Voice: +1-617-542-5942 * 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00020 * Boston, MA 02110-1301, USA gnu@gnu.org * 00021 * * 00022 ********************************************************************/ 00023 /* Test the qof_book_merge infrastructure. */ 00024 00025 #include <glib.h> 00026 #include "qof.h" 00027 #include "qofinstance-p.h" 00028 #include "qofevent-p.h" 00029 #include "test-stuff.h" 00030 00031 #define TEST_MODULE_NAME "book-merge-test" 00032 #define TEST_MODULE_DESC "Test Book Merge" 00033 #define OBJ_NAME "somename" 00034 #define OBJ_AMOUNT "anamount" 00035 #define OBJ_DATE "nottoday" 00036 #define OBJ_GUID "unique" 00037 #define OBJ_DISCOUNT "hefty" 00038 #define OBJ_VERSION "early" 00039 #define OBJ_MINOR "tiny" 00040 #define OBJ_ACTIVE "ofcourse" 00041 #define OBJ_FLAG "tiny_flag" 00042 00043 static void test_rule_loop (QofBookMergeData *, QofBookMergeRule *, 00044 guint); 00045 static void test_merge (void); 00046 gboolean myobjRegister (void); 00047 #ifdef TEST_DEBUG 00048 static QofLogModule log_module = QOF_MOD_MERGE; 00049 #endif 00050 00051 /* simple object structure */ 00052 typedef struct obj_s 00053 { 00054 QofInstance inst; 00055 gchar *Name; 00056 gchar flag; 00057 QofNumeric Amount; 00058 const GUID *obj_guid; 00059 QofTime *date; 00060 gdouble discount; /* cheap pun, I know. */ 00061 gboolean active; 00062 gint32 version; 00063 gint64 minor; 00064 } myobj; 00065 00066 static void 00067 obj_setGUID (myobj * g, const GUID * h) 00068 { 00069 if (!g) 00070 return; 00071 g->obj_guid = h; 00072 } 00073 00074 static myobj * 00075 obj_create (QofBook * book) 00076 { 00077 myobj *g; 00078 g_return_val_if_fail (book, NULL); 00079 g = g_new (myobj, 1); 00080 qof_instance_init (&g->inst, TEST_MODULE_NAME, book); 00081 obj_setGUID (g, qof_instance_get_guid (&g->inst)); 00082 g->discount = 0; 00083 g->active = TRUE; 00084 g->version = 1; 00085 g->minor = 1; 00086 g->flag = 'n'; 00087 qof_event_gen (&g->inst.entity, QOF_EVENT_CREATE, NULL); 00088 return g; 00089 } 00090 00091 static void 00092 obj_setFlag (myobj * g, char f) 00093 { 00094 g_return_if_fail (g); 00095 g->flag = f; 00096 } 00097 00098 static gchar 00099 obj_getFlag (myobj * g) 00100 { 00101 g_return_val_if_fail (g, 'n'); 00102 return g->flag; 00103 } 00104 00105 static void 00106 obj_setMinor (myobj * g, gint64 h) 00107 { 00108 g_return_if_fail (g != NULL); 00109 g->minor = h; 00110 } 00111 00112 static gint64 00113 obj_getMinor (myobj * g) 00114 { 00115 g_return_val_if_fail ((g != NULL), 0); 00116 return g->minor; 00117 } 00118 00119 static void 00120 obj_setVersion (myobj * g, gint32 h) 00121 { 00122 g_return_if_fail (g != NULL); 00123 g->version = h; 00124 } 00125 00126 static gint32 00127 obj_getVersion (myobj * g) 00128 { 00129 if (!g) 00130 return 0; 00131 return g->version; 00132 } 00133 00134 static void 00135 obj_setActive (myobj * g, gboolean h) 00136 { 00137 if (!g) 00138 return; 00139 g->active = h; 00140 } 00141 00142 static gboolean 00143 obj_getActive (myobj * g) 00144 { 00145 if (!g) 00146 return FALSE; 00147 return g->active; 00148 } 00149 00150 static void 00151 obj_setDiscount (myobj * g, gdouble h) 00152 { 00153 if (!g) 00154 return; 00155 g->discount = h; 00156 } 00157 00158 static gdouble 00159 obj_getDiscount (myobj * g) 00160 { 00161 if (!g) 00162 return 0; 00163 return g->discount; 00164 } 00165 00166 static void 00167 obj_setDate (myobj * g, QofTime *h) 00168 { 00169 if (!g) 00170 return; 00171 do_test ((h != NULL), "passed a NULL time"); 00172 do_test ((qof_time_is_valid (h) == TRUE), 00173 "passed an invalid time"); 00174 g->date = h; 00175 } 00176 00177 static QofTime * 00178 obj_getDate (myobj * g) 00179 { 00180 if (!g) 00181 return NULL; 00182 do_test ((g->date != NULL), "stored time is NULL"); 00183 do_test ((qof_time_is_valid (g->date) == TRUE), 00184 "stored time is invalid"); 00185 return g->date; 00186 } 00187 00188 static const GUID * 00189 obj_getGUID (myobj * g) 00190 { 00191 if (!g) 00192 return NULL; 00193 return g->obj_guid; 00194 } 00195 00196 static void 00197 obj_setName (myobj * g, char *h) 00198 { 00199 if (!g || !h) 00200 return; 00201 g->Name = strdup (h); 00202 } 00203 00204 static gchar * 00205 obj_getName (myobj * g) 00206 { 00207 if (!g) 00208 return NULL; 00209 return g->Name; 00210 } 00211 00212 static void 00213 obj_setAmount (myobj * g, QofNumeric h) 00214 { 00215 if (!g) 00216 return; 00217 g->Amount = h; 00218 } 00219 00220 static QofNumeric 00221 obj_getAmount (myobj * g) 00222 { 00223 if (!g) 00224 return qof_numeric_zero (); 00225 return g->Amount; 00226 } 00227 00228 static QofObject obj_object_def = { 00229 .interface_version = QOF_OBJECT_VERSION, 00230 .e_type = TEST_MODULE_NAME, 00231 .type_label = TEST_MODULE_DESC, 00232 .create = (gpointer) obj_create, 00233 .book_begin = NULL, 00234 .book_end = NULL, 00235 .is_dirty = NULL, 00236 .mark_clean = NULL, 00237 .foreach = qof_collection_foreach, 00238 .printable = NULL, 00239 .version_cmp = (gint (*)(gpointer, gpointer)) 00240 qof_instance_version_cmp, 00241 }; 00242 00243 gboolean 00244 myobjRegister (void) 00245 { 00246 static QofParam params[] = { 00247 {OBJ_NAME, QOF_TYPE_STRING, (QofAccessFunc) obj_getName, 00248 (QofSetterFunc) obj_setName, NULL}, 00249 {OBJ_AMOUNT, QOF_TYPE_NUMERIC, (QofAccessFunc) obj_getAmount, 00250 (QofSetterFunc) obj_setAmount, NULL}, 00251 {OBJ_GUID, QOF_TYPE_GUID, (QofAccessFunc) obj_getGUID, 00252 (QofSetterFunc) obj_setGUID, NULL}, 00253 {OBJ_DATE, QOF_TYPE_TIME, (QofAccessFunc) obj_getDate, 00254 (QofSetterFunc) obj_setDate, NULL}, 00255 {OBJ_DISCOUNT, QOF_TYPE_DOUBLE, (QofAccessFunc) obj_getDiscount, 00256 (QofSetterFunc) obj_setDiscount, NULL}, 00257 {OBJ_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc) obj_getActive, 00258 (QofSetterFunc) obj_setActive, NULL}, 00259 {OBJ_VERSION, QOF_TYPE_INT32, (QofAccessFunc) obj_getVersion, 00260 (QofSetterFunc) obj_setVersion, NULL}, 00261 {OBJ_MINOR, QOF_TYPE_INT64, (QofAccessFunc) obj_getMinor, 00262 (QofSetterFunc) obj_setMinor, NULL}, 00263 {OBJ_FLAG, QOF_TYPE_CHAR, (QofAccessFunc) obj_getFlag, 00264 (QofSetterFunc) obj_setFlag, NULL}, 00265 {QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc) qof_instance_get_book, 00266 NULL, NULL}, 00267 {QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc) qof_instance_get_guid, 00268 NULL, NULL}, 00269 {NULL, NULL, NULL, NULL, NULL}, 00270 }; 00271 00272 qof_class_register (TEST_MODULE_NAME, NULL, params); 00273 00274 return qof_object_register (&obj_object_def); 00275 } 00276 00277 static void 00278 test_merge (void) 00279 { 00280 QofBook *target, *import; 00281 gdouble init_value, discount; 00282 myobj *import_obj, *target_obj, *new_obj; 00283 QofTime *base_time, *temp_time; 00284 gboolean active; 00285 gint32 version; 00286 gint64 minor; 00287 gchar *import_init, *target_init; 00288 gchar flag, flag_check; 00289 QofNumeric obj_amount; 00290 QofBookMergeData *mergeData; 00291 00292 target = qof_book_new (); 00293 import = qof_book_new (); 00294 init_value = 1.00; 00295 flag = get_random_character (); 00296 discount = 0.175; 00297 active = TRUE; 00298 version = get_random_int_in_range (0, 10000); 00299 minor = get_random_int_in_range (1000001, 2000000); 00300 import_init = "test"; 00301 target_init = "testing"; 00302 base_time = qof_time_set (1153309194, 568714241); 00303 do_test ((TRUE == qof_time_is_valid (base_time)), 00304 "invalid init time"); 00305 { 00306 gchar *str; 00307 QofDate *qd; 00308 00309 qd = qof_date_from_qtime (base_time); 00310 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00311 do_test ((0 == safe_strcmp ( 00312 "2006-07-19 11:39:54.568714241 +0000", str)), 00313 "failed to compare base_time correctly."); 00314 g_free (str); 00315 qof_date_free (qd); 00316 } 00317 00318 do_test ((NULL != target), "#1 target book is NULL"); 00319 do_test ((NULL != import), "#2 import book is NULL"); 00320 00321 /* import book objects - tests used */ 00322 import_obj = g_new (myobj, 1); 00323 do_test ((NULL != import_obj), "#3 new object create"); 00324 qof_instance_init (&import_obj->inst, TEST_MODULE_NAME, import); 00325 do_test ((NULL != &import_obj->inst), "#4 instance init"); 00326 obj_setGUID (import_obj, qof_instance_get_guid (&import_obj->inst)); 00327 do_test ((NULL != &import_obj->obj_guid), "#5 guid set"); 00328 qof_event_gen (&import_obj->inst.entity, QOF_EVENT_CREATE, NULL); 00329 do_test ((NULL != &import_obj->inst.entity), "#6 gnc event create"); 00330 obj_setName (import_obj, import_init); 00331 do_test ((NULL != &import_obj->Name), "#7 string set"); 00332 obj_amount = qof_numeric_from_double (init_value, 1, QOF_HOW_DENOM_EXACT); 00333 obj_setAmount (import_obj, obj_amount); 00334 do_test ((qof_numeric_check (obj_getAmount (import_obj)) == QOF_ERROR_OK), 00335 "#8 gnc_numeric set"); 00336 obj_setActive (import_obj, active); 00337 do_test ((FALSE != &import_obj->active), "#9 gboolean set"); 00338 obj_setDiscount (import_obj, discount); 00339 obj_setVersion (import_obj, version); 00340 do_test ((version == import_obj->version), "#11 gint32 set"); 00341 obj_setMinor (import_obj, minor); 00342 do_test ((minor == import_obj->minor), "#12 gint64 set"); 00343 do_test ((TRUE == qof_time_is_valid (base_time)), 00344 "invalid import time ts"); 00345 { 00346 gchar *str; 00347 QofDate *qd; 00348 00349 qd = qof_date_from_qtime (base_time); 00350 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00351 do_test ((0 == safe_strcmp ( 00352 "2006-07-19 11:39:54.568714241 +0000", str)), 00353 "failed to compare base_time correctly."); 00354 g_free (str); 00355 qof_date_free (qd); 00356 } 00357 obj_setDate (import_obj, base_time); 00358 do_test ((TRUE == qof_time_is_valid (import_obj->date)), 00359 "invalid import time"); 00360 do_test ((qof_time_cmp (base_time, import_obj->date) == 0), 00361 "test #13 date set"); 00362 obj_setFlag (import_obj, flag); 00363 do_test ((flag == obj_getFlag (import_obj)), "#14 flag set"); 00364 00365 obj_amount = 00366 qof_numeric_add (obj_amount, obj_amount, 1, QOF_HOW_DENOM_EXACT); 00367 discount = get_random_double (); 00368 version = 2; 00369 minor = 3; 00370 00371 /* second import object - test results would be the same, so not tested. */ 00372 new_obj = g_new (myobj, 1); 00373 qof_instance_init (&new_obj->inst, TEST_MODULE_NAME, import); 00374 obj_setGUID (new_obj, qof_instance_get_guid (&new_obj->inst)); 00375 qof_event_gen (&new_obj->inst.entity, QOF_EVENT_CREATE, NULL); 00376 obj_setName (new_obj, import_init); 00377 obj_setAmount (new_obj, obj_amount); 00378 obj_setActive (new_obj, active); 00379 obj_setDiscount (new_obj, discount); 00380 obj_setVersion (new_obj, version); 00381 obj_setMinor (new_obj, minor); 00382 do_test ((TRUE == qof_time_is_valid (base_time)), 00383 "second import time invalid"); 00384 { 00385 gchar *str; 00386 QofDate *qd; 00387 00388 qd = qof_date_from_qtime (base_time); 00389 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00390 do_test ((0 == safe_strcmp ( 00391 "2006-07-19 11:39:54.568714241 +0000", str)), 00392 "failed to compare base_time correctly."); 00393 g_free (str); 00394 qof_date_free (qd); 00395 } 00396 obj_setDate (new_obj, base_time); 00397 obj_setFlag (new_obj, flag); 00398 00399 obj_amount = 00400 qof_numeric_add (obj_amount, obj_amount, 1, QOF_HOW_DENOM_EXACT); 00401 discount = get_random_double (); 00402 version = 2; 00403 minor = 3; 00404 flag = 'z'; 00405 00406 /* target object - test results would be the same, so not tested. */ 00407 target_obj = g_new (myobj, 1); 00408 qof_instance_init (&target_obj->inst, TEST_MODULE_NAME, target); 00409 obj_setGUID (target_obj, qof_instance_get_guid (&target_obj->inst)); 00410 qof_event_gen (&target_obj->inst.entity, QOF_EVENT_CREATE, NULL); 00411 obj_setName (target_obj, target_init); 00412 obj_setAmount (target_obj, obj_amount); 00413 obj_setActive (target_obj, active); 00414 obj_setDiscount (target_obj, discount); 00415 obj_setVersion (target_obj, version); 00416 obj_setMinor (target_obj, minor); 00417 { 00418 gchar *str; 00419 QofDate *qd; 00420 00421 qd = qof_date_from_qtime (base_time); 00422 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00423 do_test ((0 == safe_strcmp ( 00424 "2006-07-19 11:39:54.568714241 +0000", str)), 00425 "failed to compare base_time correctly."); 00426 g_free (str); 00427 qof_date_free (qd); 00428 } 00429 temp_time = qof_time_add_secs_copy (base_time, 65); 00430 do_test ((TRUE == qof_time_is_valid (temp_time)), 00431 "time add secs returned invalid"); 00432 obj_setDate (target_obj, temp_time); 00433 obj_setFlag (target_obj, flag); 00434 do_test ((flag == obj_getFlag (target_obj)), "#15 flag set"); 00435 00436 mergeData = qof_book_merge_init (import, target); 00437 do_test (mergeData != NULL, 00438 "FATAL: Merge could not be initialised!\t aborting . . "); 00439 g_return_if_fail (mergeData != NULL); 00440 qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_REPORT); 00441 qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_UPDATE); 00442 qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_NEW); 00443 /* reserved calls - test only */ 00444 qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_ABSOLUTE); 00445 qof_book_merge_rule_foreach (mergeData, test_rule_loop, MERGE_DUPLICATE); 00446 00447 /* import should not be in the target - pass if import_init fails match with target */ 00448 do_test (((safe_strcmp (obj_getName (import_obj), 00449 obj_getName (target_obj))) != 0), 00450 "Init value test #1"); 00451 00452 /* a good commit returns zero */ 00453 do_test (qof_book_merge_commit (mergeData) == 0, "Commit failed"); 00454 00455 /* import should be in the target - pass if import_init matches target */ 00456 do_test (((safe_strcmp (import_init, obj_getName (target_obj))) == 0), 00457 "Merged value test #1"); 00458 00459 /* import should be the same as target - pass if values are the same */ 00460 do_test (((safe_strcmp 00461 (obj_getName (target_obj), obj_getName (import_obj))) == 0), 00462 "Merged value test #2"); 00463 00464 /* check that the Amount really is a gnc_numeric */ 00465 do_test ((qof_numeric_check (obj_getAmount (import_obj)) == QOF_ERROR_OK), 00466 "import gnc_numeric check"); 00467 do_test ((qof_numeric_check (obj_getAmount (target_obj)) == QOF_ERROR_OK), 00468 "target gnc_numeric check"); 00469 00470 /* obj_amount was changed after the import object was set, so expect a difference. */ 00471 do_test ((qof_numeric_compare (obj_getAmount (import_obj), obj_amount) != 00472 QOF_ERROR_OK), "gnc_numeric value check #1"); 00473 00474 /* obj_amount is in the target object with the import value, expect a difference/ */ 00475 do_test ((qof_numeric_compare (obj_getAmount (target_obj), obj_amount) != 00476 QOF_ERROR_OK), "gnc_numeric value check #2"); 00477 00478 /* target had a different date, so import date should now be set */ 00479 qof_time_free (temp_time); 00480 temp_time = target_obj->date; 00481 { 00482 gchar *str; 00483 QofDate *qd; 00484 00485 qd = qof_date_from_qtime (base_time); 00486 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00487 do_test ((0 == safe_strcmp ( 00488 "2006-07-19 11:39:54.568714241 +0000", str)), 00489 "failed to compare base_time after merge."); 00490 g_free (str); 00491 qof_date_free (qd); 00492 } 00493 { 00494 gchar *str; 00495 QofDate *qd; 00496 00497 qd = qof_date_from_qtime (temp_time); 00498 str = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00499 do_test ((0 == safe_strcmp ( 00500 "2006-07-19 11:39:54.568714241 +0000", str)), 00501 "failed to compare target time after merge."); 00502 g_free (str); 00503 qof_date_free (qd); 00504 } 00505 do_test ((qof_time_cmp (base_time, temp_time) == 0), 00506 "date value check: 1"); 00507 #ifdef TEST_DEBUG 00508 DEBUG (" import<->target=%d\n", 00509 (qof_time_cmp (base_time, target_obj->date))); 00510 { 00511 QofDate *qd; 00512 gchar *check; 00513 00514 qd = qof_date_from_qtime (base_time); 00515 DEBUG (" base_time=%" G_GINT64_FORMAT 00516 " nsecs=%ld", qof_time_get_secs (base_time), 00517 qof_time_get_nanosecs (base_time)); 00518 DEBUG (" import:\nyear=%" G_GINT64_FORMAT 00519 " month=%ld day=%ld hour=%ld min=%ld sec=%" 00520 G_GINT64_FORMAT "nsecs=%ld\n", 00521 qd->qd_year, qd->qd_mon, qd->qd_mday, qd->qd_hour, 00522 qd->qd_min, qd->qd_sec, qd->qd_nanosecs); 00523 check = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00524 DEBUG (" import=%s\n", check); 00525 qof_date_free (qd); 00526 qd = qof_date_from_qtime (target_obj->date); 00527 if (!qd) 00528 PERR ("qd failed"); 00529 DEBUG (" target:\nyear=%" G_GINT64_FORMAT 00530 " month=%ld day=%ld hour=%ld min=%ld sec=%" 00531 G_GINT64_FORMAT "nsecs=%ld\n", 00532 qd->qd_year, qd->qd_mon, qd->qd_mday, qd->qd_hour, 00533 qd->qd_min, qd->qd_sec, qd->qd_nanosecs); 00534 check = qof_date_print (qd, QOF_DATE_FORMAT_ISO8601); 00535 DEBUG (" target=%s\n", check); 00536 g_free (check); 00537 qof_date_free (qd); 00538 } 00539 #endif 00540 qof_time_free (base_time); 00541 /* import should be the same as target - pass if values are the same */ 00542 flag_check = obj_getFlag (target_obj); 00543 do_test ((flag_check == obj_getFlag (import_obj)), "flag value check: 1"); 00544 do_test ((obj_getFlag (import_obj) == obj_getFlag (target_obj)), 00545 "flag value check: 2"); 00546 } 00547 00548 static void 00549 test_rule_loop (QofBookMergeData * mergeData, QofBookMergeRule * rule, 00550 guint remainder) 00551 { 00552 GSList *testing; 00553 QofParam *eachParam; 00554 gchar *importstring; 00555 gchar *targetstring; 00556 gboolean skip_target; 00557 00558 importstring = NULL; 00559 targetstring = NULL; 00560 skip_target = FALSE; 00561 mergeData->currentRule = rule; 00562 do_test ((rule != NULL), "loop:#1 Rule is NULL"); 00563 do_test (remainder > 0, "loop:#2 remainder error."); 00564 do_test ((safe_strcmp (NULL, rule->mergeLabel) != 0), 00565 "loop:#3 object label\n"); 00566 do_test ((rule->importEnt != NULL), 00567 "loop:#4 empty import entity"); 00568 /* targetEnt is always NULL at this stage if MERGE_NEW is set */ 00569 if (rule->targetEnt == NULL) 00570 { 00571 skip_target = TRUE; 00572 } 00573 if (!skip_target) 00574 { 00575 do_test ((safe_strcmp 00576 (rule->importEnt->e_type, rule->targetEnt->e_type) == 0), 00577 "loop: entity type mismatch"); 00578 } 00579 do_test ((rule->mergeParam != NULL), 00580 "loop: empty parameter list"); 00581 testing = rule->mergeParam; 00582 00583 while (testing != NULL) 00584 { // start of param loop 00585 eachParam = testing->data; 00586 do_test ((eachParam != NULL), "loop:#8 no QofParam data"); 00587 do_test ((eachParam->param_name != NULL), 00588 "loop:#9 no parameter name"); 00589 do_test ((eachParam->param_getfcn != NULL), 00590 "loop:#10 no get function"); 00591 do_test ((eachParam->param_setfcn != NULL), 00592 "loop:#11 no set function"); 00593 /* non-generic - test routines only! */ 00594 if (safe_strcmp (eachParam->param_type, QOF_TYPE_STRING) == 0) 00595 { 00596 importstring = 00597 g_strdup (eachParam-> 00598 param_getfcn (rule->importEnt, eachParam)); 00599 do_test ((importstring != NULL), 00600 "loop:#12 direct get_fcn import"); 00601 do_test ((safe_strcmp (importstring, "test") == 0), 00602 "loop:#13 direct import comparison"); 00603 if (!skip_target) 00604 { 00605 targetstring = 00606 eachParam->param_getfcn (rule->targetEnt, eachParam); 00607 do_test ((targetstring != NULL), 00608 "loop:#14 direct get_fcn target"); 00609 do_test ((safe_strcmp (targetstring, "testing") == 0), 00610 "loop:#15 direct target comparison"); 00611 } 00612 } 00613 /* param_as_string does the conversion for display purposes only */ 00614 /* do NOT use as_string for calculations or set_fcn */ 00615 importstring = qof_util_param_to_string (rule->importEnt, eachParam); 00616 do_test ((importstring != NULL), 00617 "loop:#16 import param_as_string is null"); 00618 if (!skip_target) 00619 { 00620 targetstring = qof_util_param_to_string (rule->targetEnt, eachParam); 00621 do_test ((targetstring != NULL), 00622 "loop:#17 target param_as_string is null"); 00623 } 00624 testing = g_slist_next (testing); 00625 } // end param loop 00626 /* set each rule dependent on the user involvement response above. */ 00627 /* test routine just sets all MERGE_REPORT to MERGE_UPDATE */ 00628 mergeData = qof_book_merge_update_result (mergeData, MERGE_UPDATE); 00629 do_test ((rule->mergeResult != MERGE_REPORT), 00630 "update result fail"); 00631 } 00632 00633 int 00634 main (void) 00635 { 00636 qof_init (); 00637 myobjRegister (); 00638 test_merge (); 00639 print_test_results (); 00640 qof_close (); 00641 return get_rv(); 00642 }