r23064 - gnucash/trunk/src/engine - Really Redo r23043 Don't print "warning" output in comparison functions.
John Ralls
jralls at code.gnucash.org
Tue Jun 25 13:04:47 EDT 2013
Author: jralls
Date: 2013-06-25 13:04:47 -0400 (Tue, 25 Jun 2013)
New Revision: 23064
Trac: http://svn.gnucash.org/trac/changeset/23064
Modified:
gnucash/trunk/src/engine/Split.c
gnucash/trunk/src/engine/Transaction.c
gnucash/trunk/src/engine/test/utest-Split.c
Log:
Really Redo r23043 Don't print "warning" output in comparison functions.
Without pulling in the extra junk.
Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c 2013-06-25 17:04:30 UTC (rev 23063)
+++ gnucash/trunk/src/engine/Split.c 2013-06-25 17:04:47 UTC (rev 23064)
@@ -557,7 +557,7 @@
str_a = gnc_numeric_to_string (a);
str_b = gnc_numeric_to_string (b);
- PWARN ("%sbalances differ: %s vs %s", tag, str_a, str_b);
+ PINFO ("%sbalances differ: %s vs %s", tag, str_a, str_b);
g_free (str_a);
g_free (str_b);
@@ -580,7 +580,7 @@
if (!sa || !sb)
{
- PWARN ("one is NULL");
+ PINFO ("one is NULL");
return FALSE;
}
@@ -592,7 +592,7 @@
{
if (qof_instance_guid_compare(sa, sb) != 0)
{
- PWARN ("GUIDs differ");
+ PINFO ("GUIDs differ");
return FALSE;
}
}
@@ -600,14 +600,14 @@
/* If the same book, since these strings are cached we can just use pointer equality */
if ((same_book && sa->memo != sb->memo) || (!same_book && g_strcmp0(sa->memo, sb->memo) != 0))
{
- PWARN ("memos differ: (%p)%s vs (%p)%s",
+ PINFO ("memos differ: (%p)%s vs (%p)%s",
sa->memo, sa->memo, sb->memo, sb->memo);
return FALSE;
}
if ((same_book && sa->action != sb->action) || (!same_book && g_strcmp0(sa->action, sb->action) != 0))
{
- PWARN ("actions differ: %s vs %s", sa->action, sb->action);
+ PINFO ("actions differ: %s vs %s", sa->action, sb->action);
return FALSE;
}
@@ -619,7 +619,7 @@
frame_a = kvp_frame_to_string (sa->inst.kvp_data);
frame_b = kvp_frame_to_string (sb->inst.kvp_data);
- PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
+ PINFO ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
g_free (frame_a);
g_free (frame_b);
@@ -629,13 +629,13 @@
if (sa->reconciled != sb->reconciled)
{
- PWARN ("reconcile flags differ: %c vs %c", sa->reconciled, sb->reconciled);
+ PINFO ("reconcile flags differ: %c vs %c", sa->reconciled, sb->reconciled);
return FALSE;
}
if (timespec_cmp(&(sa->date_reconciled), &(sb->date_reconciled)))
{
- PWARN ("reconciled date differs");
+ PINFO ("reconciled date differs");
return FALSE;
}
@@ -647,7 +647,7 @@
str_a = gnc_numeric_to_string (xaccSplitGetAmount (sa));
str_b = gnc_numeric_to_string (xaccSplitGetAmount (sb));
- PWARN ("amounts differ: %s vs %s", str_a, str_b);
+ PINFO ("amounts differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
@@ -663,7 +663,7 @@
str_a = gnc_numeric_to_string (xaccSplitGetValue (sa));
str_b = gnc_numeric_to_string (xaccSplitGetValue (sb));
- PWARN ("values differ: %s vs %s", str_a, str_b);
+ PINFO ("values differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
@@ -686,7 +686,7 @@
if (!xaccTransEqual(sa->parent, sb->parent, check_guids, check_txn_splits,
check_balances, FALSE))
{
- PWARN ("transactions differ");
+ PINFO ("transactions differ");
return FALSE;
}
Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c 2013-06-25 17:04:30 UTC (rev 23063)
+++ gnucash/trunk/src/engine/Transaction.c 2013-06-25 17:04:47 UTC (rev 23064)
@@ -780,7 +780,7 @@
if (!ta || !tb)
{
- PWARN ("one is NULL");
+ PINFO ("one is NULL");
return FALSE;
}
@@ -799,7 +799,7 @@
if (!gnc_commodity_equal(ta->common_currency, tb->common_currency))
{
- PWARN ("commodities differ %s vs %s",
+ PINFO ("commodities differ %s vs %s",
gnc_commodity_get_unique_name (ta->common_currency),
gnc_commodity_get_unique_name (tb->common_currency));
return FALSE;
@@ -812,7 +812,7 @@
(void)gnc_timespec_to_iso8601_buff(ta->date_entered, buf1);
(void)gnc_timespec_to_iso8601_buff(tb->date_entered, buf2);
- PWARN ("date entered differs: '%s' vs '%s'", buf1, buf2);
+ PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
return FALSE;
}
@@ -823,7 +823,7 @@
(void)gnc_timespec_to_iso8601_buff(ta->date_posted, buf1);
(void)gnc_timespec_to_iso8601_buff(tb->date_posted, buf2);
- PWARN ("date posted differs: '%s' vs '%s'", buf1, buf2);
+ PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
return FALSE;
}
@@ -832,14 +832,14 @@
*/
if ((same_book && ta->num != tb->num) || (!same_book && g_strcmp0(ta->num, tb->num) != 0))
{
- PWARN ("num differs: %s vs %s", ta->num, tb->num);
+ PINFO ("num differs: %s vs %s", ta->num, tb->num);
return FALSE;
}
if ((same_book && ta->description != tb->description)
|| (!same_book && g_strcmp0(ta->description, tb->description)))
{
- PWARN ("descriptions differ: %s vs %s", ta->description, tb->description);
+ PINFO ("descriptions differ: %s vs %s", ta->description, tb->description);
return FALSE;
}
@@ -851,7 +851,7 @@
frame_a = kvp_frame_to_string (ta->inst.kvp_data);
frame_b = kvp_frame_to_string (tb->inst.kvp_data);
- PWARN ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
+ PINFO ("kvp frames differ:\n%s\n\nvs\n\n%s", frame_a, frame_b);
g_free (frame_a);
g_free (frame_b);
@@ -863,7 +863,7 @@
{
if ((!ta->splits && tb->splits) || (!tb->splits && ta->splits))
{
- PWARN ("only one has splits");
+ PINFO ("only one has splits");
return FALSE;
}
@@ -885,7 +885,7 @@
if (!node_b)
{
- PWARN ("first has split %s and second does not",
+ PINFO ("first has split %s and second does not",
guid_to_string (xaccSplitGetGUID (split_a)));
return FALSE;
}
@@ -901,14 +901,14 @@
guid_to_string_buff (xaccSplitGetGUID (split_a), str_a);
guid_to_string_buff (xaccSplitGetGUID (split_b), str_b);
- PWARN ("splits %s and %s differ", str_a, str_b);
+ PINFO ("splits %s and %s differ", str_a, str_b);
return FALSE;
}
}
if (g_list_length (ta->splits) != g_list_length (tb->splits))
{
- PWARN ("different number of splits");
+ PINFO ("different number of splits");
return FALSE;
}
}
Modified: gnucash/trunk/src/engine/test/utest-Split.c
===================================================================
--- gnucash/trunk/src/engine/test/utest-Split.c 2013-06-25 17:04:30 UTC (rev 23063)
+++ gnucash/trunk/src/engine/test/utest-Split.c 2013-06-25 17:04:47 UTC (rev 23064)
@@ -374,27 +374,20 @@
static void
test_xaccSplitEqualCheckBal (Fixture *fixture, gconstpointer pData)
{
- gchar *msg = "[xaccSplitEqualCheckBal()] test balances differ: 123/100 vs 456/100";
- guint loglevel = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL, hdlr;
+ gchar *msg = "[xaccSplitEqualCheckBal] test balances differ: 123/100 vs 456/100";
+ guint loglevel = G_LOG_LEVEL_INFO, hdlr;
TestErrorStruct check = { loglevel, "gnc.engine", msg, 0 };
- GLogFunc oldlogger;
gnc_numeric foo = gnc_numeric_create (123, 100);
gnc_numeric bar = gnc_numeric_create (456, 100);
hdlr = g_log_set_handler ("gnc.engine", loglevel,
(GLogFunc)test_checked_handler, &check);
- test_add_error (&check);
- oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
- g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, NULL);
-
g_assert_cmpint (fixture->func->xaccSplitEqualCheckBal ("test ", foo, foo), ==, TRUE);
g_assert_cmpint (fixture->func->xaccSplitEqualCheckBal ("test ", foo, bar), ==, FALSE);
- g_assert_cmpint (check.hits, ==, 2);
+ g_assert_cmpint (check.hits, ==, 1);
g_log_remove_handler ("gnc.engine", hdlr);
- g_log_set_default_handler (oldlogger, NULL);
- test_clear_error_list ();
}
/* xaccSplitEqual
@@ -407,41 +400,39 @@
{
Split *split1 = xaccSplitClone (fixture->split);
Split *split2 = xaccDupeSplit (fixture->split);
- gchar *msg01 = "[xaccSplitEqual()] one is NULL";
- gchar *msg02 = "[xaccSplitEqual()] GUIDs differ";
+ gchar *msg01 = "[xaccSplitEqual] one is NULL";
+ gchar *msg02 = "[xaccSplitEqual] GUIDs differ";
gchar *msg03;
- gchar *msg04 = "[xaccSplitEqual()] actions differ: foo vs bar";
- G_GNUC_UNUSED gchar *msg05 = "[xaccSplitEqual()] kvp frames: differ foo vs bar";
- G_GNUC_UNUSED gchar *msg06 = "[xaccSplitEqual()] reconcile flags differ: foo vs bar";
- G_GNUC_UNUSED gchar *msg07 = "[xaccSplitEqual()] reconciled date differs";
- G_GNUC_UNUSED gchar *msg08 = "[xaccSplitEqual()] amounts differ: foo vs bar";
- gchar *msg10 = "[xaccSplitEqual()] transactions differ";
- gchar *msg11 = "[xaccTransEqual()] one is NULL";
- gchar *msg12 = "[xaccSplitEqualCheckBal()] balances differ: 321/1000 vs 0/1";
- gchar *msg13 = "[xaccSplitEqualCheckBal()] cleared balances differ: 321/1000 vs 0/1";
- gchar *msg14 = "[xaccSplitEqualCheckBal()] reconciled balances differ: 321/1000 vs 0/1";
+ gchar *msg04 = "[xaccSplitEqual] actions differ: foo vs bar";
+ G_GNUC_UNUSED gchar *msg05 = "[xaccSplitEqual] kvp frames: differ foo vs bar";
+ G_GNUC_UNUSED gchar *msg06 = "[xaccSplitEqual] reconcile flags differ: foo vs bar";
+ G_GNUC_UNUSED gchar *msg07 = "[xaccSplitEqual] reconciled date differs";
+ G_GNUC_UNUSED gchar *msg08 = "[xaccSplitEqual] amounts differ: foo vs bar";
+ gchar *msg10 = "[xaccSplitEqual] transactions differ";
+ gchar *msg11 = "[xaccTransEqual] one is NULL";
+ gchar *msg12 = "[xaccSplitEqualCheckBal] balances differ: 321/1000 vs 0/1";
+ gchar *msg13 = "[xaccSplitEqualCheckBal] cleared balances differ: 321/1000 vs 0/1";
+ gchar *msg14 = "[xaccSplitEqualCheckBal] reconciled balances differ: 321/1000 vs 0/1";
gchar *logdomain = "gnc.engine";
- guint loglevel = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL;
+ guint loglevel = G_LOG_LEVEL_INFO;
TestErrorStruct checkA = { loglevel, logdomain, msg01, 0 };
TestErrorStruct checkB = { loglevel, logdomain, msg10, 0 };
TestErrorStruct checkC = { loglevel, logdomain, msg11, 0 };
TestErrorStruct checkD = { loglevel, logdomain, msg14, 0 };
guint hdlr;
- GLogFunc oldlogger;
- oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &checkA);
+
test_add_error (&checkA);
test_add_error (&checkB);
test_add_error (&checkC);
test_add_error (&checkD);
- g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_list_handler, &checkA);
hdlr = g_log_set_handler (logdomain, loglevel,
- (GLogFunc)test_checked_handler, &checkA);
+ (GLogFunc)test_list_handler, &checkA);
/* Note that check_splits is just passed through to xaccTransEqual, so we don't vary it here. */
/* Test that a NULL comparison fails */
g_assert (xaccSplitEqual (fixture->split, NULL, TRUE, TRUE, TRUE) == FALSE);
g_assert (xaccSplitEqual (NULL, split1, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 4);
+ g_assert_cmpint (checkA.hits, ==, 2);
g_assert_cmpint (checkB.hits, ==, 0);
g_assert_cmpint (checkC.hits, ==, 0);
g_assert_cmpint (checkD.hits, ==, 0);
@@ -449,39 +440,33 @@
/* Clone creates splits with different GUIDs: Make sure that it fails comparison */
g_assert (xaccSplitEqual (fixture->split, split1, TRUE, TRUE, TRUE) == FALSE);
/* Test that the parent comparison fails */
- g_log_remove_handler (logdomain, hdlr);
- hdlr = g_log_set_handler (logdomain, loglevel,
- (GLogFunc)test_list_handler, &checkA);
g_assert (xaccSplitEqual (fixture->split, split1, FALSE, TRUE, TRUE) == FALSE);
/* Now set split1's parent so that it passes -- we're also checking that the GUID check is disabled when we pass FALSE to check_guids */
- g_assert_cmpint (checkA.hits, ==, 6);
- g_assert_cmpint (checkB.hits, ==, 2);
- g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert_cmpint (checkA.hits, ==, 3);
+ g_assert_cmpint (checkB.hits, ==, 1);
+ g_assert_cmpint (checkC.hits, ==, 1);
g_assert_cmpint (checkD.hits, ==, 0);
split1->parent = fixture->split->parent;
- g_log_remove_handler (logdomain, hdlr);
- hdlr = g_log_set_handler (logdomain, loglevel,
- (GLogFunc)test_list_handler, &checkA);
g_assert (xaccSplitEqual (fixture->split, split1, FALSE, TRUE, TRUE) == TRUE);
/* Now set the GUIDs equal and see that the comparison passes */
g_object_set (G_OBJECT (split1),
"guid", qof_instance_get_guid (QOF_INSTANCE(fixture->split)),
NULL);
g_assert (xaccSplitEqual (fixture->split, split1, TRUE, TRUE, TRUE) == TRUE);
- g_assert_cmpint (checkA.hits, ==, 6);
- g_assert_cmpint (checkB.hits, ==, 2);
- g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert_cmpint (checkA.hits, ==, 3);
+ g_assert_cmpint (checkB.hits, ==, 1);
+ g_assert_cmpint (checkC.hits, ==, 1);
g_assert_cmpint (checkD.hits, ==, 0);
/* Change the memo and action and test that each in turn causes the comparison to fail */
split1->memo = "baz";
- msg03 = g_strdup_printf ("[xaccSplitEqual()] memos differ: (%p)%s vs (%p)%s",
+ msg03 = g_strdup_printf ("[xaccSplitEqual] memos differ: (%p)%s vs (%p)%s",
fixture->split->memo, fixture->split->memo,
split1->memo, split1->memo);
checkA.msg = msg03;
g_assert (xaccSplitEqual (fixture->split, split1, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 8);
- g_assert_cmpint (checkB.hits, ==, 2);
- g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert_cmpint (checkA.hits, ==, 4);
+ g_assert_cmpint (checkB.hits, ==, 1);
+ g_assert_cmpint (checkC.hits, ==, 1);
g_assert_cmpint (checkD.hits, ==, 0);
split1->memo = fixture->split->memo;
split1->action = "bar";
@@ -490,40 +475,41 @@
g_log_remove_handler (logdomain, hdlr);
hdlr = g_log_set_handler (logdomain, loglevel,
(GLogFunc)test_list_handler, &checkA);
- g_assert (xaccSplitEqual (fixture->split, split1, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 12);
- g_assert_cmpint (checkB.hits, ==, 2);
- g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert (xaccSplitEqual (fixture->split, split1, TRUE, TRUE, TRUE) == FALSE);
+ g_assert_cmpint (checkA.hits, ==, 6);
+ g_assert_cmpint (checkB.hits, ==, 1);
+ g_assert_cmpint (checkC.hits, ==, 1);
g_assert_cmpint (checkD.hits, ==, 0);
/* Split2 doesn't have balances copied from fixture->split, so the balance test fails */
checkB.msg = msg12;
checkC.msg = msg13;
g_assert (xaccSplitEqual (fixture->split, split2, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 12);
- g_assert_cmpint (checkB.hits, ==, 4);
- g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert_cmpint (checkA.hits, ==, 6);
+ g_assert_cmpint (checkB.hits, ==, 2);
+ g_assert_cmpint (checkC.hits, ==, 1);
g_assert_cmpint (checkD.hits, ==, 0);
split2->balance = fixture->split->balance;
g_assert (xaccSplitEqual (fixture->split, split2, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 12);
- g_assert_cmpint (checkB.hits, ==, 4);
- g_assert_cmpint (checkC.hits, ==, 4);
+ g_assert_cmpint (checkA.hits, ==, 6);
+ g_assert_cmpint (checkB.hits, ==, 2);
+ g_assert_cmpint (checkC.hits, ==, 2);
g_assert_cmpint (checkD.hits, ==, 0);
split2->cleared_balance = fixture->split->cleared_balance;
g_assert (xaccSplitEqual (fixture->split, split2, TRUE, TRUE, TRUE) == FALSE);
- g_assert_cmpint (checkA.hits, ==, 12);
- g_assert_cmpint (checkB.hits, ==, 4);
- g_assert_cmpint (checkC.hits, ==, 4);
- g_assert_cmpint (checkD.hits, ==, 2);
+ g_assert_cmpint (checkA.hits, ==, 6);
+ g_assert_cmpint (checkB.hits, ==, 2);
+ g_assert_cmpint (checkC.hits, ==, 2);
+ g_assert_cmpint (checkD.hits, ==, 1);
test_clear_error_list ();
g_assert (xaccSplitEqual (fixture->split, split2, TRUE, FALSE, TRUE) == TRUE);
g_object_unref (split1);
g_object_unref (split2);
test_clear_error_list ();
- g_log_set_default_handler (oldlogger, NULL);
+ g_log_remove_handler (logdomain, hdlr);
+
g_free (msg03);
}
/* xaccSplitGetAccount
@@ -558,6 +544,7 @@
gchar *msg2 = "[xaccSplitCommitEdit()] Account grabbed split prematurely.";
gchar *logdomain = "gnc.engine";
guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
+ guint infolevel = G_LOG_LEVEL_INFO;
guint hdlr;
TestErrorStruct checkA = { loglevel, logdomain, msg1, 0 };
TestErrorStruct checkB = { loglevel, logdomain, msg2, 0 };
@@ -599,7 +586,6 @@
g_assert_cmpint (checkA.hits, ==, 4);
g_assert_cmpint (checkB.hits, ==, 2);
- g_log_remove_handler (logdomain, hdlr);
qof_instance_mark_clean (QOF_INSTANCE (fixture->split->parent));
g_object_set (fixture->split->acc,
"sort-dirty", FALSE,
@@ -626,6 +612,7 @@
g_assert (fixture->split->orig_parent == fixture->split->parent);
+ g_log_remove_handler (logdomain, hdlr);
test_signal_free (sig1);
test_signal_free (sig2);
test_destroy (oacc);
@@ -1272,7 +1259,19 @@
Account *acc1 = xaccMallocAccount (book);
Account *acc2 = xaccMallocAccount (book);
Account *acc3 = xaccMallocAccount (book);
+ gchar *msg1 = "get_corr_account_split: assertion `sa' failed";
+ gchar *logdomain = "gnc.engine";
+ guint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
+ TestErrorStruct check = { loglevel, logdomain, msg1, 0 };
+ gnc_numeric value = { 360, 240 };
+ gnc_numeric old_val = fixture->split->value;
+ gnc_numeric old_amt = fixture->split->amount;
+ GLogFunc oldlogger = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
+ g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler,
+ &check);
+
+
xaccAccountSetCommodity (acc1, fixture->curr);
xaccAccountSetCommodity (acc2, fixture->curr);
xaccAccountSetCommodity (acc3, fixture->curr);
@@ -1302,12 +1301,13 @@
g_assert (!fixture->func->get_corr_account_split(fixture->split, &result));
g_assert (result == NULL);
+ g_assert_cmpint (check.hits, ==, 0);
- g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_null_handler,
- NULL);
g_assert (!fixture->func->get_corr_account_split(NULL, &result));
g_assert (result == NULL);
+ g_assert_cmpint (check.hits, ==, 1);
+ g_log_set_default_handler (oldlogger, NULL);
test_destroy (split1);
test_destroy (split2);
test_destroy (split3);
More information about the gnucash-changes
mailing list