mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Make XRPAmount constructor explicit:
Remove the implicit conversion from int64 to XRPAmount. The motivation for this was noticing that many calls to `to_string` with an integer parameter type were calling the wrong `to_string` function. Since the calls were not prefixed with `std::`, and there is no ADL to call `std::to_string`, this was converting the int to an `XRPAmount` and calling `to_string(XRPAmount)`. Since `to_string(XRPAmount)` did the same thing as `to_string(int)` this error went undetected.
This commit is contained in:
@@ -344,8 +344,7 @@ public:
|
||||
void run() override
|
||||
{
|
||||
BEAST_EXPECT(INITIAL_XRP.drops() == 100'000'000'000'000'000);
|
||||
BEAST_EXPECT(INITIAL_XRP ==
|
||||
XRPAmount{ 100'000'000'000'000'000 });
|
||||
BEAST_EXPECT(INITIAL_XRP == XRPAmount{100'000'000'000'000'000});
|
||||
|
||||
testTypes();
|
||||
testJson();
|
||||
|
||||
@@ -132,8 +132,7 @@ public:
|
||||
{
|
||||
// Explicitly test every defined function for the XRPAmount class
|
||||
// since some of them are templated, but not used anywhere else.
|
||||
auto make = [&](auto x) -> XRPAmount {
|
||||
return x; };
|
||||
auto make = [&](auto x) -> XRPAmount { return XRPAmount{x}; };
|
||||
|
||||
XRPAmount defaulted;
|
||||
(void)defaulted;
|
||||
@@ -156,8 +155,8 @@ public:
|
||||
test = make(targetSame);
|
||||
BEAST_EXPECT(test.drops() == 200);
|
||||
BEAST_EXPECT(test == targetSame);
|
||||
BEAST_EXPECT(test < XRPAmount{ 1000 });
|
||||
BEAST_EXPECT(test > XRPAmount{ 100 });
|
||||
BEAST_EXPECT(test < XRPAmount{1000});
|
||||
BEAST_EXPECT(test > XRPAmount{100});
|
||||
|
||||
test = std::int64_t(200);
|
||||
BEAST_EXPECT(test.drops() == 200);
|
||||
|
||||
Reference in New Issue
Block a user