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 40 DummyStream(DummyStream&& rhs)
NLIB_NOEXCEPT : buf_(rhs.buf_), cur_(rhs.cur_), cap_(rhs.cap_) {
42 rhs.cur_ = rhs.cap_ = 0U;
46 DummyStream(DummyStream& rhs, move_tag)
NLIB_NOEXCEPT : buf_(rhs.buf_),
50 rhs.cur_ = rhs.cap_ = 0U;
52 DummyStream& assign(DummyStream& rhs, move_tag)
NLIB_NOEXCEPT;
55 DummyStream& append(
const char* str);
57 DummyStream& operator<<(
char c);
58 DummyStream& operator<<(
signed char c) {
59 *this << static_cast<int>(c);
62 DummyStream& operator<<(
unsigned char c) {
63 *this << static_cast<int>(c);
66 DummyStream& operator<<(
wchar_t c);
67 DummyStream& operator<<(
int value);
68 DummyStream& operator<<(
unsigned int value);
69 DummyStream& operator<<(
long value);
70 DummyStream& operator<<(
unsigned long value);
71 DummyStream& operator<<(
long long value);
72 DummyStream& operator<<(
unsigned long long value);
73 DummyStream& operator<<(
float value);
74 DummyStream& operator<<(
double value);
75 DummyStream& operator<<(
bool value);
76 DummyStream& operator<<(
const char* str);
77 DummyStream& operator<<(
const wchar_t* str);
80 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 81 template<
class DUMMY =
void>
83 DummyStream& operator<<(
const std::string& str) {
87 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 88 template<
class DUMMY =
void>
90 DummyStream& operator<<(
const std::wstring& str) {
95 DummyStream& operator<<(
const T& rhs) {
108 void PrintToArray(
const T* a,
size_t n, DummyStream* ostr) {
112 *ostr <<
"{" << a[0];
113 size_t nn = (n > 8) ? 8 : n;
114 for (
size_t i = 1; i <
nn; ++i) {
115 *ostr <<
", " << a[i];
125 template<
class T,
size_t N>
126 inline void PrintTo(
const T (&a)[N], DummyStream* ostr) {
127 PrintToArray(&a[0], N, ostr);
131 inline void PrintTo(
const char (&str)[N], DummyStream* ostr) {
136 inline void PrintTo(
const wchar_t (&str)[N], DummyStream* ostr) {
140 template<
class T,
class Alloc>
141 inline void PrintTo(
const std::vector<T, Alloc>& value, DummyStream* ostr) {
142 PrintToArray(&value[0], value.size(), ostr);
145 template<
class T1,
class T2>
146 void PrintTo(
const std::pair<T1, T2>& value, DummyStream* ostr) {
148 PrintTo(value.first, ostr);
150 PrintTo(value.second, ostr);
155 inline void PrintTo(
const T& value, DummyStream* ostr) {
160 template<
class T,
class DUMMY>
161 inline void PrintTo(
const T& value, DUMMY* ostr) {
176 inline std::string PrintToString(
const T& value) {
179 ::nlib_ns::testing::detail_func::DummyStream str;
184 using ::nlib_ns::testing::detail_func::PrintTo;
185 PrintTo(value, &str);
186 return std::string(str.c_str());
192 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 193 #undef NLIB_VIS_PUBLIC 194 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 197 #endif // INCLUDE_NN_NLIB_TESTING_PRINTER_H_ #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。