KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mockobjects > constraint > MatchesTest


1 /*
2  * Date: 21-Oct-2002
3  */

4 package test.mockobjects.constraint;
5
6 import junit.framework.TestCase;
7
8 import com.mockobjects.constraint.Constraint;
9 import com.mockobjects.constraint.Matches;
10
11 public class MatchesTest extends TestCase {
12     public MatchesTest(String JavaDoc name) {
13         super(name);
14     }
15
16     public void testMatches() {
17         Constraint p = new Matches("^hello, (.*)\\.$");
18
19         assertTrue(p.eval("hello, world."));
20         assertTrue(p.eval("hello, mum."));
21         assertTrue(!p.eval("hello world."));
22         assertTrue(!p.eval("hello, world"));
23         assertTrue(!p.eval("goodbye, world."));
24     }
25
26 }
27
Popular Tags