Improve javadoc for ctfAdapter in Tmf.Core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / IntegerDeclarationTest.java
CommitLineData
866e5b51
FC
1package org.eclipse.linuxtools.ctf.core.tests.types;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotNull;
5
6import java.nio.ByteOrder;
7
8import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
9import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
10import org.junit.After;
11import org.junit.Before;
12import org.junit.Test;
13
14/**
15 * The class <code>IntegerDeclarationTest</code> contains tests for the class
16 * <code>{@link IntegerDeclaration}</code>.
284fdee8 17 *
866e5b51
FC
18 * @author ematkho
19 * @version $Revision: 1.0 $
20 */
21public class IntegerDeclarationTest {
22
23 private IntegerDeclaration fixture;
24
25 /**
26 * Launch the test.
284fdee8 27 *
866e5b51
FC
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,
fd74e6c1 41 Encoding.ASCII, null, 32);
866e5b51
FC
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,
fd74e6c1 65 byteOrder, encoding, null, 16);
866e5b51
FC
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,
fd74e6c1 132 ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
866e5b51
FC
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,
fd74e6c1 153 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
866e5b51
FC
154
155 boolean result = fixture_unsigned.isSigned();
156 assertEquals(false, result);
157 }
158
866e5b51
FC
159
160 /**
161 * Run the String toString() method test.
162 */
163 @Test
164 public void testToString() {
165 String result = fixture.toString();
166 String trunc = result.substring(0, 22);
167 assertEquals("[declaration] integer[", trunc); //$NON-NLS-1$
168 }
169}
This page took 0.031326 seconds and 5 git commands to generate.