summaryrefslogtreecommitdiffstats
path: root/tools/gn/pattern_unittest.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-30 10:17:07 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-30 10:17:07 +0000
commit96ea63d0d101ebbdbb08f79a80f3fa38bfb27ced (patch)
treef33c8f6fa3ae9fbba0178ba0cbf4f291fd3ec11e /tools/gn/pattern_unittest.cc
parentfb68e6c9f20785ccd0024f14b09c200060931953 (diff)
downloadchromium_src-96ea63d0d101ebbdbb08f79a80f3fa38bfb27ced.zip
chromium_src-96ea63d0d101ebbdbb08f79a80f3fa38bfb27ced.tar.gz
chromium_src-96ea63d0d101ebbdbb08f79a80f3fa38bfb27ced.tar.bz2
Revert 214325 "Revert 214254 "Add initial prototype for the GN m..."
The issue was already fixed :) > Revert 214254 "Add initial prototype for the GN meta-buildsystem." > > It broke the check_licenses step on Android (see http://build.chromium.org/p/chromium.linux/builders/Android%20Builder%20%28dbg%29/builds/39904/steps/check_licenses/logs/stdio): > > @@@BUILD_STEP check_licenses@@@ > > /b/build/slave/Android_Builder__dbg_/build/src/android_webview/tools/webview_licenses.py scan > Got LicenseError "missing README.chromium or licenses.py SPECIAL_CASES entry" while scanning tools/gn/secondary/base/third_party/dynamic_annotations > Got LicenseError "missing README.chromium or licenses.py SPECIAL_CASES entry" while scanning tools/gn/secondary/third_party/modp_b64 > < /b/build/slave/Android_Builder__dbg_/build/src/android_webview/tools/webview_licenses.py scan > ERROR: process exited with code 2 > @@@STEP_FAILURE@@@ > > > > Add initial prototype for the GN meta-buildsystem. > > > > This is currently not hooked into the build. To build, add a reference to the > > gn.gyp file to build/all.gyp > > > > R=darin@chromium.org, scottmg@chromium.org > > > > Review URL: https://codereview.chromium.org/21114002 > > TBR=brettw@chromium.org > > Review URL: https://codereview.chromium.org/21084010 TBR=bauerb@chromium.org Review URL: https://codereview.chromium.org/21204003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/pattern_unittest.cc')
-rw-r--r--tools/gn/pattern_unittest.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/gn/pattern_unittest.cc b/tools/gn/pattern_unittest.cc
new file mode 100644
index 0000000..e9ffea6
--- /dev/null
+++ b/tools/gn/pattern_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 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 "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/pattern.h"
+
+namespace {
+
+struct Case {
+ const char* pattern;
+ const char* candidate;
+ bool expected_match;
+};
+
+} // namespace
+
+TEST(Pattern, Matches) {
+ Case pattern_cases[] = {
+ // Empty pattern matches only empty string.
+ { "", "", true },
+ { "", "foo", false },
+ // Exact matches.
+ { "foo", "foo", true },
+ { "foo", "bar", false },
+ // Path boundaries.
+ { "\\b", "", true },
+ { "\\b", "/", true },
+ { "\\b\\b", "/", true },
+ { "\\b\\b\\b", "", false },
+ { "\\b\\b\\b", "/", true },
+ { "\\b", "//", false },
+ { "\\bfoo\\b", "foo", true },
+ { "\\bfoo\\b", "/foo/", true },
+ { "\\b\\bfoo", "/foo", true },
+ // *
+ { "*", "", true },
+ { "*", "foo", true },
+ { "*foo", "foo", true },
+ { "*foo", "gagafoo", true },
+ { "*foo", "gagafoob", false },
+ { "foo*bar", "foobar", true },
+ { "foo*bar", "foo-bar", true },
+ { "foo*bar", "foolalalalabar", true },
+ { "foo*bar", "foolalalalabaz", false },
+ { "*a*b*c*d*", "abcd", true },
+ { "*a*b*c*d*", "1a2b3c4d5", true },
+ { "*a*b*c*d*", "1a2b3c45", false },
+ { "*\\bfoo\\b*", "foo", true },
+ { "*\\bfoo\\b*", "/foo/", true },
+ { "*\\bfoo\\b*", "foob", false },
+ { "*\\bfoo\\b*", "lala/foo/bar/baz", true },
+ };
+ for (size_t i = 0; i < arraysize(pattern_cases); i++) {
+ const Case& c = pattern_cases[i];
+ Pattern pattern(c.pattern);
+ bool result = pattern.MatchesString(c.candidate);
+ EXPECT_EQ(c.expected_match, result) << i << ": \"" << c.pattern
+ << "\", \"" << c.candidate << "\"";
+ }
+}