gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Sep 21 19:44:40 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/40bcd1e3 (commit)
via https://github.com/Gnucash/gnucash/commit/4fe12f54 (commit)
via https://github.com/Gnucash/gnucash/commit/87533fe4 (commit)
from https://github.com/Gnucash/gnucash/commit/6d2ef903 (commit)
commit 40bcd1e37779b2c6bcc1fc1cdb00aef8f28adb34
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 14:33:02 2018 -0700
Bump the max_denom_mult to match the new GNC_COMMODITY_MAX_FRACTION.
diff --git a/libgnucash/engine/test-core/test-engine-stuff.cpp b/libgnucash/engine/test-core/test-engine-stuff.cpp
index 05f3203..ca657d2 100644
--- a/libgnucash/engine/test-core/test-engine-stuff.cpp
+++ b/libgnucash/engine/test-core/test-engine-stuff.cpp
@@ -87,7 +87,7 @@ static gint total_num_accounts = 0;
static gint max_scu = 100; //6000;
static gint min_scu = 100; //1;
static const int64_t num_limit = INT64_MAX; //1E19+
-static const int64_t max_denom_mult = 1000000LL; //1E6
+static const int64_t max_denom_mult = 1000000000LL; //1E9
/* The inverse fraction of split/transaction data that should
@@ -402,7 +402,7 @@ get_random_gnc_numeric(int64_t deno)
{
gint64 norm = RAND_IN_RANGE (11ULL);
- /* multiple of 10, between 1 and 1 million */
+ /* multiple of 10, between 1 and 100 billion */
deno = 1;
while (norm)
{
commit 4fe12f54225938c9479f17c4f80ebe64762f1b19
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 14:32:03 2018 -0700
Some more magic number replacements.
diff --git a/libgnucash/engine/test/utest-Split.cpp b/libgnucash/engine/test/utest-Split.cpp
index bdc8f3e..2f04308 100644
--- a/libgnucash/engine/test/utest-Split.cpp
+++ b/libgnucash/engine/test/utest-Split.cpp
@@ -759,10 +759,10 @@ test_get_currency_denom (Fixture *fixture, gconstpointer pData)
const gint denom = gnc_commodity_get_fraction (fixture->curr);
g_assert_cmpint (fixture->func->get_currency_denom (NULL), ==, 0);
fixture->split->parent = NULL;
- g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000);
+ g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, GNC_COMMODITY_MAX_FRACTION);
fixture->split->parent = txn;
txn->common_currency = NULL;
- g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000);
+ g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, GNC_COMMODITY_MAX_FRACTION);
txn->common_currency = fixture->curr;
g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, denom);
}
@@ -777,7 +777,7 @@ test_get_commodity_denom (Fixture *fixture, gconstpointer pData)
const gint denom = gnc_commodity_get_fraction (fixture->comm);
g_assert_cmpint (fixture->func->get_commodity_denom (NULL), ==, 0);
fixture->split->acc = NULL;
- g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, 1000000);
+ g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, GNC_COMMODITY_MAX_FRACTION);
fixture->split->acc = acc;
g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, denom);
}
commit 87533fe4bcb659ebacec6f50ed68070175d4aeda
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Sep 21 14:28:49 2018 -0700
Catch std::underflow_error as well as std::overflow_error.
Any operation that can overflow will throw an underflow if it's a
negative number. The C interface needs to catch both to prevent
unhandled exception crashes,
diff --git a/libgnucash/engine/gnc-numeric.cpp b/libgnucash/engine/gnc-numeric.cpp
index ee38dbb..a2e6c2a 100644
--- a/libgnucash/engine/gnc-numeric.cpp
+++ b/libgnucash/engine/gnc-numeric.cpp
@@ -391,6 +391,13 @@ GncNumeric::to_decimal(unsigned int max_places) const
<< " overflows when attempting to convert it to decimal.\n";
throw std::range_error(msg.str());
}
+ catch (const std::underflow_error& err)
+ {
+ std::ostringstream msg;
+ msg << "GncNumeric " << *this
+ << " underflows when attempting to convert it to decimal.\n";
+ throw std::range_error(msg.str());
+ }
}
void
@@ -998,6 +1005,10 @@ gnc_numeric_convert(gnc_numeric in, int64_t denom, int how)
{
return gnc_numeric_error(GNC_ERROR_OVERFLOW);
}
+ catch (const std::underflow_error& err)
+ {
+ return gnc_numeric_error(GNC_ERROR_OVERFLOW);
+ }
}
Summary of changes:
libgnucash/engine/gnc-numeric.cpp | 11 +++++++++++
libgnucash/engine/test-core/test-engine-stuff.cpp | 4 ++--
libgnucash/engine/test/utest-Split.cpp | 6 +++---
3 files changed, 16 insertions(+), 5 deletions(-)
More information about the gnucash-changes
mailing list