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_(NULL), cur_(0), cap_(0) {}
38 const char* c_str()
const {
return buf_ ? buf_ :
""; }
41 void swap(DummyStream& rhs) {
42 std::swap(buf_, rhs.buf_);
43 std::swap(cur_, rhs.cur_);
44 std::swap(cap_, rhs.cap_);
46 DummyStream& append(
const char* str);
48 DummyStream& operator<<(
char c);
49 DummyStream& operator<<(
signed char c) {
50 *this << static_cast<int>(c);
53 DummyStream& operator<<(
unsigned char c) {
54 *this << static_cast<int>(c);
57 DummyStream& operator<<(
wchar_t c);
58 DummyStream& operator<<(
int value);
59 DummyStream& operator<<(
unsigned int value);
60 DummyStream& operator<<(
long value);
61 DummyStream& operator<<(
unsigned long value);
62 DummyStream& operator<<(
long long value);
63 DummyStream& operator<<(
unsigned long long value);
64 DummyStream& operator<<(
float value);
65 DummyStream& operator<<(
double value);
66 DummyStream& operator<<(
bool value);
67 DummyStream& operator<<(
const char* str);
68 DummyStream& operator<<(
const wchar_t* str);
69 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 70 template <
class DUMMY =
void>
72 DummyStream& operator<<(
const std::string& str) {
76 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 77 template <
class DUMMY =
void>
79 DummyStream& operator<<(
const std::wstring& str) {
84 DummyStream& operator<<(
const T& rhs) {
97 void PrintToArray(
const T* a,
size_t n, DummyStream* ostr) {
101 *ostr <<
"{" << a[0];
102 size_t nn = (n > 8) ? 8 : n;
103 for (
size_t i = 1; i < nn; ++i) {
104 *ostr <<
", " << a[i];
114 template <
class T,
size_t N>
115 inline void PrintTo(
const T (&a)[N], DummyStream* ostr) {
116 PrintToArray(&a[0], N, ostr);
120 inline void PrintTo(
const char (&str)[N], DummyStream* ostr) {
125 inline void PrintTo(
const wchar_t (&str)[N], DummyStream* ostr) {
129 template <
class T,
class Alloc>
130 inline void PrintTo(
const std::vector<T, Alloc>& value, DummyStream* ostr) {
131 PrintToArray(&value[0], value.size(), ostr);
134 template <
class T1,
class T2>
135 void PrintTo(
const std::pair<T1, T2>& value, DummyStream* ostr) {
137 PrintTo(value.first, ostr);
139 PrintTo(value.second, ostr);
144 inline void PrintTo(
const T& value, DummyStream* ostr) {
149 template <
class T,
class DUMMY>
150 inline void PrintTo(
const T& value, DUMMY* ostr) {
165 inline std::string PrintToString(
const T& value) {
168 ::nlib_ns::testing::detail_func::DummyStream str;
173 using ::nlib_ns::testing::detail_func::PrintTo;
174 PrintTo(value, &str);
175 return std::string(str.c_str());
181 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 182 #undef NLIB_VIS_PUBLIC 183 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 186 #endif // INCLUDE_NN_NLIB_TESTING_PRINTER_H_ #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。