19 #ifndef __STDC_CONSTANT_MACROS 21 #pragma GCC diagnostic push 22 #if __has_warning("-Wreserved-id-macro") 23 #pragma GCC diagnostic ignored "-Wreserved-id-macro" 27 # define __STDC_CONSTANT_MACROS 1 // required by C++ standard 30 #pragma GCC diagnostic pop 35 #define _CRTDBG_MAP_ALLOC 37 #pragma warning(disable : 4996) // 'function': was declared deprecated 40 #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) 41 #if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 42 #pragma GCC diagnostic push 44 #pragma GCC diagnostic ignored "-Weffc++" 47 #include "gtest/gtest.h" 50 #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 51 #pragma GCC diagnostic pop 56 #pragma GCC diagnostic ignored "-Wglobal-constructors" 59 template <
typename Ch>
60 inline unsigned StrLen(
const Ch* s) {
63 return unsigned(p - s);
67 inline int StrCmp(
const Ch* s1,
const Ch* s2) {
68 while(*s1 && (*s1 == *s2)) { s1++; s2++; }
69 return static_cast<unsigned>(*s1) <
static_cast<unsigned>(*s2) ? -1 :
static_cast<unsigned>(*s1) >
static_cast<unsigned>(*s2);
72 template <
typename Ch>
74 size_t bufferSize =
sizeof(Ch) * (
StrLen(str) + 1);
75 Ch* buffer =
static_cast<Ch*
>(malloc(bufferSize));
76 memcpy(buffer, str, bufferSize);
81 #if defined(__WIN32__) || defined(_MSC_VER) 82 filename = tmpnam(filename);
85 if (filename[0] ==
'\\')
86 for (
int i = 0; filename[i] !=
'\0'; i++)
87 filename[i] = filename[i + 1];
89 return fopen(filename,
"wb");
91 strcpy(filename,
"/tmp/fileXXXXXX");
92 int fd = mkstemp(filename);
93 return fdopen(fd,
"w");
99 #pragma warning(disable : 4127) 103 #pragma GCC diagnostic push 104 #if __has_warning("-Wdeprecated") 105 #pragma GCC diagnostic ignored "-Wdeprecated" 117 #pragma GCC diagnostic pop 120 #define RAPIDJSON_ASSERT(x) (!(x) ? throw AssertException(RAPIDJSON_STRINGIFY(x)) : (void)0u) 124 Random(
unsigned seed = 0) : mSeed(seed) {}
127 mSeed = 214013 * mSeed + 2531011;
135 #endif // UNITTEST_H_
FILE * TempFile(char *filename)
AssertException(const char *w)
Ch * StrDup(const Ch *str)
int StrCmp(const Ch *s1, const Ch *s2)
unsigned StrLen(const Ch *s)
virtual ~AssertException()
AssertException(const AssertException &rhs)