From 5a83710e371fe68a06e6e3876c6a2c8b820a8976 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 20 Dec 2014 01:40:03 +0000 Subject: Move test into test/std subdirectory. llvm-svn: 224658 --- .../fstreams/ofstream.members/open_string.pass.cpp | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp (limited to 'libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp') diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp new file mode 100644 index 00000000000..d54aa1824ab --- /dev/null +++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template > +// class basic_ofstream + +// void open(const string& s, ios_base::openmode mode = ios_base::out); + +#include +#include +#include "platform_support.h" + +int main() +{ + std::string temp = get_temp_file_name(); + { + std::ofstream fs; + assert(!fs.is_open()); + char c = 'a'; + fs << c; + assert(fs.fail()); + fs.open(temp); + assert(fs.is_open()); + fs << c; + } + { + std::ifstream fs(temp.c_str()); + char c = 0; + fs >> c; + assert(c == 'a'); + } + std::remove(temp.c_str()); + { + std::wofstream fs; + assert(!fs.is_open()); + wchar_t c = L'a'; + fs << c; + assert(fs.fail()); + fs.open(temp); + assert(fs.is_open()); + fs << c; + } + { + std::wifstream fs(temp.c_str()); + wchar_t c = 0; + fs >> c; + assert(c == L'a'); + } + std::remove(temp.c_str()); +} -- cgit v1.2.3