| 63 | |
| 64 | template <typename FileStreamType> |
| 65 | static void TestFileStream() { |
| 66 | char filename[L_tmpnam]; |
| 67 | FILE* fp = TempFile(filename); |
| 68 | fclose(fp); |
| 69 | |
| 70 | const char* s = "Hello World!\n"; |
| 71 | { |
| 72 | ofstream ofs(filename, ios::out | ios::binary); |
| 73 | BasicOStreamWrapper<ofstream> osw(ofs); |
| 74 | for (const char* p = s; *p; p++) |
| 75 | osw.Put(*p); |
| 76 | osw.Flush(); |
| 77 | } |
| 78 | |
| 79 | fp = fopen(filename, "r"); |
| 80 | for (const char* p = s; *p; p++) |
| 81 | EXPECT_EQ(*p, static_cast<char>(fgetc(fp))); |
| 82 | fclose(fp); |
| 83 | } |
| 84 | |
| 85 | TEST(OStreamWrapper, ofstream) { |
| 86 | TestFileStream<ofstream>(); |