r21700 - gnucash/trunk/src/app-utils - [Testing] Stifle the spew in app-utils checks.
John Ralls
jralls at code.gnucash.org
Fri Dec 9 18:49:41 EST 2011
Author: jralls
Date: 2011-12-09 18:49:41 -0500 (Fri, 09 Dec 2011)
New Revision: 21700
Trac: http://svn.gnucash.org/trac/changeset/21700
Modified:
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/app-utils/test/test-exp-parser.c
gnucash/trunk/src/app-utils/test/test-print-parse-amount.c
gnucash/trunk/src/app-utils/test/test-scm-query-string.c
Log:
[Testing] Stifle the spew in app-utils checks.
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-12-09 23:11:36 UTC (rev 21699)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2011-12-09 23:49:41 UTC (rev 21700)
@@ -1174,6 +1174,7 @@
/* rounding? -- can only ROUND if force_fit is also true */
if (value_is_decimal && info->round && info->force_fit)
{
+ gnc_numeric oldval = val;
rounding.num = 5; /* Limit the denom to 10^13 ~= 2^44, leaving max at ~524288 */
rounding.denom = pow(10, max_dp + 1);
val = gnc_numeric_add(val, rounding, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
Modified: gnucash/trunk/src/app-utils/test/test-exp-parser.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-exp-parser.c 2011-12-09 23:11:36 UTC (rev 21699)
+++ gnucash/trunk/src/app-utils/test/test-exp-parser.c 2011-12-09 23:49:41 UTC (rev 21700)
@@ -63,10 +63,16 @@
gboolean succeeded;
gnc_numeric result;
char *error_loc;
+ gchar *msg = "[func_op()] function eval error: [[func_op(]\n";
+ guint loglevel = G_LOG_LEVEL_CRITICAL, hdlr;
+ TestErrorStruct check = { loglevel, "gnc.gui", msg };
result = gnc_numeric_error( -1 );
- printf("Running test \"%s\" [%s] = ", node->test_name, node->exp);
+ hdlr = g_log_set_handler ("gnc.gui", loglevel,
+ (GLogFunc)test_checked_handler, &check);
+ g_test_message ("Running test \"%s\" [%s] = ", node->test_name, node->exp);
succeeded = gnc_exp_parser_parse (node->exp, &result, &error_loc);
+ g_log_remove_handler ("gnc.gui", hdlr);
{
int pass;
pass = (succeeded == node->should_succeed);
@@ -74,9 +80,9 @@
{
pass &= gnc_numeric_equal( result, node->expected_result );
}
- printf( "%0.4f [%s]\n",
- gnc_numeric_to_double( result ),
- (pass ? "PASS" : "FAIL" ) );
+ g_test_message ( "%0.4f [%s]\n",
+ gnc_numeric_to_double( result ),
+ (pass ? "PASS" : "FAIL" ) );
}
if (succeeded != node->should_succeed)
Modified: gnucash/trunk/src/app-utils/test/test-print-parse-amount.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-print-parse-amount.c 2011-12-09 23:11:36 UTC (rev 21699)
+++ gnucash/trunk/src/app-utils/test/test-print-parse-amount.c 2011-12-09 23:49:41 UTC (rev 21700)
@@ -1,13 +1,13 @@
#include "config.h"
#include <glib.h>
#include <stdlib.h>
+#include <glib/gprintf.h>
#include "gnc-ui-util.h"
#include "gnc-numeric.h"
#include "test-engine-stuff.h"
#include "test-stuff.h"
-
static void
test_num_print_info (gnc_numeric n, GNCPrintAmountInfo print_info, int line)
{
@@ -15,22 +15,32 @@
const char *s;
gboolean ok, print_ok;
+ gchar *msg = "[PrintAmountInternal()] Bad numeric from rounding: GNC_ERROR_OVERFLOW.";
+ gchar *log_domain = "gnc.gui";
+ guint loglevel = G_LOG_LEVEL_WARNING, hdlr;
+ TestErrorStruct check = { loglevel, log_domain, msg };
+
+/* Throws overflows during rounding step in xaccPrintAmount when the "fraction" is high. See bug 665707. */
+ hdlr = g_log_set_handler (log_domain, loglevel,
+ (GLogFunc)test_checked_handler, &check);
s = xaccPrintAmount (n, print_info);
- print_ok = (s && s[0] != '\0');
+ print_ok = (s && s[0] != '\0');
if (!print_ok)
return;
ok = xaccParseAmount (s, print_info.monetary, &n_parsed, NULL);
+ g_log_remove_handler (log_domain, hdlr);
+
do_test_args (ok, "parsing failure", __FILE__, __LINE__,
"num: %s, string %s (line %d)", gnc_numeric_to_string (n), s, line);
ok = gnc_numeric_equal (n, n_parsed);
-
do_test_args (ok, "not equal", __FILE__, __LINE__,
"start: %s, string %s, finish: %s (line %d)",
gnc_numeric_to_string (n), s,
gnc_numeric_to_string (n_parsed), line);
+
}
static void
Modified: gnucash/trunk/src/app-utils/test/test-scm-query-string.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-scm-query-string.c 2011-12-09 23:11:36 UTC (rev 21699)
+++ gnucash/trunk/src/app-utils/test/test-scm-query-string.c 2011-12-09 23:49:41 UTC (rev 21700)
@@ -79,7 +79,6 @@
q = get_random_query ();
test_query (q, val2str);
qof_query_destroy (q);
- printf("%d ", i);
fflush(stdout);
}
@@ -87,16 +86,15 @@
q = get_random_query ();
test_query (q, val2str);
qof_query_destroy (q);
- printf("%d ", i);
fflush(stdout);
}
- printf("\n");
}
static void
main_helper (void *closure, int argc, char **argv)
{
+ gnc_module_system_init ();
gnc_module_load("gnucash/engine", 0);
gnc_module_load("gnucash/app-utils", 0);
More information about the gnucash-changes
mailing list