diff options
Diffstat (limited to 'test/std/input.output/file.streams/fstreams/fstream.cons')
4 files changed, 166 insertions, 0 deletions
diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp new file mode 100644 index 0000000000000..cfd5a031f0fc7 --- /dev/null +++ b/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_fstream(); + +#include <fstream> +#include <type_traits> + +int main() +{ + { + std::fstream fs; + } + { + std::wfstream fs; + } +} diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp new file mode 100644 index 0000000000000..d2ae3028606c2 --- /dev/null +++ b/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// basic_fstream(basic_fstream&& rhs); + +#include <fstream> +#include <cassert> +#include "platform_support.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + std::string temp = get_temp_file_name(); + { + std::fstream fso(temp, std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::fstream fs = move(fso); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); + { + std::wfstream fso(temp, std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + std::wfstream fs = move(fso); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp new file mode 100644 index 0000000000000..06a6b77943a62 --- /dev/null +++ b/test/std/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out); + +#include <fstream> +#include <cassert> +#include "platform_support.h" + +int main() +{ + std::string temp = get_temp_file_name(); + { + std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); + { + std::wfstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); +} diff --git a/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp new file mode 100644 index 0000000000000..4b0819f8af498 --- /dev/null +++ b/test/std/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <fstream> + +// template <class charT, class traits = char_traits<charT> > +// class basic_fstream + +// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out); + +#include <fstream> +#include <cassert> +#include "platform_support.h" + +int main() +{ + std::string temp = get_temp_file_name(); + { + std::fstream fs(temp, + std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); + { + std::wfstream fs(temp, + std::ios_base::in | std::ios_base::out + | std::ios_base::trunc); + double x = 0; + fs << 3.25; + fs.seekg(0); + fs >> x; + assert(x == 3.25); + } + std::remove(temp.c_str()); +} |