Refactored exception dialog.
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / string / GlobMatcherTest.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5 package eu.svjatoslav.commons.string;
6
7 import org.junit.Test;
8
9 import static org.junit.Assert.fail;
10
11 public class GlobMatcherTest {
12
13
14     private static void testWildcard(final String string, final String pattern,
15                                      final boolean expectedResult) {
16
17         final boolean result = GlobMatcher.match(string, pattern);
18
19         if (result != expectedResult)
20             fail("Wildcard match failed.");
21
22     }
23
24     @Test
25     public void test() {
26
27         testWildcard("IMG_9770.JPG", "*.J*", true);
28         testWildcard("1", "1", true);
29         testWildcard("1", "*", true);
30         testWildcard("f", "1", false);
31         testWildcard("Hello !", "Hell*!***", true);
32         testWildcard("Hello !", "Hell*!", true);
33         testWildcard("Hello !", "Hell*", true);
34         testWildcard("Hello !", "Hell", false);
35         testWildcard("Hello !", "* *", true);
36
37     }
38
39 }