OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/strings/sys_string_conversions.h" | 5 #include "base/strings/sys_string_conversions.h" |
6 #import "testing/gtest_mac.h" | 6 #import "testing/gtest_mac.h" |
7 #include "testing/platform_test.h" | 7 #include "testing/platform_test.h" |
8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
9 // Chromium code relies on NSRegularExpression class to match regular | 13 // Chromium code relies on NSRegularExpression class to match regular |
10 // expressions. Any subtle changes in behavior can lead to hard to diagnose | 14 // expressions. Any subtle changes in behavior can lead to hard to diagnose |
11 // problems. This files tests how NSRegularExpression handles various regular | 15 // problems. This files tests how NSRegularExpression handles various regular |
12 // expression features. | 16 // expression features. |
13 | 17 |
14 namespace { | 18 namespace { |
15 | 19 |
16 // Checks that capture groups from |testString| substituted into | 20 // Checks that capture groups from |testString| substituted into |
17 // |templateString| matches |expected|. | 21 // |templateString| matches |expected|. |
18 void ExpectRegexMatched(NSRegularExpression* regex, | 22 void ExpectRegexMatched(NSRegularExpression* regex, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 regex = MakeRegularExpression(@"^ab|cd|efghij$"); | 128 regex = MakeRegularExpression(@"^ab|cd|efghij$"); |
125 ExpectRegexMatched(regex, @"ab", @"$0", @"ab"); | 129 ExpectRegexMatched(regex, @"ab", @"$0", @"ab"); |
126 ExpectRegexMatched(regex, @"cd", @"$0", @"cd"); | 130 ExpectRegexMatched(regex, @"cd", @"$0", @"cd"); |
127 ExpectRegexMatched(regex, @"efghij", @"$0", @"efghij"); | 131 ExpectRegexMatched(regex, @"efghij", @"$0", @"efghij"); |
128 ExpectRegexNotMatched(regex, @"abcdefghij"); | 132 ExpectRegexNotMatched(regex, @"abcdefghij"); |
129 ExpectRegexNotMatched(regex, @"abghij"); | 133 ExpectRegexNotMatched(regex, @"abghij"); |
130 ExpectRegexNotMatched(regex, @"cdghij"); | 134 ExpectRegexNotMatched(regex, @"cdghij"); |
131 } | 135 } |
132 | 136 |
133 } // namespace | 137 } // namespace |
OLD | NEW |