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

Unified Diff: dbus/string_util_unittest.cc

Issue 10502011: Explicitly CHECK arguments in dbus::MessageWriter::AppendString/ObjectPath (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix wording Created 8 years, 7 months 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
« dbus/string_util.cc ('K') | « dbus/string_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/string_util_unittest.cc
diff --git a/dbus/string_util_unittest.cc b/dbus/string_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c03ab2c5c3266ac9c33ca39530daf7e8e338a261
--- /dev/null
+++ b/dbus/string_util_unittest.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "dbus/string_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(StringUtilTest, IsStringValidObjectPath) {
+ EXPECT_TRUE(dbus::IsStringValidObjectPath("/"));
+ EXPECT_TRUE(dbus::IsStringValidObjectPath("/foo/bar"));
+ EXPECT_TRUE(dbus::IsStringValidObjectPath("/hoge_fuga/piyo123"));
+ // Empty string.
+ EXPECT_FALSE(dbus::IsStringValidObjectPath(""));
+ // Emptyr elemnt.
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("//"));
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo//bar"));
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo///bar"));
+ // Trailing '/'.
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo/"));
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo/bar/"));
+ // Not beginning with '/'.
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("foo/bar"));
+ // Invalid characters.
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo.bar"));
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo/*"));
+ EXPECT_FALSE(dbus::IsStringValidObjectPath("/foo/bar(1)"));
+}
« dbus/string_util.cc ('K') | « dbus/string_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698