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..76bdfcbd2bdc56ad22d5550ce43e0cec7cc98c6c |
--- /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, IsValidObjectPath) { |
+ EXPECT_TRUE(dbus::IsValidObjectPath("/")); |
+ EXPECT_TRUE(dbus::IsValidObjectPath("/foo/bar")); |
+ EXPECT_TRUE(dbus::IsValidObjectPath("/hoge_fuga/piyo123")); |
+ // Empty string. |
+ EXPECT_FALSE(dbus::IsValidObjectPath("")); |
+ // Emptyr elemnt. |
+ EXPECT_FALSE(dbus::IsValidObjectPath("//")); |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo//bar")); |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo///bar")); |
+ // Trailing '/'. |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo/")); |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo/bar/")); |
+ // Not beginning with '/'. |
+ EXPECT_FALSE(dbus::IsValidObjectPath("foo/bar")); |
+ // Invalid characters. |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo.bar")); |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo/*")); |
+ EXPECT_FALSE(dbus::IsValidObjectPath("/foo/bar(1)")); |
+} |