01: package net.sf.mockcreator.utils;
02:
03: import net.sf.mockcreator.TestCase;
04: import net.sf.mockcreator.expectable.ExpectRegexp;
05: import net.sf.mockcreator.expectable.Ignore;
06: import net.sf.mockcreator.utils.CompareByValue;
07:
08: public class RecursiveComparatorExpectableParameterTest extends
09: TestCase {
10:
11: public RecursiveComparatorExpectableParameterTest(String name) {
12: super (name);
13: }
14:
15: public void testBasic() {
16: assertTrue(CompareByValue.equals(new Ignore(), "Foo"));
17: assertTrue(CompareByValue.equals("Foo", new Ignore()));
18:
19: assertTrue(CompareByValue.equals(new Ignore(), null));
20: assertTrue(CompareByValue.equals(null, new Ignore()));
21: }
22:
23: public void testIsExpected() {
24: ExpectRegexp er = new ExpectRegexp("S[0-9]+");
25:
26: assertTrue(CompareByValue.equals(er, "S1"));
27: assertTrue(CompareByValue.equals("S123", er));
28:
29: assertFalse(CompareByValue.equals(er, "S1a"));
30: assertFalse(CompareByValue.equals("S-123", er));
31:
32: assertFalse(CompareByValue.equals(er, null));
33: assertFalse(CompareByValue.equals(null, er));
34: }
35:
36: public void testBothExpected() {
37: ExpectRegexp er1 = new ExpectRegexp("S[0-9]+");
38: ExpectRegexp er2 = new ExpectRegexp("Z[0-9]+");
39: ExpectRegexp er3 = new ExpectRegexp("Z[0-9]+");
40:
41: assertFalse(CompareByValue.equals(er1, er2));
42:
43: assertTrue(CompareByValue.equals(er2, er2));
44: assertFalse(CompareByValue.equals(er2, er3));
45: }
46: }
|