[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c28ef2c 5/9: Demonstrate substitutability of
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c28ef2c 5/9: Demonstrate substitutability of alert streams |
Date: |
Thu, 12 Jul 2018 13:12:58 -0400 (EDT) |
branch: master
commit c28ef2ce007cfb8fdf3ca129aceed238558e60e0
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Demonstrate substitutability of alert streams
It's obvious that this has to work, but it's helpful to show useful
techniques in unit tests.
---
alert_test.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/alert_test.cpp b/alert_test.cpp
index 120bbde..ffc6937 100644
--- a/alert_test.cpp
+++ b/alert_test.cpp
@@ -30,6 +30,13 @@
#include <stdexcept>
#include <vector>
+/// Demonstrate that alert streams can be used as arguments.
+
+void test_stream_arg(std::ostream& os, std::string const& s)
+{
+ os << s << std::flush;
+}
+
int test_main(int, char*[])
{
safely_show_message(" This message should appear on stderr.");
@@ -78,6 +85,13 @@ int test_main(int, char*[])
s = "Second simulated alarum.";
BOOST_TEST_THROW(alarum() << s << std::flush, std::runtime_error, s);
+ // The CLI handler should gobble this message.
+ test_stream_arg(status(), "This should not be printed.");
+
+ test_stream_arg(warning(), "This message should appear on stdout.");
+
+ BOOST_TEST_THROW(test_stream_arg(alarum(), "X"), std::runtime_error, "X");
+
return 0;
}
- [lmi-commits] [lmi] master updated (f5c7c0b -> 34bd9e1), Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master 8c11196 1/9: Work around a compiler warning, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master 899a163 3/9: Improve documentation, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master 8a68504 4/9: Call Reconcile() when reading all external input files, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master c28ef2c 5/9: Demonstrate substitutability of alert streams,
Greg Chicares <=
- [lmi-commits] [lmi] master 34bd9e1 9/9: Designate release candidate 20180712T1708Z, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master ed63bee 2/9: Enable GUI test to preserve 'configurable_settings.xml', Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master 2a0823a 8/9: Throw an exception if schema validation fails, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master d28f769 7/9: Improve certain error messages, Greg Chicares, 2018/07/12
- [lmi-commits] [lmi] master 7aaa73e 6/9: Validate external input more stringently, Greg Chicares, 2018/07/12