summaryrefslogtreecommitdiff
path: root/test/unit/t_amount.cc
diff options
context:
space:
mode:
authorMax Nikulin <manikulin@gmail.com>2024-08-06 16:10:12 +0700
committerJohn Wiegley <johnw@newartisans.com>2024-08-06 10:40:04 -1000
commitb7be0a1fedfeec26e4b7d35357157d5a9209f3ee (patch)
treefb1584ca7ce34cbb38d34e9ecd4ad84659dfb538 /test/unit/t_amount.cc
parent28ae2eaccb58e539dfd8f8533508a8edfe8bb027 (diff)
downloadfork-ledger-b7be0a1fedfeec26e4b7d35357157d5a9209f3ee.tar.gz
fork-ledger-b7be0a1fedfeec26e4b7d35357157d5a9209f3ee.tar.bz2
fork-ledger-b7be0a1fedfeec26e4b7d35357157d5a9209f3ee.zip
Fix copy on write for amount_t::in_place_roundto
- Copy amount quantity before rounding. - Fix `amount_t::roundto(int)`. - Transform `balance/testRound` into `balance/testRoundto`. It was a mix of `round` and `roundto` operation with unclear purpose and was relying on `in_place_roundto` behavior modifying all copies. There is no unit tests for balance `round` and `unround` any more. Closes #2362
Diffstat (limited to 'test/unit/t_amount.cc')
-rw-r--r--test/unit/t_amount.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/test/unit/t_amount.cc b/test/unit/t_amount.cc
index 28bc56e9..f0fdd73e 100644
--- a/test/unit/t_amount.cc
+++ b/test/unit/t_amount.cc
@@ -1163,16 +1163,15 @@ BOOST_AUTO_TEST_CASE(testCommodityCeiling)
BOOST_CHECK(x2.valid());
}
-BOOST_AUTO_TEST_CASE(testRound, * boost::unit_test::expected_failures(1))
+BOOST_AUTO_TEST_CASE(testRound)
{
amount_t a1("$ 123.123");
amount_t a2(a1);
a2.in_place_roundto(2);
- // Fails due to missing _dup() call in amount_t::in_place_roundto(int).
- // <https://github.com/ledger/ledger/issues/2362>
BOOST_CHECK_EQUAL(amount_t("$ 123.123"), a1);
// Should it be "$ 123.12"?
BOOST_CHECK_EQUAL(amount_t("$ 123.120"), a2);
+ BOOST_CHECK_EQUAL(amount_t("$ 123.120"), a1.roundto(2));
}
#ifndef NOT_FOR_PYTHON