rippled
Loading...
Searching...
No Matches
include/xrpl/beast/unit_test/amount.h
1// Distributed under the Boost Software License, Version 1.0. (See accompanying
2// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
3//
4
5#ifndef BEAST_UNIT_TEST_AMOUNT_HPP
6#define BEAST_UNIT_TEST_AMOUNT_HPP
7
8#include <cstddef>
9#include <ostream>
10#include <string>
11
12namespace beast {
13namespace unit_test {
14
16class amount
17{
18private:
21
22public:
23 amount(amount const&) = default;
24 amount&
25 operator=(amount const&) = delete;
26
27 template <class = void>
28 amount(std::size_t n, std::string const& what);
29
30 friend std::ostream&
31 operator<<(std::ostream& s, amount const& t);
32};
33
34template <class>
35amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what)
36{
37}
38
40operator<<(std::ostream& s, amount const& t)
41{
42 s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : "");
43 return s;
44}
45
46} // namespace unit_test
47} // namespace beast
48
49#endif
Utility for producing nicely composed output of amounts with units.
friend std::ostream & operator<<(std::ostream &s, amount const &t)
amount & operator=(amount const &)=delete
amount(amount const &)=default
std::ostream & operator<<(std::ostream &s, amount const &t)