ctf: Fix API inconsistencies
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / EnumDefinitionTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.types;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertTrue;
6
7 import java.nio.ByteBuffer;
8 import java.nio.ByteOrder;
9
10 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
11 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
12 import org.eclipse.linuxtools.ctf.core.event.types.EnumDeclaration;
13 import org.eclipse.linuxtools.ctf.core.event.types.EnumDefinition;
14 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18
19 /**
20 * The class <code>EnumDefinitionTest</code> contains tests for the class
21 * <code>{@link EnumDefinition}</code>.
22 *
23 * @author ematkho
24 * @version $Revision: 1.0 $
25 */
26 public class EnumDefinitionTest {
27
28 private EnumDefinition fixture;
29
30 /**
31 * Launch the test.
32 *
33 * @param args
34 * the command line arguments
35 */
36 public static void main(String[] args) {
37 new org.junit.runner.JUnitCore().run(EnumDefinitionTest.class);
38 }
39
40 /**
41 * Perform pre-test initialization.
42 */
43 @Before
44 public void setUp() {
45 EnumDeclaration declaration = new EnumDeclaration(
46 new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
47 Encoding.ASCII, null, 8));
48 String fieldName = ""; //$NON-NLS-1$
49
50 fixture = new EnumDefinition(declaration, null, fieldName);
51 }
52
53 /**
54 * Perform post-test clean-up.
55 */
56 @After
57 public void tearDown() {
58 // Add additional tear down code here
59 }
60
61 /**
62 * Run the EnumDefinition(EnumDeclaration,DefinitionScope,String)
63 * constructor test.
64 */
65 @Test
66 public void testEnumDefinition() {
67 assertNotNull(fixture);
68 }
69
70 /**
71 * Run the String getValue() method test.
72 */
73 @Test
74 public void testGetValue() {
75 String result = fixture.getValue();
76
77 assertNotNull(result);
78 }
79
80 /**
81 * Run the long getIntegerValue() method test.
82 */
83 @Test
84 public void testGetIntegerValue_one() {
85 fixture.setIntegerValue(1L);
86 long result = fixture.getIntegerValue();
87
88 assertEquals(1L, result);
89 }
90
91 /**
92 * Run the String getValue() method test.
93 */
94 @Test
95 public void testGetIntegerValue_zero() {
96 fixture.setIntegerValue(0);
97 long result = fixture.getIntegerValue();
98
99 assertTrue(0 == result);
100 }
101
102 /**
103 * Run the void read(BitBuffer) method test.
104 */
105 @Test
106 public void testRead() {
107 fixture.setIntegerValue(1L);
108 BitBuffer input = new BitBuffer(ByteBuffer.allocateDirect(128));
109
110 fixture.read(input);
111 }
112 }
This page took 0.036374 seconds and 5 git commands to generate.