@@ -207,6 +207,80 @@ public void testTab() {
207
207
assertThat ("no tab then abc" , testRegex , not (matchesTo ("abc" )));
208
208
}
209
209
210
+ @ Test
211
+ public void testWord () {
212
+ VerbalExpression testRegex = new VerbalExpression .Builder ()
213
+ .startOfLine ()
214
+ .word ()
215
+ .build ();
216
+
217
+ assertThat ("word" , testRegex , matchesTo ("abc123" ));
218
+ assertThat ("non-word" , testRegex , not (matchesTo ("@#" )));
219
+ }
220
+
221
+ @ Test
222
+ public void testMultipleNoRange () {
223
+ VerbalExpression testRegexStringOnly = new VerbalExpression .Builder ()
224
+ .startOfLine ()
225
+ .multiple ("abc" )
226
+ .build ();
227
+ VerbalExpression testRegexStringAndNull = new VerbalExpression .Builder ()
228
+ .startOfLine ()
229
+ .multiple ("abc" , null )
230
+ .build ();
231
+ VerbalExpression testRegexMoreThan2Ints = new VerbalExpression .Builder ()
232
+ .startOfLine ()
233
+ .multiple ("abc" , 2 , 4 , 8 )
234
+ .build ();
235
+ VerbalExpression [] testRegexesSameBehavior = {
236
+ testRegexStringOnly ,
237
+ testRegexStringAndNull ,
238
+ testRegexMoreThan2Ints
239
+ };
240
+ for (VerbalExpression testRegex : testRegexesSameBehavior ) {
241
+ assertThat ("abc once" , testRegex ,
242
+ matchesTo ("abc" ));
243
+ assertThat ("abc more than once" , testRegex ,
244
+ matchesTo ("abcabcabc" ));
245
+ assertThat ("no abc" , testRegex ,
246
+ not (matchesTo ("xyz" )));
247
+ }
248
+ }
249
+
250
+ @ Test
251
+ public void testMultipleFrom () {
252
+ VerbalExpression testRegexFrom = new VerbalExpression .Builder ()
253
+ .startOfLine ()
254
+ .multiple ("abc" , 2 )
255
+ .build ();
256
+ assertThat ("no abc" , testRegexFrom ,
257
+ not (matchesTo ("xyz" )));
258
+ assertThat ("abc less than 2 times" , testRegexFrom ,
259
+ not (matchesTo ("abc" )));
260
+ assertThat ("abc exactly 2 times" , testRegexFrom ,
261
+ matchesTo ("abcabc" ));
262
+ assertThat ("abc more than 2 times" , testRegexFrom ,
263
+ matchesTo ("abcabcabc" ));
264
+ }
265
+
266
+ @ Test
267
+ public void testMultipleFromTo () {
268
+ VerbalExpression testRegexFromTo = new VerbalExpression .Builder ()
269
+ .startOfLine ()
270
+ .multiple ("abc" , 2 , 4 )
271
+ .build ();
272
+ assertThat ("no abc" , testRegexFromTo , not (matchesTo ("xyz" )));
273
+ assertThat ("abc less than 2 times" , testRegexFromTo ,
274
+ not (matchesTo ("abc" )));
275
+ assertThat ("abc exactly 2 times" , testRegexFromTo , matchesTo ("abcabc" ));
276
+ assertThat ("abc between 2 and 4 times" , testRegexFromTo ,
277
+ matchesTo ("abcabcabc" ));
278
+ assertThat ("abc exactly 4 times" , testRegexFromTo ,
279
+ matchesTo ("abcabcabcabc" ));
280
+ assertThat ("abc more than 4 times" , testRegexFromTo ,
281
+ not (matchesExactly ("abcabcabcabcabc" )));
282
+ }
283
+
210
284
@ Test
211
285
public void testWithAnyCase () {
212
286
VerbalExpression testRegex = new VerbalExpression .Builder ()
0 commit comments