Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/gn/pattern_unittest.cc

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/pattern.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/pattern.h"
7
8 namespace {
9
10 struct Case {
11 const char* pattern;
12 const char* candidate;
13 bool expected_match;
14 };
15
16 } // namespace
17
18 TEST(Pattern, Matches) {
19 Case pattern_cases[] = {
20 // Empty pattern matches only empty string.
21 { "", "", true },
22 { "", "foo", false },
23 // Exact matches.
24 { "foo", "foo", true },
25 { "foo", "bar", false },
26 // Path boundaries.
27 { "\\b", "", true },
28 { "\\b", "/", true },
29 { "\\b\\b", "/", true },
30 { "\\b\\b\\b", "", false },
31 { "\\b\\b\\b", "/", true },
32 { "\\b", "//", false },
33 { "\\bfoo\\b", "foo", true },
34 { "\\bfoo\\b", "/foo/", true },
35 { "\\b\\bfoo", "/foo", true },
36 // *
37 { "*", "", true },
38 { "*", "foo", true },
39 { "*foo", "foo", true },
40 { "*foo", "gagafoo", true },
41 { "*foo", "gagafoob", false },
42 { "foo*bar", "foobar", true },
43 { "foo*bar", "foo-bar", true },
44 { "foo*bar", "foolalalalabar", true },
45 { "foo*bar", "foolalalalabaz", false },
46 { "*a*b*c*d*", "abcd", true },
47 { "*a*b*c*d*", "1a2b3c4d5", true },
48 { "*a*b*c*d*", "1a2b3c45", false },
49 { "*\\bfoo\\b*", "foo", true },
50 { "*\\bfoo\\b*", "/foo/", true },
51 { "*\\bfoo\\b*", "foob", false },
52 { "*\\bfoo\\b*", "lala/foo/bar/baz", true },
53 };
54 for (size_t i = 0; i < arraysize(pattern_cases); i++) {
55 const Case& c = pattern_cases[i];
56 Pattern pattern(c.pattern);
57 bool result = pattern.MatchesString(c.candidate);
58 EXPECT_EQ(c.expected_match, result) << i << ": \"" << c.pattern
59 << "\", \"" << c.candidate << "\"";
60 }
61 }
OLDNEW
« no previous file with comments | « tools/gn/pattern.cc ('k') | tools/gn/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698