2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2020, 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 org.junit.Test;
14 import static org.junit.Assert.fail;
16 public class GlobMatcherTest {
19 private static void testWildcard(final String string, final String pattern,
20 final boolean expectedResult) {
22 final boolean result = GlobMatcher.match(string, pattern);
24 if (result != expectedResult)
25 fail("Wildcard match failed.");
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);