blob: b17d5b3625220a97d3819203458a5aec6746f927 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.test;
import static org.junit.Assert.*;
import java.util.Arrays;
import org.junit.Test;
/**
* Check CollectionPatternMatcher, LinePatternMatcher and PatternMatcher.
*
* @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class PatternMatchersTestCase {
@Test
public final void testCollections() {
CollectionPatternMatcher cm = new CollectionPatternMatcher("a.*");
String[] coll = new String[] {};
assertEquals(false, cm.matches(Arrays.asList(coll)));
coll = new String[] { "ba", "ab" };
assertEquals(true, cm.matches(Arrays.asList(coll)));
}
@Test
public final void testLines() {
LinePatternMatcher lp = new LinePatternMatcher("a");
assertEquals(true, lp.matches("a\nab"));
assertEquals(false, lp.matches("ab\nb"));
}
@Test
public final void testPatterns() {
PatternMatcher m = new PatternMatcher(".*a.*");
assertEquals(true, m.matches("ab"));
assertEquals(false, m.matches("b"));
}
}
|