20#include <xrpl/beast/unit_test.h>
21#include <xrpl/protocol/Quality.h>
35 template <
class Integer>
45 template <
class Integer>
57 template <
class In,
class Out>
64 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
74 auto expect_result(
amounts(in_expected, out_expected));
77 BEAST_EXPECT(actual_result == expect_result);
80 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
90 auto const expect_result(
amounts(in_expected, out_expected));
93 BEAST_EXPECT(actual_result == expect_result);
288 Quality q(0x5d048191fb9130daull);
291 raw(2755280000000000ull, -15));
293 raw(4131113916555555, -16));
294 Amounts
const result(q.ceil_out(value, limit));
295 BEAST_EXPECT(result.in != beast::zero);
304 Quality q(0x59148191fb913522ull);
305 BEAST_EXPECT(q.round(3).rate().getText() ==
"57800");
306 BEAST_EXPECT(q.round(4).rate().getText() ==
"57720");
307 BEAST_EXPECT(q.round(5).rate().getText() ==
"57720");
308 BEAST_EXPECT(q.round(6).rate().getText() ==
"57719.7");
309 BEAST_EXPECT(q.round(7).rate().getText() ==
"57719.64");
310 BEAST_EXPECT(q.round(8).rate().getText() ==
"57719.636");
311 BEAST_EXPECT(q.round(9).rate().getText() ==
"57719.6353");
312 BEAST_EXPECT(q.round(10).rate().getText() ==
"57719.63526");
313 BEAST_EXPECT(q.round(11).rate().getText() ==
"57719.635251");
314 BEAST_EXPECT(q.round(12).rate().getText() ==
"57719.6352506");
315 BEAST_EXPECT(q.round(13).rate().getText() ==
"57719.63525052");
316 BEAST_EXPECT(q.round(14).rate().getText() ==
"57719.635250517");
317 BEAST_EXPECT(q.round(15).rate().getText() ==
"57719.6352505169");
318 BEAST_EXPECT(q.round(16).rate().getText() ==
"57719.63525051682");
330 Quality
const q11(Amounts(amount1, amount1));
331 Quality
const q12(Amounts(amount1, amount2));
332 Quality
const q13(Amounts(amount1, amount3));
333 Quality
const q21(Amounts(amount2, amount1));
334 Quality
const q31(Amounts(amount3, amount1));
336 BEAST_EXPECT(q11 == q11);
337 BEAST_EXPECT(q11 < q12);
338 BEAST_EXPECT(q12 < q13);
339 BEAST_EXPECT(q31 < q21);
340 BEAST_EXPECT(q21 < q11);
341 BEAST_EXPECT(q11 >= q11);
342 BEAST_EXPECT(q12 >= q11);
343 BEAST_EXPECT(q13 >= q12);
344 BEAST_EXPECT(q21 >= q31);
345 BEAST_EXPECT(q11 >= q21);
346 BEAST_EXPECT(q12 > q11);
347 BEAST_EXPECT(q13 > q12);
348 BEAST_EXPECT(q21 > q31);
349 BEAST_EXPECT(q11 > q21);
350 BEAST_EXPECT(q11 <= q11);
351 BEAST_EXPECT(q11 <= q12);
352 BEAST_EXPECT(q12 <= q13);
353 BEAST_EXPECT(q31 <= q21);
354 BEAST_EXPECT(q21 <= q11);
355 BEAST_EXPECT(q31 != q21);
367 Quality
const q11(Amounts(amount1, amount1));
368 Quality
const q12(Amounts(amount1, amount2));
369 Quality
const q13(Amounts(amount1, amount3));
370 Quality
const q21(Amounts(amount2, amount1));
371 Quality
const q31(Amounts(amount3, amount1));
378 BEAST_EXPECT(q13_31 == q31_13);
379 BEAST_EXPECT(q13_31 == q11);
393 BEAST_EXPECT(qa == qb);
394 BEAST_EXPECT(++qa != q11);
395 BEAST_EXPECT(qa != qb);
396 BEAST_EXPECT(--qb != q11);
397 BEAST_EXPECT(qa != qb);
398 BEAST_EXPECT(qb < qa);
399 BEAST_EXPECT(qb++ < qa);
400 BEAST_EXPECT(qb++ < qa);
401 BEAST_EXPECT(qb++ == qa);
402 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.