1#include <xrpl/beast/unit_test.h>
2#include <xrpl/protocol/Quality.h>
17 template <
class Integer>
27 template <
class Integer>
39 template <
class In,
class Out>
46 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
56 auto expect_result(
amounts(in_expected, out_expected));
59 BEAST_EXPECT(actual_result == expect_result);
62 template <
class In1,
class Out1,
class Int,
class In2,
class Out2>
72 auto const expect_result(
amounts(in_expected, out_expected));
75 BEAST_EXPECT(actual_result == expect_result);
270 Quality q(0x5d048191fb9130daull);
273 raw(2755280000000000ull, -15));
275 raw(4131113916555555, -16));
276 Amounts
const result(q.ceil_out(value, limit));
277 BEAST_EXPECT(result.in != beast::zero);
286 Quality q(0x59148191fb913522ull);
287 BEAST_EXPECT(q.round(3).rate().getText() ==
"57800");
288 BEAST_EXPECT(q.round(4).rate().getText() ==
"57720");
289 BEAST_EXPECT(q.round(5).rate().getText() ==
"57720");
290 BEAST_EXPECT(q.round(6).rate().getText() ==
"57719.7");
291 BEAST_EXPECT(q.round(7).rate().getText() ==
"57719.64");
292 BEAST_EXPECT(q.round(8).rate().getText() ==
"57719.636");
293 BEAST_EXPECT(q.round(9).rate().getText() ==
"57719.6353");
294 BEAST_EXPECT(q.round(10).rate().getText() ==
"57719.63526");
295 BEAST_EXPECT(q.round(11).rate().getText() ==
"57719.635251");
296 BEAST_EXPECT(q.round(12).rate().getText() ==
"57719.6352506");
297 BEAST_EXPECT(q.round(13).rate().getText() ==
"57719.63525052");
298 BEAST_EXPECT(q.round(14).rate().getText() ==
"57719.635250517");
299 BEAST_EXPECT(q.round(15).rate().getText() ==
"57719.6352505169");
300 BEAST_EXPECT(q.round(16).rate().getText() ==
"57719.63525051682");
312 Quality
const q11(Amounts(amount1, amount1));
313 Quality
const q12(Amounts(amount1, amount2));
314 Quality
const q13(Amounts(amount1, amount3));
315 Quality
const q21(Amounts(amount2, amount1));
316 Quality
const q31(Amounts(amount3, amount1));
318 BEAST_EXPECT(q11 == q11);
319 BEAST_EXPECT(q11 < q12);
320 BEAST_EXPECT(q12 < q13);
321 BEAST_EXPECT(q31 < q21);
322 BEAST_EXPECT(q21 < q11);
323 BEAST_EXPECT(q11 >= q11);
324 BEAST_EXPECT(q12 >= q11);
325 BEAST_EXPECT(q13 >= q12);
326 BEAST_EXPECT(q21 >= q31);
327 BEAST_EXPECT(q11 >= q21);
328 BEAST_EXPECT(q12 > q11);
329 BEAST_EXPECT(q13 > q12);
330 BEAST_EXPECT(q21 > q31);
331 BEAST_EXPECT(q11 > q21);
332 BEAST_EXPECT(q11 <= q11);
333 BEAST_EXPECT(q11 <= q12);
334 BEAST_EXPECT(q12 <= q13);
335 BEAST_EXPECT(q31 <= q21);
336 BEAST_EXPECT(q21 <= q11);
337 BEAST_EXPECT(q31 != q21);
349 Quality
const q11(Amounts(amount1, amount1));
350 Quality
const q12(Amounts(amount1, amount2));
351 Quality
const q13(Amounts(amount1, amount3));
352 Quality
const q21(Amounts(amount2, amount1));
353 Quality
const q31(Amounts(amount3, amount1));
360 BEAST_EXPECT(q13_31 == q31_13);
361 BEAST_EXPECT(q13_31 == q11);
375 BEAST_EXPECT(qa == qb);
376 BEAST_EXPECT(++qa != q11);
377 BEAST_EXPECT(qa != qb);
378 BEAST_EXPECT(--qb != q11);
379 BEAST_EXPECT(qa != qb);
380 BEAST_EXPECT(qb < qa);
381 BEAST_EXPECT(qb++ < qa);
382 BEAST_EXPECT(qb++ < qa);
383 BEAST_EXPECT(qb++ == qa);
384 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.