Added clocks to integer definitions and removed warnings from IOStructGen.java
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / IntegerDeclarationTest.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
6 import java.nio.ByteOrder;
7
8 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
9 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
10 import org.junit.After;
11 import org.junit.Before;
12 import org.junit.Test;
13
14 /**
15 * The class <code>IntegerDeclarationTest</code> contains tests for the class
16 * <code>{@link IntegerDeclaration}</code>.
17 *
18 * @author ematkho
19 * @version $Revision: 1.0 $
20 */
21 public class IntegerDeclarationTest {
22
23 private IntegerDeclaration fixture;
24
25 /**
26 * Launch the test.
27 *
28 * @param args
29 * the command line arguments
30 */
31 public static void main(String[] args) {
32 new org.junit.runner.JUnitCore().run(IntegerDeclarationTest.class);
33 }
34
35 /**
36 * Perform pre-test initialization.
37 */
38 @Before
39 public void setUp() {
40 fixture = new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
41 Encoding.ASCII, null);
42 }
43
44 /**
45 * Perform post-test clean-up.
46 */
47 @After
48 public void tearDown() {
49 // Add additional tear down code here
50 }
51
52 /**
53 * Run the IntegerDeclaration(int,boolean,int,ByteOrder,Encoding)
54 * constructor test.
55 */
56 @Test
57 public void testIntegerDeclaration() {
58 int len = 1;
59 boolean signed = true;
60 int base = 1;
61 ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
62 Encoding encoding = Encoding.ASCII;
63
64 IntegerDeclaration result = new IntegerDeclaration(len, signed, base,
65 byteOrder, encoding, null);
66
67 assertNotNull(result);
68 assertEquals(1, result.getBase());
69 assertEquals(false, result.isCharacter());
70 String outputValue = "[declaration] integer["; //$NON-NLS-1$
71 assertEquals(outputValue,
72 result.toString().substring(0, outputValue.length()));
73 assertEquals(1, result.getLength());
74 assertEquals(true, result.isSigned());
75 }
76
77 /**
78 * Run the int getBase() method test.
79 */
80 @Test
81 public void testGetBase() {
82 int result = fixture.getBase();
83 assertEquals(1, result);
84 }
85
86 /**
87 * Run the ByteOrder getByteOrder() method test.
88 */
89 @Test
90 public void testGetByteOrder() {
91 ByteOrder result = fixture.getByteOrder();
92 assertNotNull(result);
93 assertEquals("BIG_ENDIAN", result.toString()); //$NON-NLS-1$
94 }
95
96 /**
97 * Run the Encoding getEncoding() method test.
98 */
99 @Test
100 public void testGetEncoding() {
101 Encoding result = fixture.getEncoding();
102 assertNotNull(result);
103 assertEquals("ASCII", result.name()); //$NON-NLS-1$
104 assertEquals("ASCII", result.toString()); //$NON-NLS-1$
105 assertEquals(1, result.ordinal());
106 }
107
108 /**
109 * Run the int getLength() method test.
110 */
111 @Test
112 public void testGetLength() {
113 int result = fixture.getLength();
114 assertEquals(1, result);
115 }
116
117 /**
118 * Run the boolean isCharacter() method test.
119 */
120 @Test
121 public void testIsCharacter() {
122 boolean result = fixture.isCharacter();
123 assertEquals(false, result);
124 }
125
126 /**
127 * Run the boolean isCharacter() method test.
128 */
129 @Test
130 public void testIsCharacter_8bytes() {
131 IntegerDeclaration fixture8 = new IntegerDeclaration(8, true, 1,
132 ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
133
134 boolean result = fixture8.isCharacter();
135 assertEquals(true, result);
136 }
137
138 /**
139 * Run the boolean isSigned() method test.
140 */
141 @Test
142 public void testIsSigned_signed() {
143 boolean result = fixture.isSigned();
144 assertEquals(true, result);
145 }
146
147 /**
148 * Run the boolean isSigned() method test.
149 */
150 @Test
151 public void testIsSigned_unsigned() {
152 IntegerDeclaration fixture_unsigned = new IntegerDeclaration(1, false,
153 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
154
155 boolean result = fixture_unsigned.isSigned();
156 assertEquals(false, result);
157 }
158
159 /**
160 * Run the void setBase(int) method test.
161 */
162 @Test
163 public void testSetBase() {
164 int base = 1;
165 fixture.setBase(base);
166 }
167
168 /**
169 * Run the void setByteOrder(ByteOrder) method test.
170 */
171 @Test
172 public void testSetByteOrder() {
173 ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
174 fixture.setByteOrder(byteOrder);
175 }
176
177 /**
178 * Run the void setEncoding(Encoding) method test.
179 */
180 @Test
181 public void testSetEncoding() {
182 Encoding encoding = Encoding.ASCII;
183 fixture.setEncoding(encoding);
184 }
185
186 /**
187 * Run the void setLength(int) method test.
188 */
189 @Test
190 public void testSetLength() {
191 int length = 1;
192 fixture.setLength(length);
193 }
194
195 /**
196 * Run the void setSigned(boolean) method test.
197 */
198 @Test
199 public void testSetSigned() {
200 boolean signed = true;
201 fixture.setSigned(signed);
202 }
203
204 /**
205 * Run the String toString() method test.
206 */
207 @Test
208 public void testToString() {
209 String result = fixture.toString();
210 String trunc = result.substring(0, 22);
211 assertEquals("[declaration] integer[", trunc); //$NON-NLS-1$
212 }
213 }
This page took 0.035031 seconds and 5 git commands to generate.