ctf: potential memory optimization
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StringDefinitionTest.java
CommitLineData
4bd7f2db
AM
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
866e5b51
FC
12package org.eclipse.linuxtools.ctf.core.tests.types;
13
4f4b6212 14import static org.junit.Assert.assertEquals;
866e5b51
FC
15import static org.junit.Assert.assertNotNull;
16
486efb2e 17import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
866e5b51
FC
18import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
19import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
20import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition;
db8e8f7d 21import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
866e5b51
FC
22import org.junit.Before;
23import org.junit.Test;
24
25/**
26 * The class <code>StringDefinitionTest</code> contains tests for the class
27 * <code>{@link StringDefinition}</code>.
024373d7 28 *
866e5b51
FC
29 * @author ematkho
30 * @version $Revision: 1.0 $
31 */
32public class StringDefinitionTest {
33
34 private StringDefinition fixture;
35
866e5b51
FC
36 /**
37 * Perform pre-test initialization.
38 */
39 @Before
be6df2d8 40 public void setUp() {
4a9c1f07 41 String name = "testString";
024373d7
MK
42 StringDeclaration stringDec = new StringDeclaration();
43 fixture = stringDec.createDefinition(null, name);
866e5b51
FC
44 }
45
866e5b51
FC
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;
4a9c1f07 54 String fieldName = "";
866e5b51
FC
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() {
866e5b51
FC
67 StringDeclaration result = fixture.getDeclaration();
68 assertNotNull(result);
69 }
70
71 /**
4f4b6212 72 * Run the String getValue() method test.
866e5b51
FC
73 */
74 @Test
4f4b6212
EB
75 public void testGetValue() {
76 String result = fixture.getValue();
866e5b51
FC
77 assertNotNull(result);
78 }
79
80 /**
4f4b6212 81 * Run the String setValue() method test.
866e5b51
FC
82 */
83 @Test
4f4b6212
EB
84 public void testSetValue() {
85 fixture.setValue("dummy");
866e5b51
FC
86 String result = fixture.getValue();
87 assertNotNull(result);
4f4b6212 88 assertEquals("dummy", result);
866e5b51
FC
89 }
90
91 /**
92 * Run the void read(BitBuffer) method test.
db8e8f7d 93 * @throws CTFReaderException error
866e5b51
FC
94 */
95 @Test
db8e8f7d 96 public void testRead() throws CTFReaderException {
866e5b51
FC
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() {
866e5b51
FC
106 StringDeclaration declaration = new StringDeclaration();
107 fixture.setDeclaration(declaration);
108 }
109
866e5b51
FC
110 /**
111 * Run the String toString() method test.
112 */
113 @Test
114 public void testToString() {
866e5b51
FC
115 String result = fixture.toString();
116 assertNotNull(result);
117 }
118}
This page took 0.063399 seconds and 5 git commands to generate.