summaryrefslogtreecommitdiffstats
blob: aa20873f3911d01c60a413c9803fc63abbd15f16 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (c) 2013 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */
/*
 * Copyright (c) 2015 Tarun Gupta.
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

package com.isode.stroke.parser;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.isode.stroke.parser.EnumParser;

public class EnumParserTest {

	public EnumParserTest() {

	}

	public enum MyEnum {
		MyValue1,
		MyValue2,
		MyValue3
	};
		
	@Test
	public void testParse() {
		EnumParser parser = new EnumParser<MyEnum>();
		parser.addValue(MyEnum.MyValue1, "my-value-1");
		parser.addValue(MyEnum.MyValue2, "my-value-2");
		parser.addValue(MyEnum.MyValue3, "my-value-3");
		assertEquals(MyEnum.MyValue2, parser.parse("my-value-2"));
	}

	@Test
	public void testParse_NoValue() {
		EnumParser parser = new EnumParser<MyEnum>();
		parser.addValue(MyEnum.MyValue1, "my-value-1");
		parser.addValue(MyEnum.MyValue2, "my-value-2");
		parser.addValue(MyEnum.MyValue3, "my-value-3");
		assertNull(parser.parse("my-value-4"));
	}
}