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.MaxCheck;
18:
19: /**
20: * @author Sebastian Thomschke
21: */
22: public class MaxTest extends AbstractContraintsTest {
23: public void testMax() {
24: final MaxCheck check = new MaxCheck();
25: super .testCheck(check);
26: assertTrue(check.isSatisfied(null, null, null, null));
27:
28: check.setMax(100);
29: assertEquals(100, check.getMax());
30:
31: assertTrue(check.isSatisfied(null, "50", null, null));
32: assertTrue(check.isSatisfied(null, 50, null, null));
33: assertTrue(check.isSatisfied(null, (byte) 50, null, null));
34: assertTrue(check.isSatisfied(null, (short) 50, null, null));
35: assertTrue(check.isSatisfied(null, (float) 50.0, null, null));
36: assertTrue(check.isSatisfied(null, 50.0, null, null));
37: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(50),
38: null, null));
39: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(50.0),
40: null, null));
41: assertTrue(check.isSatisfied(null, BigInteger.valueOf(50),
42: null, null));
43:
44: assertTrue(check.isSatisfied(null, "100", null, null));
45: assertTrue(check.isSatisfied(null, 100, null, null));
46: assertTrue(check.isSatisfied(null, (byte) 100, null, null));
47: assertTrue(check.isSatisfied(null, (short) 100, null, null));
48: assertTrue(check.isSatisfied(null, (float) 100.0, null, null));
49: assertTrue(check.isSatisfied(null, 100.0, null, null));
50: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(100),
51: null, null));
52: assertTrue(check.isSatisfied(null, BigDecimal.valueOf(100.0),
53: null, null));
54: assertTrue(check.isSatisfied(null, BigInteger.valueOf(100),
55: null, null));
56:
57: assertFalse(check.isSatisfied(null, "110", null, null));
58: assertFalse(check.isSatisfied(null, 110, null, null));
59: assertFalse(check.isSatisfied(null, (byte) 110, null, null));
60: assertFalse(check.isSatisfied(null, (short) 110, null, null));
61: assertFalse(check.isSatisfied(null, (float) 110.0, null, null));
62: assertFalse(check.isSatisfied(null, 110.0, null, null));
63: assertFalse(check.isSatisfied(null, BigDecimal.valueOf(110),
64: null, null));
65: assertFalse(check.isSatisfied(null, BigDecimal.valueOf(110.0),
66: null, null));
67: assertFalse(check.isSatisfied(null, BigInteger.valueOf(110),
68: null, null));
69:
70: assertFalse(check.isSatisfied(null, "", null, null));
71: assertFalse(check.isSatisfied(null, "sdfQ", null, null));
72: }
73: }
|