summaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-internal-utils_test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2021-08-03 16:19:54 (GMT)
committerAndy Soffer <asoffer@google.com>2021-08-04 17:54:39 (GMT)
commit652ec31f9f53ab34af1257e5e2783d77e872ed45 (patch)
tree5e2b03cd82d06d80cfe1637642e133bac3abecbf /googlemock/test/gmock-internal-utils_test.cc
parentc22ce88775eaa364d085de7741a3625f3f0d5055 (diff)
downloadgoogletest-652ec31f9f53ab34af1257e5e2783d77e872ed45.zip
googletest-652ec31f9f53ab34af1257e5e2783d77e872ed45.tar.gz
googletest-652ec31f9f53ab34af1257e5e2783d77e872ed45.tar.bz2
Googletest export
Introduce a new matcher for unescaping Base-64 strings to gmock. PiperOrigin-RevId: 388471904
Diffstat (limited to 'googlemock/test/gmock-internal-utils_test.cc')
-rw-r--r--googlemock/test/gmock-internal-utils_test.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index bd7e335..b30eb8c 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -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