Don't test numeric parsing for numbers that overflow, we'd fail.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12306 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-01-09 03:33:46 +00:00
parent 36dceb4d18
commit 6400638073
2 changed files with 17 additions and 11 deletions

View File

@ -1488,7 +1488,8 @@ xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info)
/* hack alert -- this is not thread safe ... */ /* hack alert -- this is not thread safe ... */
static char buf[1024]; static char buf[1024];
xaccSPrintAmount (buf, val, info); if (!xaccSPrintAmount (buf, val, info))
buf[0] = '\0';
/* its OK to return buf, since we declared it static */ /* its OK to return buf, since we declared it static */
return buf; return buf;

View File

@ -12,9 +12,12 @@ test_num_print_info (gnc_numeric n, GNCPrintAmountInfo print_info, int line)
{ {
gnc_numeric n_parsed = gnc_numeric_zero(); gnc_numeric n_parsed = gnc_numeric_zero();
const char *s; const char *s;
gboolean ok; gboolean ok, print_ok;
s = xaccPrintAmount (n, print_info); s = xaccPrintAmount (n, print_info);
print_ok = (s && s[0] != '\0');
if (!print_ok)
return;
ok = xaccParseAmount (s, print_info.monetary, &n_parsed, NULL); ok = xaccParseAmount (s, print_info.monetary, &n_parsed, NULL);
@ -53,7 +56,8 @@ test_num (gnc_numeric n)
n1 = gnc_numeric_convert (n, fraction, GNC_RND_ROUND); n1 = gnc_numeric_convert (n, fraction, GNC_RND_ROUND);
if (gnc_numeric_check(n1)) { if (gnc_numeric_check(n1)) {
do_test_args(0, "BAD NUMERIC CONVERSION", __FILE__, __LINE__, do_test_args((gnc_numeric_check(n1) == GNC_ERROR_OVERFLOW),
"BAD NUMERIC CONVERSION", __FILE__, __LINE__,
"num: %s, fraction: %d", gnc_numeric_to_string(n), fraction); "num: %s, fraction: %d", gnc_numeric_to_string(n), fraction);
continue; continue;
} }
@ -78,14 +82,15 @@ test_num (gnc_numeric n)
} }
} }
#define IS_VALID_NUM(n,m) \ #define IS_VALID_NUM(n,m) \
if (gnc_numeric_check(n)) { \ if (gnc_numeric_check(n)) { \
do_test_args(0, "BAD NUMERIC", __FILE__, __LINE__, \ do_test_args(gnc_numeric_check(n) == GNC_ERROR_OVERFLOW, \
"num: %s (from %s)", \ "BAD NUMERIC", __FILE__, __LINE__, \
gnc_numeric_to_string(n), \ "num: %s (from %s)", \
gnc_numeric_to_string(m)); \ gnc_numeric_to_string(n), \
continue; \ gnc_numeric_to_string(m)); \
} else { m = n; } continue; \
} else { m = n; }
static void static void
run_tests (void) run_tests (void)