2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
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.
10 package eu.svjatoslav.commons.string;
12 import static org.junit.Assert.fail;
14 import org.junit.Before;
15 import org.junit.Test;
17 public class WildCardMatcherTest {
19 private static void testWildcard(final String string, final String pattern,
20 final boolean expectedResult) {
22 final boolean result = WildCardMatcher.match(string, pattern);
24 if (result != expectedResult)
25 fail("Wildcard match failed.");
29 WildCardMatcher matcher;
32 public void setUp() throws Exception {
39 testWildcard("IMG_9770.JPG", "*.J*", true);
40 testWildcard("1", "1", true);
41 testWildcard("1", "*", true);
42 testWildcard("f", "1", false);
43 testWildcard("Hello !", "Hell*!***", true);
44 testWildcard("Hello !", "Hell*!", true);
45 testWildcard("Hello !", "Hell*", true);
46 testWildcard("Hello !", "Hell", false);
47 testWildcard("Hello !", "* *", true);