QMCPACK
test_infostream.cpp File Reference
+ Include dependency graph for test_infostream.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("InfoStream basic", "[utilities]")
 
 TEST_CASE ("InfoStream redirect to new stream", "[utilities]")
 
 TEST_CASE ("InfoStream redirect to file", "[utilities]")
 
 TEST_CASE ("InfoStream double pause", "[utilities]")
 
 TEST_CASE ("InfoStream shutOff", "[utilities]")
 
 TEST_CASE ("InfoStream operator", "[utilities]")
 

Function Documentation

◆ TEST_CASE() [1/6]

TEST_CASE ( "InfoStream basic"  ,
""  [utilities] 
)

Definition at line 22 of file test_infostream.cpp.

References InfoStream::getStream(), InfoStream::isActive(), InfoStream::pause(), qmcplusplus::REQUIRE(), and InfoStream::resume().

23 {
24  std::ostringstream out;
25  InfoStream info(&out);
26  info.getStream() << "test";
27  REQUIRE(out.str() == "test");
28  REQUIRE(info.isActive());
29 
30  info.pause();
31  info.getStream() << "empty";
32  REQUIRE(out.str() == "test");
33  REQUIRE(!info.isActive());
34 
35  info.resume();
36  info.getStream() << "second";
37  REQUIRE(out.str() == "testsecond");
38 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [2/6]

TEST_CASE ( "InfoStream redirect to new stream"  ,
""  [utilities] 
)

Definition at line 40 of file test_infostream.cpp.

References InfoStream::getStream(), InfoStream::redirectToSameStream(), and qmcplusplus::REQUIRE().

41 {
42  std::ostringstream out1;
43  std::ostringstream out2;
44  InfoStream info1(&out1);
45  InfoStream info2(&out2);
46 
47  info1.getStream() << "test1";
48  info2.getStream() << "test2";
49 
50  info1.redirectToSameStream(info2);
51  info1.getStream() << "test3";
52 
53  REQUIRE(out2.str() == "test2test3");
54  REQUIRE(out1.str() == "test1");
55 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [3/6]

TEST_CASE ( "InfoStream redirect to file"  ,
""  [utilities] 
)

Definition at line 57 of file test_infostream.cpp.

References InfoStream::flush(), InfoStream::getStream(), InfoStream::redirectToFile(), qmcplusplus::REQUIRE(), and qmcplusplus::Units::time::s.

58 {
59  std::ostringstream out;
60  InfoStream info(&out);
61  info.redirectToFile("test_infostream.log");
62  info.getStream() << "test";
63  info.flush();
64 
65  std::ifstream in("test_infostream.log");
66  std::string s;
67  in >> s;
68  REQUIRE(s == "test");
69 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [4/6]

TEST_CASE ( "InfoStream double pause"  ,
""  [utilities] 
)

Definition at line 71 of file test_infostream.cpp.

References InfoStream::getStream(), InfoStream::pause(), qmcplusplus::REQUIRE(), and InfoStream::resume().

72 {
73  std::ostringstream out;
74  InfoStream info(&out);
75  info.pause();
76  info.pause();
77  info.resume();
78  info.getStream() << "test";
79  REQUIRE(out.str() == "test");
80 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [5/6]

TEST_CASE ( "InfoStream shutOff"  ,
""  [utilities] 
)

Definition at line 82 of file test_infostream.cpp.

References InfoStream::getStream(), InfoStream::pause(), qmcplusplus::REQUIRE(), InfoStream::resume(), and InfoStream::shutOff().

83 {
84  std::ostringstream out;
85  InfoStream info(&out);
86  info.shutOff();
87  info.pause();
88  info.resume();
89  info.getStream() << "test";
90  REQUIRE(out.str() == "");
91 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [6/6]

TEST_CASE ( "InfoStream operator"  ,
""  [utilities] 
)

Definition at line 93 of file test_infostream.cpp.

References qmcplusplus::REQUIRE().

94 {
95  std::ostringstream out;
96  InfoStream info(&out);
97  info << "test";
98  info << 1;
99  REQUIRE(out.str() == "test1");
100 }
Interface to output streams.
Definition: InfoStream.h:28
REQUIRE(std::filesystem::exists(filename))