lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d4e4860 3/7: Define a default error prefix


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d4e4860 3/7: Define a default error prefix
Date: Thu, 9 Feb 2017 19:49:25 -0500 (EST)

branch: master
commit d4e4860a53bb47124241744de0ece4c091513c2e
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Define a default error prefix
    
    This provides a more robust way to reset error_prefix to its default.
---
 exit_codes.hpp      | 3 ++-
 test_main.cpp       | 4 +++-
 test_tools_test.cpp | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/exit_codes.hpp b/exit_codes.hpp
index 709bb83..b51794c 100644
--- a/exit_codes.hpp
+++ b/exit_codes.hpp
@@ -88,7 +88,8 @@ namespace lmi_test
     // (because this is the one header included by all unit-test files) to
     // write such declarations here.
 
-    extern std::string error_prefix;
+    extern std::string const default_error_prefix;
+    extern std::string               error_prefix;
 } // namespace lmi_test
 
 #endif // exit_codes_hpp
diff --git a/test_main.cpp b/test_main.cpp
index a796a3b..9b3aed1 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -85,11 +85,13 @@ namespace lmi_test
     };
   } // namespace test
 
+    std::string const default_error_prefix = "\n**** ";
+
     // Change this to test this testing library's facilities without
     // emitting this actual prefix, e.g., to force simulated errors.
     // Change it back to perform tests that are intended to pass,
     // e.g., tests to validate internal helpers such as whats_what().
-    std::string error_prefix = "\n**** ";
+    std::string error_prefix = default_error_prefix;
 
     std::ostream& error_stream()
     {
diff --git a/test_tools_test.cpp b/test_tools_test.cpp
index 33823cf..a86f2bc 100644
--- a/test_tools_test.cpp
+++ b/test_tools_test.cpp
@@ -104,7 +104,7 @@ int test_main(int, char*[])
 
     // The following tests, unlike those above, should not fail.
 
-    lmi_test::error_prefix = "\n**** ";
+    lmi_test::error_prefix = lmi_test::default_error_prefix;
 
     // Ensure that the anticipated and actually-thrown exceptions are
     // treated as equivalent even though the latter has an extra



reply via email to

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