diff --git a/ChangeLog b/ChangeLog index 301833518b..0d00094147 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2001-10-10 Dave Peticolas + + * src/engine/test-core/test-engine-stuff.c + (get_random_kvp_frame_depth): use set kvp max elements number + + * src/engine/Account.c (xaccAccountEqual): add warning strings + + * src/engine/Group.c (xaccGroupEqual): add warning strings + + * src/engine/gnc-book.c (gnc_book_equal): add warning strings + + * src/engine/kvp_frame.c: treat empty frames as NULL + + * src/backend/postgres/test/run-tests.sh: enable test + + * src/backend/postgres/test/test-db.c (main): enable test + + * src/backend/file/test/test-kvp-frames.c (test_kvp_xml_stuff): + print more debugging output + + * src/backend/file/sixtp-dom-generators.c (add_kvp_value_node): + fix bug generating kvp string values (they weren't being escaped) + 2001-10-09 Robert Graham Merkel * src/engine/Transaction.{ch} (xaccTransGetVoidTime): new function. @@ -16,8 +39,8 @@ * src/engine/test/test-transaction-voiding.c: new file. - * src/engine/Transaction.c: debugging stuff for transaction voiding (will be removed - later). + * src/engine/Transaction.c: debugging stuff for transaction + voiding (will be removed later). 2001-10-03 Christian Stimming @@ -34,8 +57,8 @@ * configure.in: changes for automake 1.5 compatibility - * src/engine/transaction.c: store values as well as amounts in voided splits' - kvp frames + * src/engine/transaction.c: store values as well as amounts in + voided splits' kvp frames * src/engine/gw-engine-spec.scm: wrap voiding functions @@ -43,16 +66,20 @@ convenience functions for adding voiding checks to queries and checking the voiding status of splits. - * src/report/standard-reports/*: fixed up queries to exclude voids as appropriate. + * src/report/standard-reports/*: fixed up queries to exclude voids + as appropriate. 2001-10-01 Robert Graham Merkel - * src/engine/Transaction.{ch} (xaccTransVoid), (xaccTransGetVoidStatus), - (xaccTransGetVoidReason), (xaccSplitVoidFormerAmount): new functions. + * src/engine/Transaction.{ch} (xaccTransVoid), + (xaccTransGetVoidStatus), (xaccTransGetVoidReason), + (xaccSplitVoidFormerAmount): new functions. - * src/engine/kvp_doc.txt: add new entries related to transaction voiding. + * src/engine/kvp_doc.txt: add new entries related to transaction + voiding. - * src/engine/Query.{ch}: add support for filtering queries on voided state. + * src/engine/Query.{ch}: add support for filtering queries on + voided state. 2001-09-30 Josh Sled @@ -74,13 +101,13 @@ 2001-09-28 Robert Graham Merkel - * src/app-utils/date-utilities.scm ((gnc:deltasym-to-delta)): new function - to convert datedelta symbols to the actual deltas. + * src/app-utils/date-utilities.scm ((gnc:deltasym-to-delta)): new + function to convert datedelta symbols to the actual deltas. * src/app-utils/app-utils.scm: export gnc:deltasym-to-delta - * src/report/standard-reports/net-barchart.scm (etc.): replace eval usage - with gnc:deltasym-to-delta + * src/report/standard-reports/net-barchart.scm (etc.): replace + eval usage with gnc:deltasym-to-delta 2001-09-21 Robert Graham Merkel diff --git a/src/backend/file/sixtp-dom-generators.c b/src/backend/file/sixtp-dom-generators.c index f4bf38cc4f..9f549360af 100644 --- a/src/backend/file/sixtp-dom-generators.c +++ b/src/backend/file/sixtp-dom-generators.c @@ -246,8 +246,14 @@ add_kvp_value_node(xmlNodePtr node, gchar *tag, kvp_value* val) { xmlNodePtr val_node; gchar *tmp_str1; + kvp_value_t kvp_type; - val_node = xmlNewTextChild(node, NULL, tag, NULL); + kvp_type = kvp_value_get_type(val); + + if (kvp_type == KVP_TYPE_STRING) + val_node = xmlNewTextChild(node, NULL, tag, kvp_value_get_string(val)); + else + val_node = xmlNewTextChild(node, NULL, tag, NULL); switch(kvp_value_get_type(val)) { @@ -267,7 +273,6 @@ add_kvp_value_node(xmlNodePtr node, gchar *tag, kvp_value* val) break; case KVP_TYPE_STRING: xmlSetProp(val_node, "type", "string"); - xmlNodeSetContent(val_node, kvp_value_get_string(val)); break; case KVP_TYPE_GUID: add_text_to_node(val_node,"guid", diff --git a/src/backend/file/test/test-kvp-frames.c b/src/backend/file/test/test-kvp-frames.c index 71f8d8a6cc..b7880c2d42 100644 --- a/src/backend/file/test/test-kvp-frames.c +++ b/src/backend/file/test/test-kvp-frames.c @@ -189,11 +189,14 @@ test_kvp_xml_stuff(void) { gchar *tmp; failure("xml stuff"); - printf(" with xml:\n"); + tmp = kvp_frame_to_string(test_frame1); + printf(" with kvp_frame 1:\n%s\n", tmp); + g_free(tmp); + printf(" and xml:\n"); xmlElemDump(stdout, NULL, test_node); printf("\n"); tmp = kvp_frame_to_string(test_frame2); - printf(" and kvp_frame:\n%s\n", tmp); + printf(" and kvp_frame 2:\n%s\n", tmp); g_free(tmp); } kvp_frame_delete(test_frame2); diff --git a/src/backend/postgres/test/run-tests.sh b/src/backend/postgres/test/run-tests.sh index 4a8c6f2c4e..982ec5d955 100755 --- a/src/backend/postgres/test/run-tests.sh +++ b/src/backend/postgres/test/run-tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -exit 0 +#exit 0 EXIT_VALUE=0 @@ -12,6 +12,6 @@ EXIT_VALUE=0 if test $EXIT_VALUE != 0; then exit $EXIT_VALUE; fi -#./db-control.sh destroy +./db-control.sh destroy exit $EXIT_VALUE diff --git a/src/backend/postgres/test/test-db.c b/src/backend/postgres/test/test-db.c index e1d722c5f9..2c81cad390 100644 --- a/src/backend/postgres/test/test-db.c +++ b/src/backend/postgres/test/test-db.c @@ -98,7 +98,7 @@ guile_main (int argc, char **argv) int main (int argc, char ** argv) { - getchar (); + /* getchar (); */ gh_enter (argc, argv, guile_main); diff --git a/src/engine/Account.c b/src/engine/Account.c index 034d767db2..7bd55a6edd 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -392,23 +392,69 @@ xaccAccountGetVersion (Account *acc) \********************************************************************/ gboolean -xaccAccountEqual(Account *aa, Account *ab, gboolean check_guids) { +xaccAccountEqual(Account *aa, Account *ab, gboolean check_guids) +{ if(!aa && !ab) return TRUE; - if(!aa) return FALSE; - if(!ab) return FALSE; - if(aa->type != ab->type) return FALSE; + if(!aa || !ab) + { + PWARN ("one is NULL"); + return FALSE; + } + + if (aa->type != ab->type) + { + PWARN ("types differ"); + return FALSE; + } + + if (safe_strcmp(aa->accountName, ab->accountName) != 0) + { + PWARN ("names differ: %s vs %s", aa->accountName, ab->accountName); + return FALSE; + } - if(safe_strcmp(aa->accountName, ab->accountName) != 0) return FALSE; - if(safe_strcmp(aa->accountCode, ab->accountCode) != 0) return FALSE; - if(safe_strcmp(aa->description, ab->description) != 0) return FALSE; - if(!gnc_commodity_equiv(aa->commodity, ab->commodity)) return FALSE; + if (safe_strcmp(aa->accountCode, ab->accountCode) != 0) + { + PWARN ("codes differ: %s vs %s", aa->accountCode, ab->accountCode); + return FALSE; + } + + if (safe_strcmp(aa->description, ab->description) != 0) + { + PWARN ("descriptions differ: %s vs %s", aa->description, ab->description); + return FALSE; + } + + if (!gnc_commodity_equiv(aa->commodity, ab->commodity)) + { + PWARN ("commodities differ"); + return FALSE; + } if(check_guids) { - if(!guid_equal(&aa->guid, &ab->guid)) return FALSE; + if(!guid_equal(&aa->guid, &ab->guid)) + { + PWARN ("GUIDs differ"); + return FALSE; + } } - if(kvp_frame_compare(aa->kvp_data, ab->kvp_data) != 0) return FALSE; + if (kvp_frame_compare(aa->kvp_data, ab->kvp_data) != 0) + { + char *frame_a; + char *frame_b; + + frame_a = kvp_frame_to_string (aa->kvp_data); + frame_b = kvp_frame_to_string (ab->kvp_data); + + PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b); + + g_free (frame_a); + g_free (frame_b); + + return FALSE; + } /* no parent; always compare downwards. */ @@ -416,22 +462,43 @@ xaccAccountEqual(Account *aa, Account *ab, gboolean check_guids) { GList *la = aa->splits; GList *lb = ab->splits; - if( la && !lb) return FALSE; - if(!la && lb) return FALSE; - if(la && lb) { + if ((la && !lb) || (!la && lb)) + { + PWARN ("only one has splits"); + return FALSE; + } + + if(la && lb) + { /* presume that the splits are in the same order */ - while(la && lb) { + while (la && lb) + { Split *sa = (Split *) la->data; Split *sb = (Split *) lb->data; - if(!xaccSplitEqual(sa, sb, check_guids, FALSE)) return(FALSE); + + if (!xaccSplitEqual(sa, sb, check_guids, FALSE)) + { + PWARN ("splits differ"); + return(FALSE); + } + la = la->next; lb = lb->next; } - if((la != NULL) || (lb != NULL)) return(FALSE); + + if ((la != NULL) || (lb != NULL)) + { + PWARN ("number of splits differs"); + return(FALSE); + } } } - if(!xaccGroupEqual(aa->children, ab->children, check_guids)) return FALSE; + if (!xaccGroupEqual(aa->children, ab->children, check_guids)) + { + PWARN ("children differ"); + return FALSE; + } return(TRUE); } diff --git a/src/engine/Group.c b/src/engine/Group.c index afb6bc5924..c2e02987ad 100644 --- a/src/engine/Group.c +++ b/src/engine/Group.c @@ -103,28 +103,42 @@ xaccGroupEqual(AccountGroup *ga, GList *nb; if (!ga && !gb) return(TRUE); - if (!ga) return(FALSE); - if (!gb) return(FALSE); + + if (!ga || !gb) + { + PWARN ("one is NULL"); + return(FALSE); + } na = ga->accounts; nb = gb->accounts; - if (!na && nb) return(FALSE); - if (na && !nb) return(FALSE); + if ((!na && nb) || (na && !nb)) + { + PWARN ("only one has accounts"); + return(FALSE); + } while (na && nb) { Account *aa = na->data; Account *ab = nb->data; - if (!xaccAccountEqual(aa, ab, check_guids)) return(FALSE); + if (!xaccAccountEqual(aa, ab, check_guids)) + { + PWARN ("accounts differ"); + return(FALSE); + } na = na->next; nb = nb->next; } - if (na) return(FALSE); - if (nb) return(FALSE); + if (na || nb) + { + PWARN ("different numbers of accounts"); + return(FALSE); + } return(TRUE); } diff --git a/src/engine/gnc-book.c b/src/engine/gnc-book.c index 5dc60cc864..3226fe08a4 100644 --- a/src/engine/gnc-book.c +++ b/src/engine/gnc-book.c @@ -314,11 +314,17 @@ gnc_book_equal (GNCBook *book_1, GNCBook *book_2) if (!xaccGroupEqual (gnc_book_get_group (book_1), gnc_book_get_group (book_2), TRUE)) + { + PWARN ("groups differ"); return FALSE; + } if (!gnc_pricedb_equal (gnc_book_get_pricedb (book_1), gnc_book_get_pricedb (book_2))) + { + PWARN ("price dbs differ"); return FALSE; + } /* FIXME: do scheduled transactions and template group */ diff --git a/src/engine/kvp_frame.c b/src/engine/kvp_frame.c index 14454bac61..dbb8e373b0 100644 --- a/src/engine/kvp_frame.c +++ b/src/engine/kvp_frame.c @@ -945,7 +945,14 @@ kvp_frame_compare(const kvp_frame *fa, const kvp_frame *fb) { kvp_frame_for_each_slot((kvp_frame *) fa, kvp_frame_compare_helper, &status); - return(status.compare); + if (status.compare != 0) + return status.compare; + + status.other_frame = (kvp_frame *) fa; + + kvp_frame_for_each_slot((kvp_frame *) fb, kvp_frame_compare_helper, &status); + + return(-status.compare); } gchar* @@ -1087,7 +1094,8 @@ kvp_frame_to_string(const kvp_frame *frame) tmp1 = g_strdup_printf("{\n"); - g_hash_table_foreach(frame->hash, kvp_frame_to_string_helper, &tmp1); + if (frame->hash) + g_hash_table_foreach(frame->hash, kvp_frame_to_string_helper, &tmp1); { gchar *tmp2; diff --git a/src/engine/test-core/test-engine-stuff.c b/src/engine/test-core/test-engine-stuff.c index b54c47c2d5..bd7f88a2a7 100644 --- a/src/engine/test-core/test-engine-stuff.c +++ b/src/engine/test-core/test-engine-stuff.c @@ -256,7 +256,7 @@ get_random_kvp_frame_depth (gint depth) ret = kvp_frame_new(); - vals_to_add = get_random_int_in_range(1,10); + vals_to_add = get_random_int_in_range(1,kvp_frame_max_elements); for(;vals_to_add > 0; vals_to_add--) { @@ -270,6 +270,11 @@ get_random_kvp_frame_depth (gint depth) { return NULL; } + if (!val) + { + vals_to_add++; + continue; + } kvp_frame_set_slot_nc(ret, key, val); diff --git a/src/test-core/test-stuff.c b/src/test-core/test-stuff.c index 10ca7a0561..5fc53b2223 100644 --- a/src/test-core/test-stuff.c +++ b/src/test-core/test-stuff.c @@ -207,9 +207,11 @@ static char random_chars[] = "abcdefghijklmnopqrstuvwxyz" "1234567890" " " -/* ",.'\"`~!@#$%^*(){}[]/=?+-_\\|" */ -/* "<>&" */ -/* "\n\t" */ +#if 0 +",.'\"`~!@#$%^*(){}[]/=?+-_\\|" +"<>&" +"\n\t" +#endif ""; gchar