open_pointer.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <fstream> 11 12// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode); 13 14#include <fstream> 15#include <cassert> 16 17int main() 18{ 19 { 20 std::filebuf f; 21 assert(f.open("test.dat", std::ios_base::out) != 0); 22 assert(f.is_open()); 23 assert(f.sputn("123", 3) == 3); 24 } 25 { 26 std::filebuf f; 27 assert(f.open("test.dat", std::ios_base::in) != 0); 28 assert(f.is_open()); 29 assert(f.sbumpc() == '1'); 30 assert(f.sbumpc() == '2'); 31 assert(f.sbumpc() == '3'); 32 } 33 remove("test.dat"); 34 { 35 std::wfilebuf f; 36 assert(f.open("test.dat", std::ios_base::out) != 0); 37 assert(f.is_open()); 38 assert(f.sputn(L"123", 3) == 3); 39 } 40 { 41 std::wfilebuf f; 42 assert(f.open("test.dat", std::ios_base::in) != 0); 43 assert(f.is_open()); 44 assert(f.sbumpc() == L'1'); 45 assert(f.sbumpc() == L'2'); 46 assert(f.sbumpc() == L'3'); 47 } 48 remove("test.dat"); 49} 50