1#include <xrpl/basics/Number.h>
2#include <xrpl/beast/unit_test/suite.h>
3#include <xrpl/json/json_forwards.h>
4#include <xrpl/protocol/IOUAmount.h>
5#include <xrpl/protocol/Issue.h>
6#include <xrpl/protocol/SField.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STNumber.h>
9#include <xrpl/protocol/Serializer.h>
26 STNumber const before{sfNumber, number};
27 BEAST_EXPECT(number == before);
30 BEAST_EXPECT(s.
size() == 12);
33 BEAST_EXPECT(
after.isEquivalent(before));
34 BEAST_EXPECT(number ==
after);
42 BEAST_EXPECT(stnum.
getSType() == STI_NUMBER);
43 BEAST_EXPECT(stnum.
getText() ==
"0");
64 STNumber const factor{sfNumber, 100};
65 auto const iouValue = strikePrice.
iou();
66 IOUAmount const totalValue{iouValue * factor};
68 BEAST_EXPECT(totalAmount ==
Number{10'000});
158 BEAST_EXPECT(e.
what() == expected);
168 std::string const expected =
"'e' is not a number";
169 BEAST_EXPECT(e.
what() == expected);
179 std::string const expected =
"'1e' is not a number";
180 BEAST_EXPECT(e.
what() == expected);
190 std::string const expected =
"'e2' is not a number";
191 BEAST_EXPECT(e.
what() == expected);
202 BEAST_EXPECT(e.
what() == expected);
209 "1234567890123456789012345678901234567890123456789012345678"
210 "9012345678901234567890123456789012345678901234567890123456"
211 "78901234567890123456789012345678901234567890");
227 std::string const expected =
"'001' is not a number";
228 BEAST_EXPECT(e.
what() == expected);
238 std::string const expected =
"'000.0' is not a number";
239 BEAST_EXPECT(e.
what() == expected);
250 std::string const expected =
"'.1' is not a number";
251 BEAST_EXPECT(e.
what() == expected);
261 std::string const expected =
"'1.' is not a number";
262 BEAST_EXPECT(e.
what() == expected);
272 std::string const expected =
"'1.e3' is not a number";
273 BEAST_EXPECT(e.
what() == expected);
TestcaseT testcase
Memberspace for declaring test cases.
Floating point representation of amounts with high dynamic range.
A currency issued by an account.
Sets the new scale and restores the old scale when it leaves scope.
Number is a floating point type that can represent a wide range of values.
static constexpr int kMinExponent
static MantissaRange::MantissaScale getMantissaScale()
Returns which mantissa scale is currently in use for normalization.
static constexpr int kMaxExponent
constexpr TIss const & get() const
void add(Serializer &s) const override
bool isDefault() const override
std::string getText() const override
SerializedTypeID getSType() const override
Number const & value() const
Slice slice() const noexcept
std::size_t size() const noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
int scale(Number const &number, Asset const &asset)
Get the scale of a Number for a given asset.
std::string to_string(BaseUInt< Bits, Tag > const &a)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
STNumber numberFromJson(SField const &field, json::Value const &value)
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, xrpl)
static std::set< MantissaScale > const & getAllScales()
void testCombo(Number number)
void run() override
Runs the suite.