[CTF] Fix Struct toString fields in CtfTmfEventFields
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / EnumDeclarationTest.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.assertNull;
6 import static org.junit.Assert.assertTrue;
7
8 import java.nio.ByteOrder;
9
10 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
11 import org.eclipse.linuxtools.ctf.core.event.types.EnumDeclaration;
12 import org.eclipse.linuxtools.ctf.core.event.types.EnumDefinition;
13 import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
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>EnumDeclarationTest</code> contains tests for the class
21 * <code>{@link EnumDeclaration}</code>.
22 *
23 * @author ematkho
24 * @version $Revision: 1.0 $
25 */
26 public class EnumDeclarationTest {
27
28 private EnumDeclaration 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(EnumDeclarationTest.class);
38 }
39
40 /**
41 * Perform pre-test initialization.
42 */
43 @Before
44 public void setUp() {
45 fixture = new EnumDeclaration(new IntegerDeclaration(1, true, 1,
46 ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8));
47 }
48
49 /**
50 * Perform post-test clean-up.
51 */
52 @After
53 public void tearDown() {
54 // Add additional tear down code here
55 }
56
57 /**
58 * Run the EnumDeclaration(IntegerDeclaration) constructor test.
59 */
60 @Test
61 public void testEnumDeclaration() {
62 IntegerDeclaration containerType = new IntegerDeclaration(1, true, 1,
63 ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
64
65 EnumDeclaration result = new EnumDeclaration(containerType);
66
67 assertNotNull(result);
68 String left = "[declaration] enum["; //$NON-NLS-1$
69 assertEquals(left, result.toString().substring(0, left.length()));
70 }
71
72 /**
73 * Run the boolean add(long,long,String) method test.
74 */
75 @Test
76 public void testAdd() {
77 long low = 1L;
78 long high = 1L;
79 String label = ""; //$NON-NLS-1$
80
81 boolean result = fixture.add(low, high, label);
82
83 assertTrue(result);
84 }
85
86 /**
87 * Run the EnumDefinition createDefinition(DefinitionScope,String) method
88 * test.
89 */
90 @Test
91 public void testCreateDefinition() {
92 IDefinitionScope definitionScope = null;
93 String fieldName = ""; //$NON-NLS-1$
94
95 EnumDefinition result = fixture.createDefinition(definitionScope,
96 fieldName);
97
98 assertNotNull(result);
99 }
100
101 /**
102 * Run the String query(long) method test.
103 */
104 @Test
105 public void testQuery() {
106 long value = 0;
107 String result = fixture.query(value);
108
109 assertNull(result);
110 }
111
112 /**
113 * Run the String toString() method test.
114 */
115 @Test
116 public void testToString() {
117 String result = fixture.toString();
118
119 String left = "[declaration] enum["; //$NON-NLS-1$
120 assertEquals(left, result.substring(0, left.length()));
121 }
122 }
This page took 0.033344 seconds and 5 git commands to generate.