26 template <
typename StringStreamType>
27 static void TestStringStream() {
28 typedef typename StringStreamType::char_type
Ch;
30 Ch s[] = {
'A',
'B',
'C',
'\0' };
31 StringStreamType oss(s);
33 for (
size_t i = 0; i < 3; i++)
36 for (
size_t i = 0; i < 3; i++)
41 TestStringStream<ostringstream>();
45 TestStringStream<stringstream>();
49 TestStringStream<wostringstream>();
53 TestStringStream<wstringstream>();
58 const char* s =
"Hello World!\n";
64 template <
typename FileStreamType>
65 static void TestFileStream() {
66 char filename[L_tmpnam];
70 const char* s =
"Hello World!\n";
72 FileStreamType ofs(filename, ios::out | ios::binary);
74 for (
const char* p = s; *p; p++)
79 fp = fopen(filename,
"r");
81 for (
const char* p = s; *p; p++)
82 EXPECT_EQ(*p, static_cast<char>(fgetc(fp)));
87 TestFileStream<ofstream>();
91 TestFileStream<fstream>();
FILE * TempFile(char *filename)
TEST(OStreamWrapper, ostringstream)
Wrapper of std::basic_ostream into RapidJSON's Stream concept.
#define ASSERT_TRUE(condition)
#define EXPECT_EQ(val1, val2)