29 #include <gtest/gtest.h>
37 TEST(DebugFlagTest, NameDesc)
40 EXPECT_EQ(
"FlagNameDescTestKidA", flag_a.
name());
41 EXPECT_EQ(
"Kid A", flag_a.
desc());
44 EXPECT_EQ(
"FlagNameDescTestKidB", flag_b.
name());
45 EXPECT_EQ(
"Kid B", flag_b.
desc());
49 EXPECT_EQ(
"FlagNameDescTest", compound_flag.name());
50 EXPECT_EQ(
"Compound Flag", compound_flag.desc());
54 TEST(DebugFlagDeathTest, UniqueNames)
59 const std::string
expected =
"panic: panic condition !result.second "
60 "occurred: Flag FlagUniqueNamesTest already defined!\n";
66 TEST(DebugFlagTest, IsFormat)
77 TEST(DebugSimpleFlagTest, Enabled)
89 ASSERT_TRUE(!TRACING_ON || flag.
tracing());
95 ASSERT_TRUE(!TRACING_ON || flag.
tracing());
106 TEST(DebugCompoundFlagTest, Enabled)
115 ASSERT_FALSE(flag.tracing());
119 ASSERT_FALSE(flag_a.
tracing());
120 ASSERT_FALSE(flag_b.
tracing());
121 ASSERT_FALSE(flag.tracing());
123 for (
auto &kid : flag.kids()) {
124 ASSERT_TRUE(!TRACING_ON || kid->tracing());
126 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
127 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
131 for (
auto &kid : flag.kids()) {
132 ASSERT_FALSE(kid->tracing());
134 ASSERT_FALSE(flag_a.
tracing());
135 ASSERT_FALSE(flag_b.
tracing());
136 ASSERT_FALSE(flag.tracing());
140 TEST(DebugFlagTest, ConversionOperator)
145 ASSERT_EQ(flag, flag.
tracing());
147 ASSERT_EQ(flag, flag.
tracing());
155 TEST(DebugCompoundFlagTest, EnabledKids)
164 ASSERT_FALSE(flag_a.
tracing());
165 ASSERT_FALSE(flag_b.
tracing());
166 ASSERT_FALSE(flag.tracing());
168 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
169 ASSERT_FALSE(flag_b.
tracing());
170 ASSERT_FALSE(flag.tracing());
173 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
174 ASSERT_FALSE(flag_b.
tracing());
175 ASSERT_FALSE(flag.tracing());
177 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
178 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
182 ASSERT_FALSE(flag_a.
tracing());
183 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
184 ASSERT_FALSE(flag.tracing());
198 ASSERT_FALSE(flag_a.
tracing());
200 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
202 ASSERT_FALSE(flag_b.
tracing());
204 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
211 TEST(DebugFlagTest, ChangeFlag)
219 ASSERT_FALSE(flag_a.
tracing());
221 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
223 ASSERT_FALSE(flag_a.
tracing());
226 ASSERT_FALSE(flag_b.
tracing());
228 ASSERT_FALSE(flag_b.
tracing());
230 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
237 TEST(DebugFlagTest, SetClearDebugFlag)
244 ASSERT_FALSE(flag_a.
tracing());
246 ASSERT_TRUE(!TRACING_ON || flag_a.
tracing());
248 ASSERT_FALSE(flag_a.
tracing());
251 ASSERT_FALSE(flag_b.
tracing());
253 ASSERT_FALSE(flag_b.
tracing());
255 ASSERT_TRUE(!TRACING_ON || flag_b.
tracing());
263 TEST(DebugFlagTest, NoDumpDebugFlags)
277 TEST(DebugFlagTest, DumpDebugFlags)
291 ASSERT_FALSE(flag_a.
tracing());
292 ASSERT_FALSE(flag_b.
tracing());
293 ASSERT_FALSE(flag_c.
tracing());
294 ASSERT_FALSE(flag_d.
tracing());
295 ASSERT_FALSE(flag_e.
tracing());
298 compound_flag_b.enable();
302 std::ostringstream
os;
305 EXPECT_EQ(
output,
"FlagDumpDebugFlagTestA\nFlagDumpDebugFlagTestC\n" \
306 "FlagDumpDebugFlagTestE\n");