[libcxx] r295390 - add tests for ENAMETOOLONG

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 17:00:37 PST 2017


Author: ericwf
Date: Thu Feb 16 19:00:37 2017
New Revision: 295390

URL: http://llvm.org/viewvc/llvm-project?rev=295390&view=rev
Log:
add tests for ENAMETOOLONG

Modified:
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
    libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp?rev=295390&r1=295389&r2=295390&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp Thu Feb 16 19:00:37 2017
@@ -85,4 +85,13 @@ TEST_CASE(test_exists_fails)
     TEST_CHECK_THROW(filesystem_error, exists(file));
 }
 
+TEST_CASE(test_name_too_long) {
+    std::string long_name(2500, 'a');
+    const path file(long_name);
+
+    std::error_code ec;
+    TEST_CHECK(exists(file, ec) == false);
+    TEST_CHECK(ec);
+}
+
 TEST_SUITE_END()

Modified: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp?rev=295390&r1=295389&r2=295390&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp Thu Feb 16 19:00:37 2017
@@ -65,29 +65,36 @@ TEST_CASE(test_status_cannot_resolve)
 
     const std::error_code set_ec =
         std::make_error_code(std::errc::address_in_use);
-    const std::error_code expect_ec =
+    const std::error_code perm_ec =
         std::make_error_code(std::errc::permission_denied);
+    const std::error_code name_too_long_ec =
+        std::make_error_code(std::errc::filename_too_long);
 
-    const path cases[] = {
-        file, sym
+    struct TestCase {
+      path p;
+      std::error_code expect_ec;
+    } const TestCases[] = {
+      {file, perm_ec},
+      {sym, perm_ec},
+      {path(std::string(2500, 'a')), name_too_long_ec}
     };
-    for (auto& p : cases)
+    for (auto& TC : TestCases)
     {
         { // test non-throwing case
             std::error_code ec = set_ec;
-            file_status st = status(p, ec);
-            TEST_CHECK(ec == expect_ec);
+            file_status st = status(TC.p, ec);
+            TEST_CHECK(ec == TC.expect_ec);
             TEST_CHECK(st.type() == file_type::none);
             TEST_CHECK(st.permissions() == perms::unknown);
         }
 #ifndef TEST_HAS_NO_EXCEPTIONS
         { // test throwing case
             try {
-                status(p);
+                status(TC.p);
             } catch (filesystem_error const& err) {
-                TEST_CHECK(err.path1() == p);
+                TEST_CHECK(err.path1() == TC.p);
                 TEST_CHECK(err.path2() == "");
-                TEST_CHECK(err.code() == expect_ec);
+                TEST_CHECK(err.code() == TC.expect_ec);
             }
         }
 #endif




More information about the cfe-commits mailing list