@Test public void testOrder() throws InvalidPatternException { List<String> result; result = newGlobExpander().expand("{a,b}"); assertEquals(result, Arrays.asList("a","b"), "Expansion was "+result); result = newGlobExpander().expand("{{a},b}"); assertEquals(result, Arrays.asList("a","b"), "Expansion was "+result); result = newGlobExpander().expand("{a,b}{1,2}"); assertEquals(result, Arrays.asList("a1","a2","b1","b2"), "Expansion was "+result); result = newGlobExpander().expand("{80{8{1,2},90},8000+}"); assertEquals(result, Arrays.asList("8081","8082","8090","8000+"), "Expansion was "+result); }
@Test public void testNumLeadZero() throws InvalidPatternException { assertTrue(newGlobExpander().isGlobMatchedNumeric("a{01-03,05}", "a01")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{ 01 - 03 , 05 }", "a01")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{ 01 - 03 , 05 }", "a02")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{ 01 - 03 , 05 }", "a03")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{ 01 - 03 , 05 }", "a 05 ")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{01-03,05}", "a05")); assertFalse(newGlobExpander().isGlobMatchedNumeric("a{01-03,05}", "a04")); assertFalse(newGlobExpander().isGlobMatchedNumeric("a{01-03,05}", "a3")); }
@Test public void testQuotesAndParen() throws InvalidPatternException { List<String> result; SpecialistGlobExpander special = new SpecialistGlobExpander(true, PhraseTreatment.INTERIOR_EXPANDABLE, PhraseTreatment.INTERIOR_NOT_EXPANDABLE); result = special.expand("\"{hello,goodbye}{1-2,({3-4}),(\")}\""); assertEquals(8, result.size()); assertTrue(result.contains("\"goodbye2\"")); assertTrue(result.contains("\"hello({3-4})\"")); assertTrue(result.contains("\"goodbye(\")\"")); }
@Test public void testBasic() throws InvalidPatternException { assertTrue(WildcardGlobs.isGlobMatched("a?{ex,in}", "akin")); assertTrue(WildcardGlobs.isGlobMatched("a?{ex,in}", "alex")); assertFalse(WildcardGlobs.isGlobMatched("a?{ex,in}", "appin")); }
SpecialistGlobExpander notSpecial = new SpecialistGlobExpander(true, PhraseTreatment.NOT_A_SPECIAL_CHAR, PhraseTreatment.NOT_A_SPECIAL_CHAR); result = notSpecial.expand("hello ({1-3})"); assertEquals(3, result.size()); assertEquals("hello (1)", result.get(0)); assertEquals(3, result.size()); assertEquals("hello (1)", result.get(0)); result = expanding.expand("hello ({1,2-3})"); assertEquals(3, result.size()); assertEquals("hello (2)", result.get(1)); assertEquals(1, result.size()); assertEquals("hello ({1,2-3})", result.get(0)); assertEquals(3, result.size()); assertEquals("hello (1", result.get(0)); assertEquals(1, result.size()); assertEquals("hello (1,2,3)", result.get(0)); assertEquals(1, result.size()); assertEquals("hello (1,2,3)", result.get(0)); assertEquals(4, result.size()); assertEquals("hello (1", result.get(0)); assertEquals("hello 03)", result.get(2)); assertEquals(3, result.size()); assertEquals("hello (1,02)", result.get(0));
@Test public void testEmpty() throws InvalidPatternException { assertTrue(WildcardGlobs.isGlobMatched("a{,?}{,b}", "a")); assertTrue(WildcardGlobs.isGlobMatched("a{,?}{,b}", "ab")); assertTrue(WildcardGlobs.isGlobMatched("a{,?}{,b}", "ac")); assertTrue(WildcardGlobs.isGlobMatched("a{,?}{,b}", "acb")); assertFalse(WildcardGlobs.isGlobMatched("a{,?}{,b}", "abc")); assertFalse(WildcardGlobs.isGlobMatched("a{,?}{,b}", "accb")); }
SpecialistGlobExpander notSpecial = new SpecialistGlobExpander(true, PhraseTreatment.NOT_A_SPECIAL_CHAR, PhraseTreatment.NOT_A_SPECIAL_CHAR); result = notSpecial.expand("hello \"{1-3}\""); assertEquals(3, result.size()); assertEquals("hello \"1\"", result.get(0)); assertEquals(3, result.size()); assertEquals("hello \"1\"", result.get(0)); result = expanding.expand("hello \"{1,2-3}\""); assertEquals(3, result.size()); assertEquals("hello \"2\"", result.get(1)); assertEquals(1, result.size()); assertEquals("hello \"{1,2-3}\"", result.get(0)); assertEquals(3, result.size()); assertEquals("hello \"1", result.get(0)); assertEquals(1, result.size()); assertEquals("hello \"1,2,3\"", result.get(0)); assertEquals(1, result.size()); assertEquals("hello \"1,2,3\"", result.get(0)); assertEquals(4, result.size()); assertEquals("hello \"1", result.get(0)); assertEquals("hello 03\"", result.get(2)); assertEquals(3, result.size()); assertEquals("hello \"1,02\"", result.get(0));
@Test public void testNum() throws InvalidPatternException { assertTrue(newGlobExpander().isGlobMatchedNumeric("{1-3}", "1")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{1-3}", "a1")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{1-3,5}", "a1")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{1-3,5}", "a3")); assertTrue(newGlobExpander().isGlobMatchedNumeric("a{1-3,5}", "a5")); assertFalse(newGlobExpander().isGlobMatchedNumeric("a{1-3,5}", "a4")); assertFalse(newGlobExpander().isGlobMatchedNumeric("a{1-3,5}", "a01")); }