]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/path/construct/90634.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / path / construct / 90634.cc
1 // Copyright (C) 2019-2020 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // { dg-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
20
21 #include <filesystem>
22 #include <cstdlib>
23 #include <testsuite_hooks.h>
24
25 std::size_t bytes_allocated = 0;
26
27 void* operator new(std::size_t n)
28 {
29 bytes_allocated += n;
30 return std::malloc(n);
31 }
32
33 void operator delete(void* p) noexcept { std::free(p); }
34 #if __cpp_sized_deallocation
35 void operator delete(void* p, std::size_t) noexcept { std::free(p); }
36 #endif
37
38 void
39 test01()
40 {
41 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
42 std::wstring s0;
43 std::wstring s1 = L"/";
44 std::wstring s2 = L"///";
45 std::wstring s3 = L"file";
46 std::wstring s4 = L"C:";
47 std::wstring s5 = L"\\";
48 #else
49 std::string s0;
50 std::string s1 = "/";
51 std::string s2 = "///";
52 std::string s3 = "file";
53 std::string s4 = "C:";
54 std::string s5 = "\\";
55 #endif
56
57 using std::filesystem::path;
58
59 bytes_allocated = 0;
60 path p0 = std::move(s0);
61 VERIFY( bytes_allocated == 0 );
62 path p1 = std::move(s1);
63 VERIFY( bytes_allocated == 0 );
64 path p2 = std::move(s2);
65 VERIFY( bytes_allocated == 0 );
66 path p3 = std::move(s3);
67 VERIFY( bytes_allocated == 0 );
68 path p4 = std::move(s4);
69 VERIFY( bytes_allocated == 0 );
70 path p5 = std::move(s5);
71 VERIFY( bytes_allocated == 0 );
72 }
73
74 int
75 main()
76 {
77 test01();
78 }