ctf: Hide internal functionalities of StringDefinition.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StringDefinitionTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11
12 package org.eclipse.linuxtools.ctf.core.tests.types;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16
17 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
18 import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
19 import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
20 import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
21 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
22 import org.junit.Before;
23 import org.junit.Test;
24
25 /**
26 * The class <code>StringDefinitionTest</code> contains tests for the class
27 * <code>{@link StringDefinition}</code>.
28 *
29 * @author ematkho
30 * @version $Revision: 1.0 $
31 */
32 public class StringDefinitionTest {
33
34 private StringDefinition fixture;
35
36 /**
37 * Perform pre-test initialization.
38 */
39 @Before
40 public void setUp() {
41 String name = "testString";
42 StringDeclaration stringDec = new StringDeclaration();
43 fixture = stringDec.createDefinition(null, name);
44 }
45
46 /**
47 * Run the StringDefinition(StringDeclaration,DefinitionScope,String)
48 * constructor test.
49 */
50 @Test
51 public void testStringDefinition() {
52 StringDeclaration declaration = new StringDeclaration();
53 IDefinitionScope definitionScope = null;
54 String fieldName = "";
55
56 StringDefinition result = new StringDefinition(declaration,
57 definitionScope, fieldName);
58
59 assertNotNull(result);
60 }
61
62 /**
63 * Run the StringDeclaration getDeclaration() method test.
64 */
65 @Test
66 public void testGetDeclaration() {
67 StringDeclaration result = fixture.getDeclaration();
68 assertNotNull(result);
69 }
70
71 /**
72 * Run the String getValue() method test.
73 */
74 @Test
75 public void testGetValue() {
76 String result = fixture.getValue();
77 assertNotNull(result);
78 }
79
80 /**
81 * Run the String setValue() method test.
82 */
83 @Test
84 public void testSetValue() {
85 fixture.setValue("dummy");
86 String result = fixture.getValue();
87 assertNotNull(result);
88 assertEquals("dummy", result);
89 }
90
91 /**
92 * Run the void read(BitBuffer) method test.
93 * @throws CTFReaderException error
94 */
95 @Test
96 public void testRead() throws CTFReaderException {
97 BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
98 fixture.read(input);
99 }
100
101 /**
102 * Run the void setDeclaration(StringDeclaration) method test.
103 */
104 @Test
105 public void testSetDeclaration() {
106 StringDeclaration declaration = new StringDeclaration();
107 fixture.setDeclaration(declaration);
108 }
109
110 /**
111 * Run the String toString() method test.
112 */
113 @Test
114 public void testToString() {
115 String result = fixture.toString();
116 assertNotNull(result);
117 }
118 }
This page took 0.033817 seconds and 6 git commands to generate.