20 using namespace folly;
21 using std::make_shared;
23 TEST(PrintfTest, printfStyleMacros) {
25 Logger logger{&db,
"test"};
28 auto handler = make_shared<TestLogHandler>();
33 Logger foobar{&db,
"test.foo.bar"};
34 Logger footest{&db,
"test.foo.test"};
35 Logger footest1234{&db,
"test.foo.test.1234"};
36 Logger other{&db,
"test.other"};
45 FB_LOGC(other,
DBG0,
"this should be discarded: %d", 5);
49 bool argumentEvaluated =
false;
51 argumentEvaluated =
true;
54 FB_LOGC(foobar,
DBG3,
"discarded message: %d", getValue());
57 FB_LOGC(foobar,
DBG1,
"this message should pass: %d", getValue());
68 FB_LOGC(foobar,
DBG1,
"no actual format arguments");
75 xlogCategory->addHandler(
handler);
78 argumentEvaluated =
false;
79 XLOGC(
DBG9,
"failing log check: %d", getValue());
82 XLOGC(
DBG5,
"passing log: %03d", getValue());
99 argumentEvaluated =
false;
100 XLOGC_IF(
DBG1,
true,
"xlog format string %d", getValue());
105 argumentEvaluated =
false;
106 XLOGC_IF(
DBG1,
false,
"xlog format string %d", getValue());
112 std::array<bool, 2> conds = {{
false,
true}};
113 for (
unsigned i = 0;
i < conds.size();
i++) {
114 for (
unsigned j = 0; j < conds.size(); j++) {
115 argumentEvaluated =
false;
117 DBG1, conds[
i] && conds[j],
"testing conditional %d", getValue());
120 if (conds[
i] && conds[j]) {
126 argumentEvaluated =
false;
128 DBG1, conds[
i] || conds[j],
"testing conditional %d", getValue());
131 if (conds[
i] || conds[j]) {
147 XLOGC_IF(
DBG1, 0x6 | 0x2 ?
true :
false,
"More conditional 3");
151 XLOGC_IF(
DBG1, 0x6 | 0x2 ?
true :
false,
"More conditional 3");
155 XLOGC_IF(
DBG1, 0x3 & 0x4 ?
true :
false,
"More conditional 4");
159 XLOGC_IF(
DBG1,
false ?
true :
false,
"More conditional 5");
164 FB_LOGC(footest1234,
ERR,
"width overflow: %999999999999999999999d", 5);
167 "error formatting printf-style log message: " 168 "width overflow: %999999999999999999999d",
static struct message messages[5]
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
#define XLOGC_IF(level, cond, fmt,...)
—— Concurrent Priority Queue Implementation ——
void handler(int, siginfo_t *, void *)
LogCategory * getCategory() const
#define EXPECT_TRUE(condition)
#define XLOG_GET_CATEGORY()
#define XLOGC(level, fmt,...)
#define EXPECT_FALSE(condition)
#define FB_LOGC(logger, level, fmt,...)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
constexpr detail::First first