29#include <gtest/gtest.h>
37TEST(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());
54TEST(DebugFlagDeathTest, UniqueNames)
59 const std::string
expected =
"panic: panic condition !result.second "
60 "occurred: Flag FlagUniqueNamesTest already defined!\n";
66TEST(DebugFlagTest, IsFormat)
77TEST(DebugSimpleFlagTest, Enabled)
89 ASSERT_TRUE(!TRACING_ON || flag.
tracing());
95 ASSERT_TRUE(!TRACING_ON || flag.
tracing());
106TEST(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());
140TEST(DebugFlagTest, ConversionOperator)
145 ASSERT_EQ(flag, flag.
tracing());
147 ASSERT_EQ(flag, flag.
tracing());
155TEST(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());
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());
237TEST(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());
263TEST(DebugFlagTest, NoDumpDebugFlags)
277TEST(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");
static void globalEnable()
static void globalDisable()
bool isFormat() const
Checks whether this flag is a conventional debug flag, or a flag that modifies the way debug informat...
TEST(DebugFlagTest, NameDesc)
Test assignment of names and descriptions.
std::vector< SwitchingFiber * > expected({ &a, &b, &a, &a, &a, &b, &c, &a, &c, &c, &c })
bool changeFlag(const char *s, bool value)
Flag * findFlag(const std::string &name)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
void setDebugFlag(const char *string)
void clearDebugFlag(const char *string)
static void output(const char *filename)
void dumpDebugFlags(std::ostream &os)
thread_local GTestLogOutput gtestLogOutput