lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 8538df8 31/33: Improve unit tests and their d


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 8538df8 31/33: Improve unit tests and their documentation
Date: Mon, 3 May 2021 08:15:56 -0400 (EDT)

branch: master
commit 8538df8f13d632feec85bb244fdcae76ddf8501d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Improve unit tests and their documentation
---
 global_settings_test.cpp | 16 +++++++++-------
 path_utility.cpp         |  2 +-
 path_utility_test.cpp    |  7 ++++---
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/global_settings_test.cpp b/global_settings_test.cpp
index b3e0f63..8df9c43 100644
--- a/global_settings_test.cpp
+++ b/global_settings_test.cpp
@@ -37,37 +37,39 @@ void test_directory_exceptions()
 
     // Such string values must not be empty.
 
-    // "Data directory must not be empty."
     LMI_TEST_THROW
         (global_settings::instance().set_data_directory("")
         ,std::runtime_error
-        ,""
+        ,"Data directory must not be empty."
         );
 
     // Such string values must be validly-formed paths.
+    // BOOST !! Originally, this test detected that "?" is not a
+    // valid directory name, at least for msw. Should that useful
+    // validation be regained by adding code to lmi, now that
+    // std::filesystem doesn't validate paths semantically? If not,
+    // then this test adds no value.
 
     LMI_TEST_THROW
         (global_settings::instance().set_data_directory("?")
         ,std::runtime_error
-        ,""
+        ,"Data directory '?' not found."
         );
 
     // Such string values must name paths that exist in the filesystem.
 
-    // "Data directory 'UnLiKeLyNaMe' not found."
     LMI_TEST_THROW
         (global_settings::instance().set_data_directory("UnLiKeLyNaMe")
         ,std::runtime_error
-        ,""
+        ,"Data directory 'UnLiKeLyNaMe' not found."
         );
 
     // Such string values must name directories, not normal files.
 
-    // "Data directory 'global_settings.o' is not a directory."
     LMI_TEST_THROW
         (global_settings::instance().set_data_directory("global_settings.o")
         ,std::runtime_error
-        ,""
+        ,"Data directory 'global_settings.o' is not a directory."
         );
 }
 
diff --git a/path_utility.cpp b/path_utility.cpp
index f67d19a..97df7ca 100644
--- a/path_utility.cpp
+++ b/path_utility.cpp
@@ -269,7 +269,7 @@ fs::path serial_file_path
 ///
 /// A try-block is necessary because fs::remove() can throw. The
 /// postcondition is asserted explicitly at the end of the try-block
-/// because that fs::remove() documentation is still unclear:
+/// because the fs::remove() documentation is still unclear:
 ///   BOOST !! Is this still true of std::filesystem?
 /// apparently it mustn't fail without throwing, yet it doesn't throw
 /// on an operation that must fail, like removing a file that's locked
diff --git a/path_utility_test.cpp b/path_utility_test.cpp
index 7416080..2d9d7d2 100644
--- a/path_utility_test.cpp
+++ b/path_utility_test.cpp
@@ -304,11 +304,12 @@ void test_unique_filepath_with_normal_filenames()
     // These calls to std::remove() fail, at least with 'wine':
 //  LMI_TEST(0 == std::remove(tmp.c_str()));
 //  LMI_TEST(0 == std::remove(tmpdir.string().c_str()));
-    // They return nonzero, and do not remove the directory. The
+    // They return nonzero, and do not remove the directory. (The
     // reason is that the msw C library's remove() function doesn't
     // delete directories; it sets errno to 13, which means EACCESS,
-    // and _doserrno to 5, which might mean EIO. The std::filesystem::remove()
-    // specification in C++17 (N4659) [30.10.15.30] says:
+    // and _doserrno to 5, which might mean EIO.) Therefore,
+    // instead of std::remove(), use std::filesystem::remove(),
+    // whose effect in C++20 (N4861) [fs.op.remove] is that
     //   "the file p is removed as if by POSIX remove()".
     // Therefore, use the filesystem function to remove the directory:
     fs::remove(tmpdir);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]