KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mx4j > util > WildcardMatchTest


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8 package test.mx4j.util;
9
10 import junit.framework.TestCase;
11 import mx4j.util.Utils;
12
13 /**
14  * @version $Revision: 1.1 $
15  */

16 public class WildcardMatchTest extends TestCase
17 {
18    public void testSingleWildcard()
19    {
20       assertTrue(Utils.wildcardMatch("*", ""));
21       assertTrue(Utils.wildcardMatch("*", "A"));
22       assertTrue(Utils.wildcardMatch("*", "ABC"));
23    }
24
25    public void testTwoWildcards()
26    {
27       assertFalse(Utils.wildcardMatch("*D*", ""));
28       assertTrue(Utils.wildcardMatch("*D*", "aaaaDbbb"));
29       assertTrue(Utils.wildcardMatch("*D*", "aaaaD"));
30       assertTrue(Utils.wildcardMatch("*D*", "Dbbb"));
31       assertFalse(Utils.wildcardMatch("*D*", "aaabbb"));
32    }
33 }
34
Popular Tags