1
2
3
4
5
6
7
8
9 package bexee.util;
10
11 import junit.framework.TestCase;
12 import bexee.model.InvalidValueException;
13
14 /***
15 * @author Pawel Kowalski
16 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:21 $
17 */
18 public class BooleanUtilsTest extends TestCase {
19
20 public void testYesNoToBoolean() {
21 assertTrue(BooleanUtils.yesNoToBoolean("YES"));
22 }
23
24 public void testYesNoToBooleanTwo() {
25 assertTrue(BooleanUtils.yesNoToBoolean("Yes"));
26 }
27
28 public void testYesNoToBooleanNo() {
29 assertFalse(BooleanUtils.yesNoToBoolean("No"));
30 }
31
32 public void testYesNoToBooleanNoTwo() {
33 assertFalse(BooleanUtils.yesNoToBoolean("bkljbdf"));
34 }
35
36 public void testStrictYesNoToBoolean() {
37 try {
38 assertTrue(BooleanUtils.strictYesNoToBoolean("YES"));
39 } catch (InvalidValueException e) {
40 e.printStackTrace();
41 fail("Should not throw Exception");
42 }
43 }
44
45 public void testStrictYesNoToBooleanTwo() {
46 try {
47 assertTrue(BooleanUtils.strictYesNoToBoolean("Yes"));
48 } catch (InvalidValueException e) {
49 e.printStackTrace();
50 fail("Should not throw Exception");
51 }
52 }
53
54 public void testStrictYesNoToBooleanNo() {
55 try {
56 assertFalse(BooleanUtils.strictYesNoToBoolean("No"));
57 } catch (InvalidValueException e) {
58 e.printStackTrace();
59 fail("Should not throw Exception");
60 }
61 }
62
63 public void testStrictYesNoToBooleanException() {
64 try {
65 assertFalse(BooleanUtils.strictYesNoToBoolean("wdfwef"));
66 fail("Should not accept Strings other than yes or no");
67 } catch (InvalidValueException e) {
68 }
69 }
70 }