summaryrefslogtreecommitdiff
path: root/src/test/java/bjc/data/EitherTest.java
blob: ef2d12b787e15d89f0af50fb4bac320d5ca0d9ce (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
package bjc.data;

import static org.junit.Assert.*;

import java.util.*;

import org.junit.*;

@SuppressWarnings("javadoc")
public class EitherTest
{
	private Either<String, String> leftEither;
	private Either<String, String> rightEither;
	
	@Before
	public void setUp() throws Exception {
		leftEither  = Either.left("left");
		rightEither = Either.right("right");
	}

	@Test
	public void testIsLeft() {
		assertTrue("isLeft properly marks left eithers", leftEither.isLeft());
		assertFalse("isLeft properly marks right eithers", rightEither.isLeft());
	}
	
	@Test
	public void testGetLeft() {
		assertEquals("getLeft treats left eithers properly",
				Optional.of("left"), leftEither.getLeft());
		assertEquals("getLeft treats right eithers properly",
				Optional.empty(), rightEither.getLeft());
	}

}