Skip to content

Commit e2ee676

Browse files
committed
CXX-196 CXX-155 Force construction of bool to deal with explicit operator bool on streams
(cherry picked from commit 9f28c08)
1 parent ccb3aa8 commit e2ee676

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/mongo/logger/rotatable_file_writer_test.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ namespace {
4949
RotatableFileWriter writer;
5050
RotatableFileWriter::Use writerUse(&writer);
5151
ASSERT_OK(writerUse.setFileName(logFileName, false));
52-
ASSERT_TRUE(writerUse.stream() << "Level 1 message." << std::endl);
53-
ASSERT_TRUE(writerUse.stream() << "Level 2 message." << std::endl);
52+
ASSERT_TRUE(bool(writerUse.stream() << "Level 1 message." << std::endl));
53+
ASSERT_TRUE(bool(writerUse.stream() << "Level 2 message." << std::endl));
5454
ASSERT_OK(writerUse.rotate(logFileNameRotated));
55-
ASSERT_TRUE(writerUse.stream() << "Level 3 message." << std::endl);
56-
ASSERT_TRUE(writerUse.stream() << "Level 4 message." << std::endl);
55+
ASSERT_TRUE(bool(writerUse.stream() << "Level 3 message." << std::endl));
56+
ASSERT_TRUE(bool(writerUse.stream() << "Level 4 message." << std::endl));
5757
}
5858

5959
{
6060
std::ifstream ifs(logFileNameRotated.c_str());
6161
ASSERT_TRUE(ifs.is_open());
6262
ASSERT_TRUE(ifs.good());
6363
std::string input;
64-
ASSERT_TRUE(std::getline(ifs, input));
64+
ASSERT_TRUE(bool(std::getline(ifs, input)));
6565
ASSERT_EQUALS(input, "Level 1 message.");
66-
ASSERT_TRUE(std::getline(ifs, input));
66+
ASSERT_TRUE(bool(std::getline(ifs, input)));
6767
ASSERT_EQUALS(input, "Level 2 message.");
6868
ASSERT_TRUE(std::getline(ifs, input).fail());
6969
ASSERT_TRUE(ifs.eof());
@@ -74,9 +74,9 @@ namespace {
7474
ASSERT_TRUE(ifs.is_open());
7575
ASSERT_TRUE(ifs.good());
7676
std::string input;
77-
ASSERT_TRUE(std::getline(ifs, input));
77+
ASSERT_TRUE(bool(std::getline(ifs, input)));
7878
ASSERT_EQUALS(input, "Level 3 message.");
79-
ASSERT_TRUE(std::getline(ifs, input));
79+
ASSERT_TRUE(bool(std::getline(ifs, input)));
8080
ASSERT_EQUALS(input, "Level 4 message.");
8181
ASSERT_TRUE(std::getline(ifs, input).fail());
8282
ASSERT_TRUE(ifs.eof());
@@ -86,22 +86,22 @@ namespace {
8686
RotatableFileWriter writer;
8787
RotatableFileWriter::Use writerUse(&writer);
8888
ASSERT_OK(writerUse.setFileName(logFileName, true));
89-
ASSERT_TRUE(writerUse.stream() << "Level 5 message." << std::endl);
90-
ASSERT_TRUE(writerUse.stream() << "Level 6 message." << std::endl);
89+
ASSERT_TRUE(bool(writerUse.stream() << "Level 5 message." << std::endl));
90+
ASSERT_TRUE(bool(writerUse.stream() << "Level 6 message." << std::endl));
9191
}
9292

9393
{
9494
std::ifstream ifs(logFileName.c_str());
9595
ASSERT_TRUE(ifs.is_open());
9696
ASSERT_TRUE(ifs.good());
9797
std::string input;
98-
ASSERT_TRUE(std::getline(ifs, input));
98+
ASSERT_TRUE(bool(std::getline(ifs, input)));
9999
ASSERT_EQUALS(input, "Level 3 message.");
100-
ASSERT_TRUE(std::getline(ifs, input));
100+
ASSERT_TRUE(bool(std::getline(ifs, input)));
101101
ASSERT_EQUALS(input, "Level 4 message.");
102102
ASSERT_FALSE(std::getline(ifs, input).fail());
103103
ASSERT_EQUALS(input, "Level 5 message.");
104-
ASSERT_TRUE(std::getline(ifs, input));
104+
ASSERT_TRUE(bool(std::getline(ifs, input)));
105105
ASSERT_EQUALS(input, "Level 6 message.");
106106
ASSERT_TRUE(std::getline(ifs, input).fail());
107107
ASSERT_TRUE(ifs.eof());
@@ -111,16 +111,16 @@ namespace {
111111
RotatableFileWriter writer;
112112
RotatableFileWriter::Use writerUse(&writer);
113113
ASSERT_OK(writerUse.setFileName(logFileName, false));
114-
ASSERT_TRUE(writerUse.stream() << "Level 7 message." << std::endl);
115-
ASSERT_TRUE(writerUse.stream() << "Level 8 message." << std::endl);
114+
ASSERT_TRUE(bool(writerUse.stream() << "Level 7 message." << std::endl));
115+
ASSERT_TRUE(bool(writerUse.stream() << "Level 8 message." << std::endl));
116116
}
117117

118118
{
119119
std::ifstream ifs(logFileName.c_str());
120120
ASSERT_TRUE(ifs.is_open());
121121
ASSERT_TRUE(ifs.good());
122122
std::string input;
123-
ASSERT_TRUE(std::getline(ifs, input));
123+
ASSERT_TRUE(bool(std::getline(ifs, input)));
124124
ASSERT_EQUALS(input, "Level 7 message.");
125125
ASSERT_FALSE(std::getline(ifs, input).fail());
126126
ASSERT_EQUALS(input, "Level 8 message.");

0 commit comments

Comments
 (0)