20#include <xrpl/beast/unit_test.h>
21#include <xrpl/protocol/Quality.h>
36 template <
class Integer>
46 template <
class Integer>
58 template <
class In,
class Out>
65 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
75 auto expect_result(
amounts(in_expected, out_expected));
78 BEAST_EXPECT(actual_result == expect_result);
81 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
91 auto const expect_result(
amounts(in_expected, out_expected));
94 BEAST_EXPECT(actual_result == expect_result);
289 Quality q(0x5d048191fb9130daull);
292 raw(2755280000000000ull, -15));
294 raw(4131113916555555, -16));
295 Amounts
const result(q.ceil_out(value, limit));
296 BEAST_EXPECT(result.in != beast::zero);
305 Quality q(0x59148191fb913522ull);
306 BEAST_EXPECT(q.round(3).rate().getText() ==
"57800");
307 BEAST_EXPECT(q.round(4).rate().getText() ==
"57720");
308 BEAST_EXPECT(q.round(5).rate().getText() ==
"57720");
309 BEAST_EXPECT(q.round(6).rate().getText() ==
"57719.7");
310 BEAST_EXPECT(q.round(7).rate().getText() ==
"57719.64");
311 BEAST_EXPECT(q.round(8).rate().getText() ==
"57719.636");
312 BEAST_EXPECT(q.round(9).rate().getText() ==
"57719.6353");
313 BEAST_EXPECT(q.round(10).rate().getText() ==
"57719.63526");
314 BEAST_EXPECT(q.round(11).rate().getText() ==
"57719.635251");
315 BEAST_EXPECT(q.round(12).rate().getText() ==
"57719.6352506");
316 BEAST_EXPECT(q.round(13).rate().getText() ==
"57719.63525052");
317 BEAST_EXPECT(q.round(14).rate().getText() ==
"57719.635250517");
318 BEAST_EXPECT(q.round(15).rate().getText() ==
"57719.6352505169");
319 BEAST_EXPECT(q.round(16).rate().getText() ==
"57719.63525051682");
331 Quality
const q11(Amounts(amount1, amount1));
332 Quality
const q12(Amounts(amount1, amount2));
333 Quality
const q13(Amounts(amount1, amount3));
334 Quality
const q21(Amounts(amount2, amount1));
335 Quality
const q31(Amounts(amount3, amount1));
337 BEAST_EXPECT(q11 == q11);
338 BEAST_EXPECT(q11 < q12);
339 BEAST_EXPECT(q12 < q13);
340 BEAST_EXPECT(q31 < q21);
341 BEAST_EXPECT(q21 < q11);
342 BEAST_EXPECT(q11 >= q11);
343 BEAST_EXPECT(q12 >= q11);
344 BEAST_EXPECT(q13 >= q12);
345 BEAST_EXPECT(q21 >= q31);
346 BEAST_EXPECT(q11 >= q21);
347 BEAST_EXPECT(q12 > q11);
348 BEAST_EXPECT(q13 > q12);
349 BEAST_EXPECT(q21 > q31);
350 BEAST_EXPECT(q11 > q21);
351 BEAST_EXPECT(q11 <= q11);
352 BEAST_EXPECT(q11 <= q12);
353 BEAST_EXPECT(q12 <= q13);
354 BEAST_EXPECT(q31 <= q21);
355 BEAST_EXPECT(q21 <= q11);
356 BEAST_EXPECT(q31 != q21);
368 Quality
const q11(Amounts(amount1, amount1));
369 Quality
const q12(Amounts(amount1, amount2));
370 Quality
const q13(Amounts(amount1, amount3));
371 Quality
const q21(Amounts(amount2, amount1));
372 Quality
const q31(Amounts(amount3, amount1));
379 BEAST_EXPECT(q13_31 == q31_13);
380 BEAST_EXPECT(q13_31 == q11);
394 BEAST_EXPECT(qa == qb);
395 BEAST_EXPECT(++qa != q11);
396 BEAST_EXPECT(qa != qb);
397 BEAST_EXPECT(--qb != q11);
398 BEAST_EXPECT(qa != qb);
399 BEAST_EXPECT(qb < qa);
400 BEAST_EXPECT(qb++ < qa);
401 BEAST_EXPECT(qb++ < qa);
402 BEAST_EXPECT(qb++ == qa);
403 BEAST_EXPECT(qa < qb);
testcase_t testcase
Memberspace for declaring test cases.
A currency issued by an account.
void ceil_out(Quality const &q, In1 in, Out1 out, Int limit, In2 in_expected, Out2 out_expected)
void run() override
Runs the suite.
static STAmount amount(Integer integer, std::enable_if_t< std::is_signed< Integer >::value > *=0)
void ceil_in(Quality const &q, In1 in, Out1 out, Int limit, In2 in_expected, Out2 out_expected)
static Amounts amounts(In in, Out out)
static STAmount raw(std::uint64_t mantissa, int exponent)
static STAmount amount(Integer integer, std::enable_if_t<!std::is_signed< Integer >::value > *=0)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Quality composed_quality(Quality const &lhs, Quality const &rhs)
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Issue const & noIssue()
Returns an asset specifier that represents no account and currency.