#include "gtest/gtest.h"
#include <stdexcept>
Go to the source code of this file.
|
| template<typename Ch > |
| unsigned | StrLen (const Ch *s) |
| |
| template<typename Ch > |
| int | StrCmp (const Ch *s1, const Ch *s2) |
| |
| template<typename Ch > |
| Ch * | StrDup (const Ch *str) |
| |
| FILE * | TempFile (char *filename) |
| |
◆ __STDC_CONSTANT_MACROS
| #define __STDC_CONSTANT_MACROS 1 |
◆ RAPIDJSON_ASSERT
| #define RAPIDJSON_ASSERT |
( |
|
x | ) |
(!(x) ? throw AssertException(RAPIDJSON_STRINGIFY(x)) : (void)0u) |
◆ RAPIDJSON_HAS_CXX11_NOEXCEPT
| #define RAPIDJSON_HAS_CXX11_NOEXCEPT 0 |
◆ StrCmp()
template<typename Ch >
| int StrCmp |
( |
const Ch * |
s1, |
|
|
const Ch * |
s2 |
|
) |
| |
|
inline |
Definition at line 67 of file unittest.h.
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);
◆ StrDup()
template<typename Ch >
| Ch* StrDup |
( |
const Ch * |
str | ) |
|
|
inline |
Definition at line 73 of file unittest.h.
74 size_t bufferSize =
sizeof(
Ch) * (
StrLen(str) + 1);
75 Ch* buffer =
static_cast<Ch*
>(malloc(bufferSize));
76 memcpy(buffer, str, bufferSize);
void * memcpy(void *a, const void *b, size_t c)
unsigned StrLen(const Ch *s)
◆ StrLen()
template<typename Ch >
| unsigned StrLen |
( |
const Ch * |
s | ) |
|
|
inline |
Definition at line 60 of file unittest.h.
63 return unsigned(p - s);
◆ TempFile()
| FILE* TempFile |
( |
char * |
filename | ) |
|
|
inline |
Definition at line 80 of file unittest.h.
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");