Skip to main content
summaryrefslogtreecommitdiffstats
blob: 04c06ddde3914c479c0d43423892a82a6863b028 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*******************************************************************************
 * Copyright (c) 2008, 2010 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal;

import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.SimpleBooleanReference;

@SuppressWarnings("nls")
public class SimpleBooleanReferenceTests extends TestCase {

	public SimpleBooleanReferenceTests(String name) {
		super(name);
	}

	public void testGetValue() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.getValue());
	}

	public void testGetValueDefault() {
		SimpleBooleanReference br = new SimpleBooleanReference();
		assertFalse(br.getValue());
	}

	public void testIs() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.is(true));
		assertFalse(br.is(false));
	}

	public void testIsNot() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertFalse(br.isNot(true));
		assertTrue(br.isNot(false));
	}

	public void testIsTrue() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.isTrue());
	}

	public void testIsFalse() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertFalse(br.isFalse());
		br.setFalse();
		assertTrue(br.isFalse());
	}

	public void testSetValue() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.getValue());
		br.setValue(false);
		assertFalse(br.getValue());
	}

	public void testFlip() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.getValue());
		assertFalse(br.flip());
		assertFalse(br.getValue());
		assertTrue(br.flip());
		assertTrue(br.getValue());
	}

	public void testSetNotBoolean() {
		SimpleBooleanReference br = new SimpleBooleanReference(false);
		assertFalse(br.getValue());
		br.setNot(true);
		assertFalse(br.getValue());
		br.setNot(true);
		assertFalse(br.getValue());
		br.setNot(false);
		assertTrue(br.getValue());
	}

	public void testSetTrue() {
		SimpleBooleanReference br = new SimpleBooleanReference(false);
		assertFalse(br.getValue());
		br.setTrue();
		assertTrue(br.getValue());
	}

	public void testSetFalse() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		assertTrue(br.getValue());
		br.setFalse();
		assertFalse(br.getValue());
	}

	public void testClone() {
		SimpleBooleanReference br = new SimpleBooleanReference(true);
		SimpleBooleanReference clone = br.clone();
		assertTrue(clone.getValue());
	}

	public void testToString() {
		SimpleBooleanReference br1 = new SimpleBooleanReference(true);
		assertEquals("[true]", br1.toString());
		br1.setFalse();
		assertEquals("[false]", br1.toString());
	}

}

Back to the top