Browse Source

Get rid of fPlus argument to FormatMoney

It's never used with any other value than false, the default.
0.13
Wladimir J. van der Laan 10 years ago
parent
commit
a04bdefbeb
  1. 2
      src/rpcserver.cpp
  2. 44
      src/test/util_tests.cpp
  3. 4
      src/utilmoneystr.cpp
  4. 2
      src/utilmoneystr.h

2
src/rpcserver.cpp

@ -133,7 +133,7 @@ CAmount AmountFromValue(const UniValue& value)
UniValue ValueFromAmount(const CAmount& amount) UniValue ValueFromAmount(const CAmount& amount)
{ {
return UniValue(UniValue::VREAL, FormatMoney(amount, false)); return UniValue(UniValue::VREAL, FormatMoney(amount));
} }
uint256 ParseHashV(const UniValue& v, string strName) uint256 ParseHashV(const UniValue& v, string strName)

44
src/test/util_tests.cpp

@ -146,29 +146,27 @@ BOOST_AUTO_TEST_CASE(util_GetArg)
BOOST_AUTO_TEST_CASE(util_FormatMoney) BOOST_AUTO_TEST_CASE(util_FormatMoney)
{ {
BOOST_CHECK_EQUAL(FormatMoney(0, false), "0.00"); BOOST_CHECK_EQUAL(FormatMoney(0), "0.00");
BOOST_CHECK_EQUAL(FormatMoney((COIN/10000)*123456789, false), "12345.6789"); BOOST_CHECK_EQUAL(FormatMoney((COIN/10000)*123456789), "12345.6789");
BOOST_CHECK_EQUAL(FormatMoney(COIN, true), "+1.00"); BOOST_CHECK_EQUAL(FormatMoney(-COIN), "-1.00");
BOOST_CHECK_EQUAL(FormatMoney(-COIN, false), "-1.00");
BOOST_CHECK_EQUAL(FormatMoney(-COIN, true), "-1.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*100000000), "100000000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*10000000), "10000000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*100000000, false), "100000000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*1000000), "1000000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*10000000, false), "10000000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*100000), "100000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*1000000, false), "1000000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*10000), "10000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*100000, false), "100000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*1000), "1000.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*10000, false), "10000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*100), "100.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*1000, false), "1000.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN*10), "10.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*100, false), "100.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN), "1.00");
BOOST_CHECK_EQUAL(FormatMoney(COIN*10, false), "10.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN/10), "0.10");
BOOST_CHECK_EQUAL(FormatMoney(COIN, false), "1.00"); BOOST_CHECK_EQUAL(FormatMoney(COIN/100), "0.01");
BOOST_CHECK_EQUAL(FormatMoney(COIN/10, false), "0.10"); BOOST_CHECK_EQUAL(FormatMoney(COIN/1000), "0.001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/100, false), "0.01"); BOOST_CHECK_EQUAL(FormatMoney(COIN/10000), "0.0001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/1000, false), "0.001"); BOOST_CHECK_EQUAL(FormatMoney(COIN/100000), "0.00001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/10000, false), "0.0001"); BOOST_CHECK_EQUAL(FormatMoney(COIN/1000000), "0.000001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/100000, false), "0.00001"); BOOST_CHECK_EQUAL(FormatMoney(COIN/10000000), "0.0000001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/1000000, false), "0.000001"); BOOST_CHECK_EQUAL(FormatMoney(COIN/100000000), "0.00000001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/10000000, false), "0.0000001");
BOOST_CHECK_EQUAL(FormatMoney(COIN/100000000, false), "0.00000001");
} }
BOOST_AUTO_TEST_CASE(util_ParseMoney) BOOST_AUTO_TEST_CASE(util_ParseMoney)

4
src/utilmoneystr.cpp

@ -11,7 +11,7 @@
using namespace std; using namespace std;
string FormatMoney(const CAmount& n, bool fPlus) std::string FormatMoney(const CAmount& n)
{ {
// Note: not using straight sprintf here because we do NOT want // Note: not using straight sprintf here because we do NOT want
// localized number formatting. // localized number formatting.
@ -29,8 +29,6 @@ string FormatMoney(const CAmount& n, bool fPlus)
if (n < 0) if (n < 0)
str.insert((unsigned int)0, 1, '-'); str.insert((unsigned int)0, 1, '-');
else if (fPlus && n > 0)
str.insert((unsigned int)0, 1, '+');
return str; return str;
} }

2
src/utilmoneystr.h

@ -14,7 +14,7 @@
#include "amount.h" #include "amount.h"
std::string FormatMoney(const CAmount& n, bool fPlus=false); std::string FormatMoney(const CAmount& n);
bool ParseMoney(const std::string& str, CAmount& nRet); bool ParseMoney(const std::string& str, CAmount& nRet);
bool ParseMoney(const char* pszIn, CAmount& nRet); bool ParseMoney(const char* pszIn, CAmount& nRet);

Loading…
Cancel
Save