diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 04:15:50 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 04:15:50 +0000 |
commit | 43fa5b848147d846761fecbea0317331510dd287 (patch) | |
tree | eae5721b0ae1bd1fb4be7d93e66266a0b2b2beca /dbus/string_util_unittest.cc | |
parent | 44437a2af771d8302a128a38aa25953ce7eaa51f (diff) | |
download | chromium_src-43fa5b848147d846761fecbea0317331510dd287.zip chromium_src-43fa5b848147d846761fecbea0317331510dd287.tar.gz chromium_src-43fa5b848147d846761fecbea0317331510dd287.tar.bz2 |
Explicitly CHECK arguments in dbus::MessageWriter::AppendString/ObjectPath
Add dbus::IsStringValidObjectPath() and dbus::ObjectPath::IsValid()
BUG=129335
TEST=dbus_unittests
Review URL: https://chromiumcodereview.appspot.com/10502011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/string_util_unittest.cc')
-rw-r--r-- | dbus/string_util_unittest.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/dbus/string_util_unittest.cc b/dbus/string_util_unittest.cc new file mode 100644 index 0000000..76bdfcb --- /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)")); +} |