blob: 60e8d225565d5f02a83406c9b930650d925c1557 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package com.smartdevicelink.test.rpc.enums;
import com.smartdevicelink.proxy.rpc.enums.Dimension;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* This is a unit test class for the SmartDeviceLink library project class :
* {@link com.smartdevicelink.proxy.rpc.enums.Dimension}
*/
public class DimensionTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
public void testValidEnums() {
String example = "NO_FIX";
Dimension enumNoFix = Dimension.valueForString(example);
example = "2D";
Dimension enum2D = Dimension.valueForString(example);
example = "3D";
Dimension enum3D = Dimension.valueForString(example);
assertNotNull("NO_FIX returned null", enumNoFix);
assertNotNull("2D returned null", enum2D);
assertNotNull("3D returned null", enum3D);
}
/**
* Verifies that an invalid assignment is null.
*/
public void testInvalidEnum() {
String example = "no_FiX";
try {
Dimension temp = Dimension.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
} catch (IllegalArgumentException exception) {
fail("Invalid enum throws IllegalArgumentException.");
}
}
/**
* Verifies that a null assignment is invalid.
*/
public void testNullEnum() {
String example = null;
try {
Dimension temp = Dimension.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
} catch (NullPointerException exception) {
fail("Null string throws NullPointerException.");
}
}
/**
* Verifies the possible enum values of Dimension.
*/
public void testListEnum() {
List<Dimension> enumValueList = Arrays.asList(Dimension.values());
List<Dimension> enumTestList = new ArrayList<Dimension>();
enumTestList.add(Dimension.NO_FIX);
enumTestList.add(Dimension._2D);
enumTestList.add(Dimension._3D);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
}
}
|