1#include <xrpl/beast/unit_test.h>
2#include <xrpl/protocol/Quality.h>
17 template <
class Integer>
25 template <
class Integer>
35 template <
class In,
class Out>
42 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
44 ceil_in(Quality
const& q, In1
in, Out1
out, Int limit, In2 in_expected, Out2 out_expected)
46 auto expect_result(
amounts(in_expected, out_expected));
49 BEAST_EXPECT(actual_result == expect_result);
52 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
54 ceil_out(Quality
const& q, In1
in, Out1
out, Int limit, In2 in_expected, Out2 out_expected)
56 auto const expect_result(
amounts(in_expected, out_expected));
59 BEAST_EXPECT(actual_result == expect_result);
254 Quality q(0x5d048191fb9130daull);
257 raw(2755280000000000ull, -15));
259 Amounts
const result(q.ceil_out(value, limit));
260 BEAST_EXPECT(result.in != beast::zero);
269 Quality q(0x59148191fb913522ull);
270 BEAST_EXPECT(q.round(3).rate().getText() ==
"57800");
271 BEAST_EXPECT(q.round(4).rate().getText() ==
"57720");
272 BEAST_EXPECT(q.round(5).rate().getText() ==
"57720");
273 BEAST_EXPECT(q.round(6).rate().getText() ==
"57719.7");
274 BEAST_EXPECT(q.round(7).rate().getText() ==
"57719.64");
275 BEAST_EXPECT(q.round(8).rate().getText() ==
"57719.636");
276 BEAST_EXPECT(q.round(9).rate().getText() ==
"57719.6353");
277 BEAST_EXPECT(q.round(10).rate().getText() ==
"57719.63526");
278 BEAST_EXPECT(q.round(11).rate().getText() ==
"57719.635251");
279 BEAST_EXPECT(q.round(12).rate().getText() ==
"57719.6352506");
280 BEAST_EXPECT(q.round(13).rate().getText() ==
"57719.63525052");
281 BEAST_EXPECT(q.round(14).rate().getText() ==
"57719.635250517");
282 BEAST_EXPECT(q.round(15).rate().getText() ==
"57719.6352505169");
283 BEAST_EXPECT(q.round(16).rate().getText() ==
"57719.63525051682");
295 Quality
const q11(Amounts(amount1, amount1));
296 Quality
const q12(Amounts(amount1, amount2));
297 Quality
const q13(Amounts(amount1, amount3));
298 Quality
const q21(Amounts(amount2, amount1));
299 Quality
const q31(Amounts(amount3, amount1));
301 BEAST_EXPECT(q11 == q11);
302 BEAST_EXPECT(q11 < q12);
303 BEAST_EXPECT(q12 < q13);
304 BEAST_EXPECT(q31 < q21);
305 BEAST_EXPECT(q21 < q11);
306 BEAST_EXPECT(q11 >= q11);
307 BEAST_EXPECT(q12 >= q11);
308 BEAST_EXPECT(q13 >= q12);
309 BEAST_EXPECT(q21 >= q31);
310 BEAST_EXPECT(q11 >= q21);
311 BEAST_EXPECT(q12 > q11);
312 BEAST_EXPECT(q13 > q12);
313 BEAST_EXPECT(q21 > q31);
314 BEAST_EXPECT(q11 > q21);
315 BEAST_EXPECT(q11 <= q11);
316 BEAST_EXPECT(q11 <= q12);
317 BEAST_EXPECT(q12 <= q13);
318 BEAST_EXPECT(q31 <= q21);
319 BEAST_EXPECT(q21 <= q11);
320 BEAST_EXPECT(q31 != q21);
332 Quality
const q11(Amounts(amount1, amount1));
333 Quality
const q12(Amounts(amount1, amount2));
334 Quality
const q13(Amounts(amount1, amount3));
335 Quality
const q21(Amounts(amount2, amount1));
336 Quality
const q31(Amounts(amount3, amount1));
343 BEAST_EXPECT(q13_31 == q31_13);
344 BEAST_EXPECT(q13_31 == q11);
357 BEAST_EXPECT(qa == qb);
358 BEAST_EXPECT(++qa != q11);
359 BEAST_EXPECT(qa != qb);
360 BEAST_EXPECT(--qb != q11);
361 BEAST_EXPECT(qa != qb);
362 BEAST_EXPECT(qb < qa);
363 BEAST_EXPECT(qb++ < qa);
364 BEAST_EXPECT(qb++ < qa);
365 BEAST_EXPECT(qb++ == qa);
366 BEAST_EXPECT(qa < qb);
testcase_t testcase
Memberspace for declaring test cases.
A currency issued by an account.
static STAmount raw(std::uint64_t mantissa, int exponent)
static STAmount amount(Integer integer, std::enable_if_t<!std::is_signed< Integer >::value > *=0)
void ceil_out(Quality const &q, In1 in, Out1 out, Int limit, In2 in_expected, Out2 out_expected)
void run() override
Runs the suite.
void ceil_in(Quality const &q, In1 in, Out1 out, Int limit, In2 in_expected, Out2 out_expected)
static STAmount amount(Integer integer, std::enable_if_t< std::is_signed< Integer >::value > *=0)
static Amounts amounts(In in, Out out)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Quality composed_quality(Quality const &lhs, Quality const &rhs)
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.