| 1884 | // copy_file_tests ------------------------------------------------------------------// |
| 1885 | |
| 1886 | void copy_file_tests(const fs::path& f1x, const fs::path& d1x) |
| 1887 | { |
| 1888 | cout << "copy_file_tests..." << endl; |
| 1889 | |
| 1890 | BOOST_TEST(fs::exists(f1x)); |
| 1891 | fs::remove(d1x / "f2"); // remove possible residue from prior testing |
| 1892 | BOOST_TEST(fs::exists(d1x)); |
| 1893 | BOOST_TEST(!fs::exists(d1x / "f2")); |
| 1894 | cout << " copy " << f1x << " to " << d1x / "f2" << endl; |
| 1895 | bool file_copied = fs::copy_file(f1x, d1x / "f2"); |
| 1896 | cout << " copy complete" << endl; |
| 1897 | BOOST_TEST(file_copied); |
| 1898 | BOOST_TEST(fs::exists(f1x)); |
| 1899 | BOOST_TEST(fs::exists(d1x / "f2")); |
| 1900 | BOOST_TEST(!fs::is_directory(d1x / "f2")); |
| 1901 | verify_file(d1x / "f2", "file-f1"); |
| 1902 | |
| 1903 | bool copy_ex_ok = false; |
| 1904 | file_copied = false; |
| 1905 | try |
| 1906 | { |
| 1907 | file_copied = fs::copy_file(f1x, d1x / "f2"); |
| 1908 | } |
| 1909 | catch (const fs::filesystem_error&) |
| 1910 | { |
| 1911 | copy_ex_ok = true; |
| 1912 | } |
| 1913 | BOOST_TEST(copy_ex_ok); |
| 1914 | BOOST_TEST(!file_copied); |
| 1915 | |
| 1916 | file_copied = false; |
| 1917 | copy_ex_ok = false; |
| 1918 | try |
| 1919 | { |
| 1920 | file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::none); |
| 1921 | } |
| 1922 | catch (const fs::filesystem_error&) |
| 1923 | { |
| 1924 | copy_ex_ok = true; |
| 1925 | } |
| 1926 | BOOST_TEST(copy_ex_ok); |
| 1927 | BOOST_TEST(!file_copied); |
| 1928 | |
| 1929 | fs::remove(d1x / "f2"); |
| 1930 | create_file(d1x / "f2", "1234567890"); |
| 1931 | BOOST_TEST_EQ(fs::file_size(d1x / "f2"), 10U); |
| 1932 | file_copied = false; |
| 1933 | copy_ex_ok = true; |
| 1934 | try |
| 1935 | { |
| 1936 | file_copied = fs::copy_file(f1x, d1x / "f2", fs::copy_options::skip_existing); |
| 1937 | } |
| 1938 | catch (const fs::filesystem_error&) |
| 1939 | { |
| 1940 | copy_ex_ok = false; |
| 1941 | } |
| 1942 | BOOST_TEST(copy_ex_ok); |
| 1943 | BOOST_TEST(!file_copied); |
no test coverage detected