rippled
Loading...
Searching...
No Matches
include/xrpl/beast/unit_test/amount.h
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_UNIT_TEST_AMOUNT_HPP
9#define BEAST_UNIT_TEST_AMOUNT_HPP
10
11#include <cstddef>
12#include <ostream>
13#include <string>
14
15namespace beast {
16namespace unit_test {
17
19class amount
20{
21private:
24
25public:
26 amount(amount const&) = default;
27 amount&
28 operator=(amount const&) = delete;
29
30 template <class = void>
31 amount(std::size_t n, std::string const& what);
32
33 friend std::ostream&
34 operator<<(std::ostream& s, amount const& t);
35};
36
37template <class>
38amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what)
39{
40}
41
43operator<<(std::ostream& s, amount const& t)
44{
45 s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : "");
46 return s;
47}
48
49} // namespace unit_test
50} // namespace beast
51
52#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)