forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_util_unittest.cc
31 lines (27 loc) · 1.03 KB
/
string_util_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// 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"
namespace dbus {
TEST(StringUtilTest, IsValidObjectPath) {
EXPECT_TRUE(IsValidObjectPath("/"));
EXPECT_TRUE(IsValidObjectPath("/foo/bar"));
EXPECT_TRUE(IsValidObjectPath("/hoge_fuga/piyo123"));
// Empty string.
EXPECT_FALSE(IsValidObjectPath(std::string()));
// Empty element.
EXPECT_FALSE(IsValidObjectPath("//"));
EXPECT_FALSE(IsValidObjectPath("/foo//bar"));
EXPECT_FALSE(IsValidObjectPath("/foo///bar"));
// Trailing '/'.
EXPECT_FALSE(IsValidObjectPath("/foo/"));
EXPECT_FALSE(IsValidObjectPath("/foo/bar/"));
// Not beginning with '/'.
EXPECT_FALSE(IsValidObjectPath("foo/bar"));
// Invalid characters.
EXPECT_FALSE(IsValidObjectPath("/foo.bar"));
EXPECT_FALSE(IsValidObjectPath("/foo/*"));
EXPECT_FALSE(IsValidObjectPath("/foo/bar(1)"));
}
} // namespace dbus