]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // |
2 | // Copyright (c) 2015 Artyom Beilis (Tonkikh) | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. (See | |
20effc67 | 5 | // accompanying file LICENSE or copy at |
f67539c2 TL |
6 | // http://www.boost.org/LICENSE_1_0.txt) |
7 | // | |
8 | ||
9 | #include <boost/nowide/filesystem.hpp> | |
10 | ||
11 | #include <boost/nowide/convert.hpp> | |
12 | #include <boost/nowide/cstdio.hpp> | |
13 | #include <boost/nowide/fstream.hpp> | |
14 | #include <boost/filesystem/operations.hpp> | |
15 | ||
16 | #include "test.hpp" | |
17 | ||
20effc67 | 18 | void test_main(int, char** argv, char**) |
f67539c2 TL |
19 | { |
20 | boost::nowide::nowide_filesystem(); | |
20effc67 | 21 | const std::string prefix = argv[0]; |
f67539c2 TL |
22 | const std::string utf8_name = |
23 | prefix + "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt"; | |
24 | ||
25 | { | |
26 | boost::nowide::ofstream f(utf8_name.c_str()); | |
27 | TEST(f); | |
28 | f << "Test" << std::endl; | |
29 | } | |
30 | ||
31 | TEST(boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name))); | |
32 | TEST(boost::filesystem::is_regular_file(utf8_name)); | |
33 | ||
34 | TEST(boost::nowide::remove(utf8_name.c_str()) == 0); | |
35 | ||
36 | TEST(!boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name))); | |
37 | TEST(!boost::filesystem::is_regular_file(utf8_name)); | |
38 | ||
39 | const boost::filesystem::path path = utf8_name; | |
40 | { | |
41 | boost::nowide::ofstream f(path); | |
42 | TEST(f); | |
43 | f << "Test" << std::endl; | |
44 | TEST(is_regular_file(path)); | |
45 | } | |
46 | { | |
47 | boost::nowide::ifstream f(path); | |
48 | TEST(f); | |
49 | std::string test; | |
50 | f >> test; | |
51 | TEST(test == "Test"); | |
52 | } | |
53 | { | |
54 | boost::nowide::fstream f(path); | |
55 | TEST(f); | |
56 | std::string test; | |
57 | f >> test; | |
58 | TEST(test == "Test"); | |
59 | } | |
60 | boost::filesystem::remove(path); | |
61 | } |