]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/nowide/test/test_fs.cpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / libs / nowide / test / test_fs.cpp
CommitLineData
f67539c2
TL
1//
2// Copyright (c) 2015 Artyom Beilis (Tonkikh)
1e59de90 3// Copyright (c) 2021 Alexander Grund
f67539c2
TL
4//
5// Distributed under the Boost Software License, Version 1.0. (See
20effc67 6// accompanying file LICENSE or copy at
f67539c2
TL
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
1e59de90
TL
10#if defined(__GNUC__) && __GNUC__ >= 7
11#pragma GCC diagnostic ignored "-Wattributes"
12#endif
f67539c2
TL
13#include <boost/nowide/filesystem.hpp>
14
15#include <boost/nowide/convert.hpp>
16#include <boost/nowide/cstdio.hpp>
17#include <boost/nowide/fstream.hpp>
f67539c2 18#include "test.hpp"
1e59de90
TL
19#if defined(_MSC_VER)
20#pragma warning(disable : 4714) // function marked as __forceinline not inlined
21#endif
22#include <boost/filesystem/operations.hpp>
f67539c2 23
1e59de90 24// coverity [root_function]
20effc67 25void test_main(int, char** argv, char**)
f67539c2
TL
26{
27 boost::nowide::nowide_filesystem();
20effc67 28 const std::string prefix = argv[0];
f67539c2
TL
29 const std::string utf8_name =
30 prefix + "\xf0\x9d\x92\x9e-\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-\xE3\x82\x84\xE3\x81\x82.txt";
31
32 {
33 boost::nowide::ofstream f(utf8_name.c_str());
34 TEST(f);
35 f << "Test" << std::endl;
36 }
37
38 TEST(boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name)));
39 TEST(boost::filesystem::is_regular_file(utf8_name));
40
41 TEST(boost::nowide::remove(utf8_name.c_str()) == 0);
42
43 TEST(!boost::filesystem::is_regular_file(boost::nowide::widen(utf8_name)));
44 TEST(!boost::filesystem::is_regular_file(utf8_name));
45
46 const boost::filesystem::path path = utf8_name;
47 {
48 boost::nowide::ofstream f(path);
49 TEST(f);
50 f << "Test" << std::endl;
51 TEST(is_regular_file(path));
52 }
53 {
54 boost::nowide::ifstream f(path);
55 TEST(f);
56 std::string test;
57 f >> test;
58 TEST(test == "Test");
59 }
60 {
61 boost::nowide::fstream f(path);
62 TEST(f);
63 std::string test;
64 f >> test;
65 TEST(test == "Test");
66 }
67 boost::filesystem::remove(path);
68}