16 #ifndef INCLUDE_NN_NLIB_TESTING_PRINTER_H_ 17 #define INCLUDE_NN_NLIB_TESTING_PRINTER_H_ 25 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 26 #undef NLIB_VIS_PUBLIC 27 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 32 namespace detail_func {
36 DummyStream() : buf_(nullptr), cur_(0U), cap_(0U) {}
38 const char* c_str()
const {
return buf_ ? buf_ :
""; }
39 #ifdef __cpp_rvalue_references 41 : buf_(rhs.buf_), cur_(rhs.cur_), cap_(rhs.cap_) {
43 rhs.cur_ = rhs.cap_ = 0U;
47 DummyStream(DummyStream& rhs, move_tag) NLIB_NOEXCEPT
48 : buf_(rhs.buf_), cur_(rhs.cur_), cap_(rhs.cap_) {
50 rhs.cur_ = rhs.cap_ = 0U;
52 DummyStream& assign(DummyStream& rhs, move_tag)
NLIB_NOEXCEPT;
56 std::swap(buf_, rhs.buf_);
57 std::swap(cur_, rhs.cur_);
58 std::swap(cap_, rhs.cap_);
60 DummyStream& append(
const char* str);
62 DummyStream& operator<<(
char c);
63 DummyStream& operator<<(
signed char c) {
64 *this << static_cast<int>(c);
67 DummyStream& operator<<(
unsigned char c) {
68 *this << static_cast<int>(c);
71 DummyStream& operator<<(
wchar_t c);
72 DummyStream& operator<<(
int value);
73 DummyStream& operator<<(
unsigned int value);
74 DummyStream& operator<<(
long value);
75 DummyStream& operator<<(
unsigned long value);
76 DummyStream& operator<<(
long long value);
77 DummyStream& operator<<(
unsigned long long value);
78 DummyStream& operator<<(
float value);
79 DummyStream& operator<<(
double value);
80 DummyStream& operator<<(
bool value);
81 DummyStream& operator<<(
const char* str);
82 DummyStream& operator<<(
const wchar_t* str);
83 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 84 template <
class DUMMY =
void>
86 DummyStream& operator<<(
const std::string& str) {
90 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 91 template <
class DUMMY =
void>
93 DummyStream& operator<<(
const std::wstring& str) {
98 DummyStream& operator<<(
const T& rhs) {
111 void PrintToArray(
const T* a,
size_t n, DummyStream* ostr) {
115 *ostr <<
"{" << a[0];
116 size_t nn = (n > 8) ? 8 : n;
117 for (
size_t i = 1; i < nn; ++i) {
118 *ostr <<
", " << a[i];
128 template <
class T,
size_t N>
129 inline void PrintTo(
const T (&a)[N], DummyStream* ostr) {
130 PrintToArray(&a[0], N, ostr);
134 inline void PrintTo(
const char (&str)[N], DummyStream* ostr) {
139 inline void PrintTo(
const wchar_t (&str)[N], DummyStream* ostr) {
143 template <
class T,
class Alloc>
144 inline void PrintTo(
const std::vector<T, Alloc>& value, DummyStream* ostr) {
145 PrintToArray(&value[0], value.size(), ostr);
148 template <
class T1,
class T2>
149 void PrintTo(
const std::pair<T1, T2>& value, DummyStream* ostr) {
151 PrintTo(value.first, ostr);
153 PrintTo(value.second, ostr);
158 inline void PrintTo(
const T& value, DummyStream* ostr) {
163 template <
class T,
class DUMMY>
164 inline void PrintTo(
const T& value, DUMMY* ostr) {
179 inline std::string PrintToString(
const T& value) {
182 ::nlib_ns::testing::detail_func::DummyStream str;
187 using ::nlib_ns::testing::detail_func::PrintTo;
188 PrintTo(value, &str);
189 return std::string(str.c_str());
195 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 196 #undef NLIB_VIS_PUBLIC 197 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 200 #endif // INCLUDE_NN_NLIB_TESTING_PRINTER_H_ #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。