21 const void* MakeItem(
size_t v) {
22 return reinterpret_cast<const void*
>(v);
30 exp.
Record(MakeItem(1),
"first explanation");
31 exp.
Record(MakeItem(1),
"second explanation");
32 exp.
Record(MakeItem(2),
"third explanation");
33 exp.
Record(MakeItem(2),
"fourth %s",
"explanation");
35 std::vector<std::string> list;
38 ASSERT_TRUE(list.empty());
41 ASSERT_EQ(2u, list.size());
42 EXPECT_EQ(list[0],
"first explanation");
43 EXPECT_EQ(list[1],
"second explanation");
46 ASSERT_EQ(4u, list.size());
47 EXPECT_EQ(list[0],
"first explanation");
48 EXPECT_EQ(list[1],
"second explanation");
49 EXPECT_EQ(list[2],
"third explanation");
50 EXPECT_EQ(list[3],
"fourth explanation");
57 exp.
Record(MakeItem(1),
"first explanation");
58 exp.
Record(MakeItem(1),
"second explanation");
59 exp.
Record(MakeItem(2),
"third explanation");
60 exp.
Record(MakeItem(2),
"fourth %s",
"explanation");
62 std::vector<std::string> list;
65 ASSERT_TRUE(list.empty());
68 ASSERT_EQ(2u, list.size());
69 EXPECT_EQ(list[0],
"first explanation");
70 EXPECT_EQ(list[1],
"second explanation");
73 ASSERT_EQ(4u, list.size());
74 EXPECT_EQ(list[0],
"first explanation");
75 EXPECT_EQ(list[1],
"second explanation");
76 EXPECT_EQ(list[2],
"third explanation");
77 EXPECT_EQ(list[3],
"fourth explanation");
83 exp.
Record(MakeItem(1),
"first explanation");
84 exp.
Record(MakeItem(1),
"second explanation");
85 exp.
Record(MakeItem(2),
"third explanation");
86 exp.
Record(MakeItem(2),
"fourth %s",
"explanation");
88 std::vector<std::string> list;
90 ASSERT_TRUE(list.empty());
93 ASSERT_TRUE(list.empty());
96 ASSERT_TRUE(list.empty());
TEST(Explanations, Explanations)
A class used to record a list of explanation strings associated with a given 'item' pointer.
void LookupAndAppend(const void *item, std::vector< std::string > *out)
Lookup the explanations recorded for |item|, and append them to |*out|, if any.
void Record(const void *item, const char *fmt,...)
Record an explanation for |item| if this instance is enabled.
Convenience wrapper for an Explanations pointer, which can be null if no explanations need to be reco...
void Record(const void *item, const char *fmt,...)
void LookupAndAppend(const void *item, std::vector< std::string > *out)