]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/filesystem/operations/copy_file.cc
1 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" }
19 // { dg-do run { target c++11 } }
20 // { dg-require-filesystem-ts "" }
22 // 15.4 Copy [fs.op.copy_file]
24 #include <experimental/filesystem>
26 #include <testsuite_fs.h>
27 #include <testsuite_hooks.h>
32 using std::experimental::filesystem::copy_options
;
35 auto from
= __gnu_test::nonexistent_path();
36 auto to
= __gnu_test::nonexistent_path();
38 // test non-existent file
39 bool b
= copy_file(from
, to
, ec
);
42 VERIFY( !exists(to
) );
45 std::ofstream
{from
.c_str()};
46 VERIFY( exists(from
) );
47 VERIFY( file_size(from
) == 0 );
49 b
= copy_file(from
, to
);
52 VERIFY( file_size(to
) == 0 );
54 VERIFY( !exists(to
) );
55 b
= copy_file(from
, to
, copy_options::none
, ec
);
59 VERIFY( file_size(to
) == 0 );
61 std::ofstream
{from
.c_str()} << "Hello, filesystem!";
62 VERIFY( file_size(from
) != 0 );
64 VERIFY( !exists(to
) );
65 b
= copy_file(from
, to
);
68 VERIFY( file_size(to
) == file_size(from
) );
70 VERIFY( !exists(to
) );
71 b
= copy_file(from
, to
);
75 VERIFY( file_size(to
) == file_size(from
) );