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 ... */
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 */
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();
const char *s;
gboolean ok;
gboolean ok, print_ok;
s = xaccPrintAmount (n, print_info);
print_ok = (s && s[0] != '\0');
if (!print_ok)
return;
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);
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);
continue;
}
@ -80,7 +84,8 @@ test_num (gnc_numeric n)
#define IS_VALID_NUM(n,m) \
if (gnc_numeric_check(n)) { \
do_test_args(0, "BAD NUMERIC", __FILE__, __LINE__, \
do_test_args(gnc_numeric_check(n) == GNC_ERROR_OVERFLOW, \
"BAD NUMERIC", __FILE__, __LINE__, \
"num: %s (from %s)", \
gnc_numeric_to_string(n), \
gnc_numeric_to_string(m)); \