Code cleanup and formatting. Migrated to java 1.8.
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / string / WildCardMatcherTest.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality.
3  * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.commons.string;
11
12 import org.junit.Test;
13
14 import static org.junit.Assert.fail;
15
16 public class WildCardMatcherTest {
17
18
19     private static void testWildcard(final String string, final String pattern,
20                                      final boolean expectedResult) {
21
22         final boolean result = WildCardMatcher.match(string, pattern);
23
24         if (result != expectedResult)
25             fail("Wildcard match failed.");
26
27     }
28
29     @Test
30     public void test() {
31
32         testWildcard("IMG_9770.JPG", "*.J*", true);
33         testWildcard("1", "1", true);
34         testWildcard("1", "*", true);
35         testWildcard("f", "1", false);
36         testWildcard("Hello !", "Hell*!***", true);
37         testWildcard("Hello !", "Hell*!", true);
38         testWildcard("Hello !", "Hell*", true);
39         testWildcard("Hello !", "Hell", false);
40         testWildcard("Hello !", "* *", true);
41
42     }
43
44 }