From 269a7c6f3bb6f2d8d537c9df6b78ce6a24796678 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 17 Apr 2007 09:11:23 +0000 Subject: Got most of the commodity tests working, save multiplication and division. --- amount.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/amount.cc b/amount.cc index a3a7fb40..73bc6718 100644 --- a/amount.cc +++ b/amount.cc @@ -634,6 +634,13 @@ amount_t& amount_t::operator/=(const amount_t& amt) goto finish; } + if (has_commodity() && amt.has_commodity() && + commodity() != amt.commodity()) + throw new amount_error + (std::string("Dividing amounts with different commodities: ") + + (has_commodity() ? commodity_->qualified_symbol : "NONE") + " != " + + (amt.has_commodity() ? amt.commodity_->qualified_symbol : "NONE")); + _dup(); // Increase the value's precision, to capture fractional parts after -- cgit v1.2.3