3 #ifndef INCLUDE_NN_NLIB_TESTING_PRINTER_H_ 4 #define INCLUDE_NN_NLIB_TESTING_PRINTER_H_ 12 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 13 #undef NLIB_VIS_PUBLIC 14 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 19 namespace detail_func {
23 DummyStream() : buf_(NULL), cur_(0), cap_(0) {}
25 const char* c_str()
const {
return buf_ ? buf_ :
""; }
28 void swap(DummyStream& rhs) {
29 std::swap(buf_, rhs.buf_);
30 std::swap(cur_, rhs.cur_);
31 std::swap(cap_, rhs.cap_);
33 DummyStream& append(
const char* str);
35 DummyStream& operator<<(
char c);
36 DummyStream& operator<<(
signed char c) {
37 *this << static_cast<int>(c);
40 DummyStream& operator<<(
unsigned char c) {
41 *this << static_cast<int>(c);
44 DummyStream& operator<<(
wchar_t c);
45 DummyStream& operator<<(
int value);
46 DummyStream& operator<<(
unsigned int value);
47 DummyStream& operator<<(
long value);
48 DummyStream& operator<<(
unsigned long value);
49 DummyStream& operator<<(
long long value);
50 DummyStream& operator<<(
unsigned long long value);
51 DummyStream& operator<<(
float value);
52 DummyStream& operator<<(
double value);
53 DummyStream& operator<<(
bool value);
54 DummyStream& operator<<(
const char* str);
55 DummyStream& operator<<(
const wchar_t* str);
56 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 57 template <
class DUMMY =
void>
59 DummyStream& operator<<(
const std::string& str) {
63 #ifdef NLIB_CXX11_DEFAULT_TEMPLATE_ARGUMENT_FOR_FUNCTION_TEMPLATES 64 template <
class DUMMY =
void>
66 DummyStream& operator<<(
const std::wstring& str) {
71 DummyStream& operator<<(
const T& rhs) {
84 void PrintToArray(
const T* a,
size_t n, DummyStream* ostr) {
89 size_t nn = (n > 8) ? 8 : n;
90 for (
size_t i = 1; i < nn; ++i) {
91 *ostr <<
", " << a[i];
101 template <
class T,
size_t N>
102 inline void PrintTo(
const T (&a)[N], DummyStream* ostr) {
103 PrintToArray(&a[0], N, ostr);
107 inline void PrintTo(
const char (&str)[N], DummyStream* ostr) {
112 inline void PrintTo(
const wchar_t (&str)[N], DummyStream* ostr) {
116 template <
class T,
class Alloc>
117 inline void PrintTo(
const std::vector<T, Alloc>& value, DummyStream* ostr) {
118 PrintToArray(&value[0], value.size(), ostr);
121 template <
class T1,
class T2>
122 void PrintTo(
const std::pair<T1, T2>& value, DummyStream* ostr) {
124 PrintTo(value.first, ostr);
126 PrintTo(value.second, ostr);
131 inline void PrintTo(
const T& value, DummyStream* ostr) {
136 template <
class T,
class DUMMY>
137 inline void PrintTo(
const T& value, DUMMY* ostr) {
152 inline std::string PrintToString(
const T& value) {
155 ::nlib_ns::testing::detail_func::DummyStream str;
160 using ::nlib_ns::testing::detail_func::PrintTo;
161 PrintTo(value, &str);
162 return std::string(str.c_str());
168 #if defined(_MSC_VER) && defined(nx_testing_EXPORTS) 169 #undef NLIB_VIS_PUBLIC 170 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 173 #endif // INCLUDE_NN_NLIB_TESTING_PRINTER_H_ #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
A file that contains the configuration information for each development environment.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.