Update the CTF tests to the previous change
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StringDefinitionTest.java
CommitLineData
866e5b51
FC
1package org.eclipse.linuxtools.ctf.core.tests.types;
2
3import static org.junit.Assert.assertNotNull;
4
5import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
6import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
7import org.eclipse.linuxtools.ctf.core.event.types.Definition;
8import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
9import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
10import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
11import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
12import org.eclipse.linuxtools.ctf.core.tests.TestParams;
13import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
14import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
15
16import org.junit.After;
17import org.junit.Before;
18import org.junit.Test;
19
20/**
21 * The class <code>StringDefinitionTest</code> contains tests for the class
22 * <code>{@link StringDefinition}</code>.
23 *
24 * @author ematkho
25 * @version $Revision: 1.0 $
26 */
27public class StringDefinitionTest {
28
29 private StringDefinition fixture;
30
31 /**
32 * Launch the test.
33 *
34 * @param args
35 * the command line arguments
36 */
37 public static void main(String[] args) {
38 new org.junit.runner.JUnitCore().run(StringDefinitionTest.class);
39 }
40
41 /**
42 * Perform pre-test initialization.
43 */
44 @Before
45 public void setUp() {
46 CTFTrace trace = TestParams.createTrace();
47 CTFTraceReader tr = new CTFTraceReader(trace);
48 String name = ""; //$NON-NLS-1$
49 StructDefinition structDef = null;
50 boolean found = false;
51
52 while (tr.hasMoreEvents() && !found) {
53 tr.advance();
54 EventDefinition ed = tr.getCurrentEventDef();
55 for (String key : ed.fields.getDefinitions().keySet()) {
56 structDef = ed.fields;
57 Definition d = structDef.lookupDefinition(key);
58 if (d instanceof StringDefinition) {
59 found = true;
60 name = key;
61 break;
62 }
63 }
64 }
65 fixture = structDef.lookupString(name);
66 }
67
68 /**
69 * Perform post-test clean-up.
70 */
71 @After
72 public void tearDown() {
73 // Add additional tear down code here
74 }
75
76 /**
77 * Run the StringDefinition(StringDeclaration,DefinitionScope,String)
78 * constructor test.
79 */
80 @Test
81 public void testStringDefinition() {
82 StringDeclaration declaration = new StringDeclaration();
83 IDefinitionScope definitionScope = null;
84 String fieldName = ""; //$NON-NLS-1$
85
86 StringDefinition result = new StringDefinition(declaration,
87 definitionScope, fieldName);
88
89 assertNotNull(result);
90 }
91
92 /**
93 * Run the StringDeclaration getDeclaration() method test.
94 */
95 @Test
96 public void testGetDeclaration() {
97 fixture.setString(new StringBuilder());
98 StringDeclaration result = fixture.getDeclaration();
99 assertNotNull(result);
100 }
101
102 /**
103 * Run the StringBuilder getString() method test.
104 */
105 @Test
106 public void testGetString() {
107 fixture.setString(new StringBuilder());
108 StringBuilder result = fixture.getString();
109 assertNotNull(result);
110 }
111
112 /**
113 * Run the String getValue() method test.
114 */
115 @Test
116 public void testGetValue() {
117 fixture.setString(new StringBuilder());
118 String result = fixture.getValue();
119 assertNotNull(result);
120 }
121
122 /**
123 * Run the void read(BitBuffer) method test.
124 */
125 @Test
126 public void testRead() {
127 fixture.setString(new StringBuilder());
128 BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
129 fixture.read(input);
130 }
131
132 /**
133 * Run the void setDeclaration(StringDeclaration) method test.
134 */
135 @Test
136 public void testSetDeclaration() {
137 fixture.setString(new StringBuilder());
138 StringDeclaration declaration = new StringDeclaration();
139 fixture.setDeclaration(declaration);
140 }
141
142 /**
143 * Run the void setString(StringBuilder) method test.
144 */
145 @Test
146 public void testSetString() {
147 fixture.setString(new StringBuilder());
148 StringBuilder string = new StringBuilder();
149 fixture.setString(string);
150 }
151
152 /**
153 * Run the String toString() method test.
154 */
155 @Test
156 public void testToString() {
157 fixture.setString(new StringBuilder());
158 String result = fixture.toString();
159 assertNotNull(result);
160 }
161}
This page took 0.029014 seconds and 5 git commands to generate.