Googletest export
Introduce a new matcher for unescaping Base-64 strings to gmock. PiperOrigin-RevId: 388471904
This commit is contained in:
@@ -716,6 +716,46 @@ TEST(FunctionTest, LongArgumentList) {
|
||||
F::MakeResultIgnoredValue>::value));
|
||||
}
|
||||
|
||||
TEST(Base64Unescape, InvalidString) {
|
||||
std::string unescaped;
|
||||
EXPECT_FALSE(Base64Unescape("(invalid)", &unescaped));
|
||||
}
|
||||
|
||||
TEST(Base64Unescape, ShortString) {
|
||||
std::string unescaped;
|
||||
EXPECT_TRUE(Base64Unescape("SGVsbG8gd29ybGQh", &unescaped));
|
||||
EXPECT_EQ("Hello world!", unescaped);
|
||||
}
|
||||
|
||||
TEST(Base64Unescape, ShortStringWithPadding) {
|
||||
std::string unescaped;
|
||||
EXPECT_TRUE(Base64Unescape("SGVsbG8gd29ybGQ=", &unescaped));
|
||||
EXPECT_EQ("Hello world", unescaped);
|
||||
}
|
||||
|
||||
TEST(Base64Unescape, ShortStringWithoutPadding) {
|
||||
std::string unescaped;
|
||||
EXPECT_TRUE(Base64Unescape("SGVsbG8gd29ybGQ", &unescaped));
|
||||
EXPECT_EQ("Hello world", unescaped);
|
||||
}
|
||||
|
||||
TEST(Base64Unescape, LongStringWithWhiteSpaces) {
|
||||
std::string escaped =
|
||||
R"(TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz
|
||||
IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg
|
||||
dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu
|
||||
dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo
|
||||
ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=)";
|
||||
std::string expected =
|
||||
"Man is distinguished, not only by his reason, but by this singular "
|
||||
"passion from other animals, which is a lust of the mind, that by a "
|
||||
"perseverance of delight in the continued and indefatigable generation "
|
||||
"of knowledge, exceeds the short vehemence of any carnal pleasure.";
|
||||
std::string unescaped;
|
||||
EXPECT_TRUE(Base64Unescape(escaped, &unescaped));
|
||||
EXPECT_EQ(expected, unescaped);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
|
||||
Reference in New Issue
Block a user