summaryrefslogtreecommitdiff
path: root/src/test/java/bjc/data/BooleanToggleTest.java
blob: bf7a04feada6d784e5efb025de1de5cead2ba6cf (plain)
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
package bjc.data;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * Test for boolean toggles.
 * 
 * @author bjculkin
 *
 */
public class BooleanToggleTest {

	/**
	 * Test that boolean toggles work right.
	 */
	@Test
	public void test() {
		BooleanToggle tog = new BooleanToggle();

		// Check initial value is false.
		assertEquals(false, tog.peek());
		// Check that 'get' returns the old value
		assertEquals(false, tog.get());
		// Check that 'get' swaps the value
		assertEquals(true, tog.peek());
		// Check that we can round-trip back.
		assertEquals(true, tog.get());
		assertEquals(false, tog.peek());

		tog.set(true);

		// Check set works
		assertEquals(true, tog.peek());
	}
}