Debian Codegraph @

libstdc++-v3/testsuite/27_io/filesystem/path/construct/102592.cc

raw
1 // { dg-options "-fchar8_t" }
2 // { dg-do run { target c++17 } }
3
4 #include <filesystem>
5 #include <testsuite_hooks.h>
6 #include <testsuite_iterators.h>
7
8 using __gnu_test::input_iterator_wrapper;
9 using __gnu_test::input_container;
10
11 void test01()
12 {
13 const char8_t src[] = u8"/long/path/to/a/file/to/avoid/small/string";
14 input_container<const char8_t> c1(src); // includes null terminator
15 std::filesystem::path p1(c1.begin()); // read up to null terminator
16 VERIFY( p1.u8string() == src );
17
18 std::u8string_view sv = src;
19 input_container<const char8_t> c2(sv.data(), sv.data() + sv.size());
20 std::filesystem::path p2(c2.begin(), c2.end()); // PR libstdc++/102592
21 VERIFY( p2.u8string() == src );
22 VERIFY( p1 == p2 );
23 }
24
25 int main()
26 {
27 test01();
28 }