1 3 package jodd.util; 4 5 import junit.framework.TestCase; 6 7 public class WildcardTest extends TestCase { 8 9 public void testMatch() { 10 assertTrue(Wildcard.match("CfgOptions.class", "C*class")); 11 assertFalse(Wildcard.match("CfgOptions.class", "C*clas")); 12 assertFalse(Wildcard.match("C*r*class", "CfgOptions.class")); 13 14 assertTrue(Wildcard.match("CfgOptions.class", "*g*class")); 16 assertTrue(Wildcard.match("CfgOptions.class", "*C*g*class")); 17 assertTrue(Wildcard.match("CfgOptions.class", "C*g*cl*")); 18 assertTrue(Wildcard.match("CfgOptions.class", "*C*g*cl*")); 19 20 assertTrue(Wildcard.match("CfgOptions.class", "*g*c**ss")); 22 assertTrue(Wildcard.match("CfgOptions.class", "*g*c**s")); assertTrue(Wildcard.match("CfgOptions.class", "*gOpti******ons.c**ss")); 24 assertTrue(Wildcard.match("CfgOptions.class", "***gOpti*ons.c**ss")); 25 assertTrue(Wildcard.match("CfgOptions.class", "***gOptions.c**")); 26 27 assertTrue(Wildcard.match("CfgOptions.class", "*gOpti*c?ass")); 29 assertFalse(Wildcard.match("CfgOptions.class", "*gOpti*c?ss")); 30 31 assertTrue(Wildcard.match("CfgOptions.class", "*gOpti*c?as?")); 33 assertFalse(Wildcard.match("CfgOptions.class", "*gOpti*c?a?")); 34 assertTrue(Wildcard.match("CfgOptions.class", "?fgOpti*c?ass")); 35 assertFalse(Wildcard.match("CfgOptions.class", "?gOpti*c?as?")); 36 assertTrue(Wildcard.match("CfgOptions.class", "??gOpti*c?ass")); 37 38 assertTrue(Wildcard.match("CfgOptions.class", "C????ti*c?ass")); 40 assertFalse(Wildcard.match("CfgOptions.class", "C???ti*c?ass")); 41 42 assertTrue(Wildcard.match("CfgOptions.class", "C??*ti*c?ass")); 44 assertTrue(Wildcard.match("CfgOptions.class", "C*ti*c?as?*")); 45 assertTrue(Wildcard.match("CfgOptions.class", "C*ti*c?a*?")); 46 assertTrue(Wildcard.match("CfgOptions.class", "C*ti*?a*")); 47 assertTrue(Wildcard.match("CfgOptions.class", "C*ti*c?a?*")); 48 assertFalse(Wildcard.match("CfgOptions.class", "C*ti*c?*la?*")); 49 50 assertFalse(Wildcard.match("CfgOptions.class", "*gOpti\\*c?ass")); 52 assertTrue(Wildcard.match("CfgOpti*class", "*gOpti\\*class")); 53 assertTrue(Wildcard.match("CfgOpti*class", "*gOpti\\*c?ass")); 54 assertFalse(Wildcard.match("CfgOpti*class", "*gOpti\\\\*c?ass")); 55 assertTrue(Wildcard.match("CfgOpti\\*class", "*gOpti\\\\*c?ass")); 56 assertTrue(Wildcard.match("CfgOpti?class", "*gOpti\\?c*ass")); 57 assertFalse(Wildcard.match("CfgOpti\\?class", "*gOpti\\?c*ass")); 58 assertTrue(Wildcard.match("CfgOptions.class", "CfgOpti\\ons.class")); 59 assertTrue(Wildcard.match("What's this?", "What*\\?")); 60 } 61 62 } 63 | Popular Tags |