01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.test.constraints;
13:
14: import java.math.BigDecimal;
15: import java.math.BigInteger;
16:
17: import net.sf.oval.constraint.MinCheck;
18:
19: /**
20: * @author Sebastian Thomschke
21: */
22: public class MinTest extends AbstractContraintsTest {
23: public void testMax() {
24: final MinCheck check = new MinCheck();
25: super .testCheck(check);
26: assertTrue(check.isSatisfied(null, null, null, null));
27:
28: check.setMin(40);
29: assertEquals(40, check.getMin());
30:
31: assertTrue(check.isSatisfied(null, "40", null, null));
32: assertTrue(check.isSatisfied(null, 40, null, null));
33: assertTrue(check.isSatisfied(null, (byte) 40, null, null));
34: assertTrue(check.isSatisfied(null, (short) 40, null, null));
35: assertTrue(check.isSatisfied(null, (float) 40.0, null, null));
36: assertTrue(check.isSatisfied(null, 40.0, null, null));
37: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(40),
38: null, null));
39: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(40.0),
40: null, null));
41: assertTrue(check.isSatisfied(null, BigInteger.valueOf(40),
42: null, null));
43:
44: assertTrue(check.isSatisfied(null, "50", null, null));
45: assertTrue(check.isSatisfied(null, 50, null, null));
46: assertTrue(check.isSatisfied(null, (byte) 50, null, null));
47: assertTrue(check.isSatisfied(null, (short) 50, null, null));
48: assertTrue(check.isSatisfied(null, (float) 50.0, null, null));
49: assertTrue(check.isSatisfied(null, 50.0, null, null));
50: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(50),
51: null, null));
52: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(50.0),
53: null, null));
54: assertTrue(check.isSatisfied(null, BigInteger.valueOf(50),
55: null, null));
56:
57: assertFalse(check.isSatisfied(null, "20", null, null));
58: assertFalse(check.isSatisfied(null, 20, null, null));
59: assertFalse(check.isSatisfied(null, (byte) 20, null, null));
60: assertFalse(check.isSatisfied(null, (short) 20, null, null));
61: assertFalse(check.isSatisfied(null, (float) 20.0, null, null));
62: assertFalse(check.isSatisfied(null, 20.0, null, null));
63: assertFalse(check.isSatisfied(null, BigDecimal.valueOf(20),
64: null, null));
65: assertFalse(check.isSatisfied(null, BigDecimal.valueOf(20.0),
66: null, null));
67: assertFalse(check.isSatisfied(null, BigInteger.valueOf(20),
68: null, null));
69:
70: assertFalse(check.isSatisfied(null, "", null, null));
71: assertFalse(check.isSatisfied(null, "sdfQ", null, null));
72: }
73: }
|