Lines 80-90
Link Here
|
80 |
|
80 |
|
81 |
/** |
81 |
/** |
82 |
* Tests exact match functionality. If we camelCase rule is enable, Pattern should starts with lowerCase character. |
82 |
* Tests exact match functionality. If we camelCase rule is enable, Pattern should starts with lowerCase character. |
83 |
* Result for "aBcD " pattern should be similar to regexp pattern "abcd" with case insensitive. |
83 |
* Result for "abcd " pattern should be similar to regexp pattern "abcd" with case insensitive. |
84 |
*/ |
84 |
*/ |
85 |
public void testExactMatch1() { |
85 |
public void testExactMatch1() { |
86 |
String patternText = "aBcD "; |
86 |
String patternText = "abcd "; |
87 |
Pattern pattern = Pattern.compile("aBcD", Pattern.CASE_INSENSITIVE); |
87 |
Pattern pattern = Pattern.compile("abcd", Pattern.CASE_INSENSITIVE); |
88 |
SearchPattern patternMatcher = new SearchPattern(); |
88 |
SearchPattern patternMatcher = new SearchPattern(); |
89 |
patternMatcher.setPattern(patternText); |
89 |
patternMatcher.setPattern(patternText); |
90 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_EXACT_MATCH); |
90 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_EXACT_MATCH); |
Lines 96-106
Link Here
|
96 |
|
96 |
|
97 |
/** |
97 |
/** |
98 |
* Tests exact match functionality. If we camelCase rule is enable, Pattern should starts with lowerCase character. |
98 |
* Tests exact match functionality. If we camelCase rule is enable, Pattern should starts with lowerCase character. |
99 |
* Result for "AbCdEfGh<" pattern should be similar to regexp pattern "AbCdEfGh" with case insensitive. |
99 |
* Result for "abcdefgh " pattern should be similar to regexp pattern "abcdefgh" with case insensitive. |
100 |
*/ |
100 |
*/ |
101 |
public void testExactMatch2() { |
101 |
public void testExactMatch2() { |
102 |
String patternText = "AbCdEfGh<"; |
102 |
String patternText = "abcdefgh<"; |
103 |
Pattern pattern = Pattern.compile("AbCdEfGh", Pattern.CASE_INSENSITIVE); |
103 |
Pattern pattern = Pattern.compile("abcdefgh", Pattern.CASE_INSENSITIVE); |
104 |
SearchPattern patternMatcher = new SearchPattern(); |
104 |
SearchPattern patternMatcher = new SearchPattern(); |
105 |
patternMatcher.setPattern(patternText); |
105 |
patternMatcher.setPattern(patternText); |
106 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_EXACT_MATCH); |
106 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_EXACT_MATCH); |
Lines 164-170
Link Here
|
164 |
* Result for "CD" SearchPattern should be similar to regexp pattern "C[^A-Z]*D.*" or "CD.*" |
164 |
* Result for "CD" SearchPattern should be similar to regexp pattern "C[^A-Z]*D.*" or "CD.*" |
165 |
* If pattern contains only upperCase characters result contains all prefix match elements. |
165 |
* If pattern contains only upperCase characters result contains all prefix match elements. |
166 |
*/ |
166 |
*/ |
167 |
public void testCamelCaseMatch() { |
167 |
public void testCamelCaseMatch1() { |
168 |
String patternText = "CD"; |
168 |
String patternText = "CD"; |
169 |
Pattern pattern = Pattern.compile("C[^A-Z]*D.*"); |
169 |
Pattern pattern = Pattern.compile("C[^A-Z]*D.*"); |
170 |
Pattern pattern2 = Pattern.compile("CD.*", Pattern.CASE_INSENSITIVE); |
170 |
Pattern pattern2 = Pattern.compile("CD.*", Pattern.CASE_INSENSITIVE); |
Lines 180-185
Link Here
|
180 |
} |
180 |
} |
181 |
|
181 |
|
182 |
/** |
182 |
/** |
|
|
183 |
* Tests camelCase match functionality. |
184 |
* Every string starts with upperCase characters should be recognize as camelCase pattern match rule. |
185 |
* Result for "AbCd " SearchPattern should be similar to regexp pattern "C[^A-Z]*D.*" or "CD.*" |
186 |
*/ |
187 |
public void testCamelCaseMatch2() { |
188 |
String patternText = "AbCd "; |
189 |
Pattern pattern = Pattern.compile("Ab[^A-Z]*Cd[^A-Z]*"); |
190 |
SearchPattern patternMatcher = new SearchPattern(); |
191 |
patternMatcher.setPattern(patternText); |
192 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_CAMELCASE_MATCH); |
193 |
for (Iterator iter = resources.iterator(); iter.hasNext();) { |
194 |
String res = (String) iter.next(); |
195 |
assertEquals(patternMatcher.matches(res), pattern.matcher(res).matches()); |
196 |
} |
197 |
} |
198 |
|
199 |
/** |
200 |
* Tests camelCase match functionality. |
201 |
* Every string starts with upperCase characters should be recognize as camelCase pattern match rule. |
202 |
* Result for "AbCdE<" SearchPattern should be similar to regexp pattern "Ab[^A-Z]*Cd[^A-Z]*E[^A-Z]*" |
203 |
*/ |
204 |
public void testCamelCaseMatch3() { |
205 |
String patternText = "AbCdE<"; |
206 |
Pattern pattern = Pattern.compile("Ab[^A-Z]*Cd[^A-Z]*E[^A-Z]*"); |
207 |
SearchPattern patternMatcher = new SearchPattern(); |
208 |
patternMatcher.setPattern(patternText); |
209 |
assertEquals(patternMatcher.getMatchRule(), SearchPattern.RULE_CAMELCASE_MATCH); |
210 |
for (Iterator iter = resources.iterator(); iter.hasNext();) { |
211 |
String res = (String) iter.next(); |
212 |
assertEquals(patternMatcher.matches(res), pattern.matcher(res).matches()); |
213 |
} |
214 |
} |
215 |
|
216 |
/** |
183 |
* Tests blank match functionality. |
217 |
* Tests blank match functionality. |
184 |
* Blank string should be recognize as blank pattern match rule. |
218 |
* Blank string should be recognize as blank pattern match rule. |
185 |
* It should match with all resources. |
219 |
* It should match with all resources. |