Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Unified Diff: mojo/public/tests/bindings_type_conversion_unittest.cc

Issue 105133002: Add array bounds assertion and improve type conversion for empty strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/bindings/lib/bindings_internal.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tests/bindings_type_conversion_unittest.cc
diff --git a/mojo/public/tests/bindings_type_conversion_unittest.cc b/mojo/public/tests/bindings_type_conversion_unittest.cc
index 01050faf7075f7f789d4c87939062433fc6a698f..6c41bb5c450adc158a68cabdd5667ca0d1c841dd 100644
--- a/mojo/public/tests/bindings_type_conversion_unittest.cc
+++ b/mojo/public/tests/bindings_type_conversion_unittest.cc
@@ -85,7 +85,21 @@ TEST_F(BindingsTypeConversionTest, String) {
TEST_F(BindingsTypeConversionTest, String_Null) {
String a;
+ EXPECT_TRUE(a.is_null());
EXPECT_EQ(std::string(), a.To<std::string>());
+
+ String b(static_cast<const char*>(NULL));
+ EXPECT_TRUE(b.is_null());
+}
+
+TEST_F(BindingsTypeConversionTest, String_Empty) {
+ AllocationScope scope;
+ String a = String::Builder(0).Finish();
+ EXPECT_EQ(std::string(), a.To<std::string>());
+
+ String b = std::string();
+ EXPECT_FALSE(b.is_null());
+ EXPECT_EQ(std::string(), b.To<std::string>());
}
TEST_F(BindingsTypeConversionTest, String_ShallowCopy) {
« no previous file with comments | « mojo/public/bindings/lib/bindings_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698