OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "dbus/string_util.h" | 5 #include "dbus/string_util.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
| 8 namespace dbus { |
| 9 |
8 TEST(StringUtilTest, IsValidObjectPath) { | 10 TEST(StringUtilTest, IsValidObjectPath) { |
9 EXPECT_TRUE(dbus::IsValidObjectPath("/")); | 11 EXPECT_TRUE(IsValidObjectPath("/")); |
10 EXPECT_TRUE(dbus::IsValidObjectPath("/foo/bar")); | 12 EXPECT_TRUE(IsValidObjectPath("/foo/bar")); |
11 EXPECT_TRUE(dbus::IsValidObjectPath("/hoge_fuga/piyo123")); | 13 EXPECT_TRUE(IsValidObjectPath("/hoge_fuga/piyo123")); |
12 // Empty string. | 14 // Empty string. |
13 EXPECT_FALSE(dbus::IsValidObjectPath(std::string())); | 15 EXPECT_FALSE(IsValidObjectPath(std::string())); |
14 // Emptyr elemnt. | 16 // Empty element. |
15 EXPECT_FALSE(dbus::IsValidObjectPath("//")); | 17 EXPECT_FALSE(IsValidObjectPath("//")); |
16 EXPECT_FALSE(dbus::IsValidObjectPath("/foo//bar")); | 18 EXPECT_FALSE(IsValidObjectPath("/foo//bar")); |
17 EXPECT_FALSE(dbus::IsValidObjectPath("/foo///bar")); | 19 EXPECT_FALSE(IsValidObjectPath("/foo///bar")); |
18 // Trailing '/'. | 20 // Trailing '/'. |
19 EXPECT_FALSE(dbus::IsValidObjectPath("/foo/")); | 21 EXPECT_FALSE(IsValidObjectPath("/foo/")); |
20 EXPECT_FALSE(dbus::IsValidObjectPath("/foo/bar/")); | 22 EXPECT_FALSE(IsValidObjectPath("/foo/bar/")); |
21 // Not beginning with '/'. | 23 // Not beginning with '/'. |
22 EXPECT_FALSE(dbus::IsValidObjectPath("foo/bar")); | 24 EXPECT_FALSE(IsValidObjectPath("foo/bar")); |
23 // Invalid characters. | 25 // Invalid characters. |
24 EXPECT_FALSE(dbus::IsValidObjectPath("/foo.bar")); | 26 EXPECT_FALSE(IsValidObjectPath("/foo.bar")); |
25 EXPECT_FALSE(dbus::IsValidObjectPath("/foo/*")); | 27 EXPECT_FALSE(IsValidObjectPath("/foo/*")); |
26 EXPECT_FALSE(dbus::IsValidObjectPath("/foo/bar(1)")); | 28 EXPECT_FALSE(IsValidObjectPath("/foo/bar(1)")); |
27 } | 29 } |
| 30 |
| 31 } // namespace dbus |
OLD | NEW |