QMCPACK
test_output_manager.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
16 
17 namespace qmcplusplus
18 {
19 // redirect streams to stringstream for testing
20 static std::ostringstream summary_out;
21 static std::ostringstream app_out;
22 static std::ostringstream err_out;
23 static std::ostringstream debug_out;
24 
26 {
27  summary_out.str("");
28  app_out.str("");
29  err_out.str("");
30  debug_out.str("");
31 }
32 
34 {
40 }
41 
42 
43 TEST_CASE("OutputManager basic", "[utilities]")
44 {
46 
47  // Low verbosity
49  REQUIRE(om.isDebugActive() == false);
50  REQUIRE(om.isHighActive() == false);
51 
52  // High verbosity
54  REQUIRE(om.isDebugActive() == false);
55  REQUIRE(om.isHighActive() == true);
56 
57  // Debug verbosity
59  REQUIRE(om.isDebugActive() == true);
60  REQUIRE(om.isHighActive() == true);
61 }
62 
63 TEST_CASE("OutputManager output", "[utilities]")
64 {
66 
67  // Low verbosity
69 
70  app_summary() << "test1";
71  app_log() << "test2";
72  app_debug() << "test3";
73  app_error() << "test4";
74  REQUIRE(summary_out.str() == "test1");
75  REQUIRE(app_out.str() == "");
76  REQUIRE(debug_out.str() == "");
77  REQUIRE(err_out.str() == "ERROR test4");
78 
80 
81  // High verbosity
83 
84  app_summary() << "test5";
85  app_log() << "test6";
86  app_debug() << "test7";
87  app_error() << "test8";
88  REQUIRE(summary_out.str() == "test5");
89  REQUIRE(app_out.str() == "test6");
90  REQUIRE(debug_out.str() == "");
91  REQUIRE(err_out.str() == "ERROR test8");
92 
94 
95  // Debug verbosity
97 
98  app_summary() << "test9";
99  app_log() << "testA";
100  app_debug() << "testB";
101  app_error() << "testC";
102  REQUIRE(summary_out.str() == "test9");
103  REQUIRE(app_out.str() == "testA");
104  REQUIRE(debug_out.str() == "testB");
105  REQUIRE(err_out.str() == "ERROR testC");
106 }
107 
108 TEST_CASE("OutputManager pause", "[utilities]")
109 {
111 
113 
114  app_summary() << "test1";
115  app_log() << "test2";
116 
117  REQUIRE(summary_out.str() == "");
118  REQUIRE(app_out.str() == "");
119 
121 
123  app_summary() << "test3";
124  app_log() << "test4";
125 
126  REQUIRE(summary_out.str() == "test3");
127  REQUIRE(app_out.str() == "test4");
128 }
129 
130 
131 TEST_CASE("OutputManager shutoff", "[utilities]")
132 {
134 
136 
137  app_summary() << "test1";
138  app_log() << "test2";
139  app_error() << "test3";
140  app_debug() << "test4";
141 
142  REQUIRE(summary_out.str() == "");
143  REQUIRE(app_out.str() == "");
144  REQUIRE(err_out.str() == "");
145  REQUIRE(debug_out.str() == "");
146 }
147 
148 } // namespace qmcplusplus
void pause()
Pause the summary and log streams.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Declaration of OutputManager class.
bool isHighActive() const
Definition: OutputManager.h:47
static std::ostringstream app_out
InfoStream infoSummary
#define app_debug
Definition: OutputManager.h:75
InfoStream infoDebug
std::ostream & app_log()
Definition: OutputManager.h:65
void shutOff()
Permanently shut off all streams.
std::ostream & app_summary()
Definition: OutputManager.h:63
TEST_CASE("complex_helper", "[type_traits]")
std::ostream & app_error()
Definition: OutputManager.h:67
static std::ostringstream err_out
InfoStream infoLog
OutputManagerClass outputManager(Verbosity::HIGH)
void setStream(std::ostream *output_stream)
Definition: InfoStream.cpp:24
void resume()
Resume the summary and log streams.
REQUIRE(std::filesystem::exists(filename))
bool isDebugActive() const
Definition: OutputManager.h:45
InfoStream infoError
static std::ostringstream summary_out
void setVerbosity(Verbosity level)
static std::ostringstream debug_out