[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);
- [lmi-commits] [lmi] master 9235f33 16/33: Avoid implicit conversion to fs::path, (continued)
- [lmi-commits] [lmi] master 9235f33 16/33: Avoid implicit conversion to fs::path, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 4ab2c4e 20/33: Further improve modify_directory() documentation, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master b64436f 19/33: Improve modify_directory() documentation and tests, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 0e3d61a 21/33: Rework modify_directory() documentation; augment unit test, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 40096c3 24/33: Conserve 70-character comment width, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 4473403 29/33: Improve output spacing, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master bc805ad 28/33: Augment path-validation unit test, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 6fd9f69 32/33: Remove the last occurrence of /name.check/, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 0c2d6b4 30/33: Revert "Revert "Trap exceptions from filesystem library"", Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master bfa1255 27/33: Enable some tests that were conditionally suppressed, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 8538df8 31/33: Improve unit tests and their documentation,
Greg Chicares <=
- [lmi-commits] [lmi] master 6ddb0fa 25/33: Rework a 'wine' workaround again, Greg Chicares, 2021/05/03
- [lmi-commits] [lmi] master 0296ac4 33/33: Deboostify still more, Greg Chicares, 2021/05/03