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
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
14 import static org
.junit
.Assert
.assertNotNull
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
18 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDefinition
;
20 import org
.junit
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * The class <code>StringDefinitionTest</code> contains tests for the class
26 * <code>{@link StringDefinition}</code>.
29 * @version $Revision: 1.0 $
31 public class StringDefinitionTest
{
33 private StringDefinition fixture
;
39 * the command line arguments
41 public static void main(String
[] args
) {
42 new org
.junit
.runner
.JUnitCore().run(StringDefinitionTest
.class);
46 * Perform pre-test initialization.
50 String name
= "testString"; //$NON-NLS-1$
51 StringDeclaration stringDec
= new StringDeclaration();
52 fixture
= stringDec
.createDefinition(null, name
);
56 * Perform post-test clean-up.
59 public void tearDown() {
60 // Add additional tear down code here
64 * Run the StringDefinition(StringDeclaration,DefinitionScope,String)
68 public void testStringDefinition() {
69 StringDeclaration declaration
= new StringDeclaration();
70 IDefinitionScope definitionScope
= null;
71 String fieldName
= ""; //$NON-NLS-1$
73 StringDefinition result
= new StringDefinition(declaration
,
74 definitionScope
, fieldName
);
76 assertNotNull(result
);
80 * Run the StringDeclaration getDeclaration() method test.
83 public void testGetDeclaration() {
84 fixture
.setString(new StringBuilder());
85 StringDeclaration result
= fixture
.getDeclaration();
86 assertNotNull(result
);
90 * Run the StringBuilder getString() method test.
93 public void testGetString() {
94 fixture
.setString(new StringBuilder());
95 StringBuilder result
= fixture
.getString();
96 assertNotNull(result
);
100 * Run the String getValue() method test.
103 public void testGetValue() {
104 fixture
.setString(new StringBuilder());
105 String result
= fixture
.getValue();
106 assertNotNull(result
);
110 * Run the void read(BitBuffer) method test.
113 public void testRead() {
114 fixture
.setString(new StringBuilder());
115 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
120 * Run the void setDeclaration(StringDeclaration) method test.
123 public void testSetDeclaration() {
124 fixture
.setString(new StringBuilder());
125 StringDeclaration declaration
= new StringDeclaration();
126 fixture
.setDeclaration(declaration
);
130 * Run the void setString(StringBuilder) method test.
133 public void testSetString() {
134 fixture
.setString(new StringBuilder());
135 StringBuilder string
= new StringBuilder();
136 fixture
.setString(string
);
140 * Run the String toString() method test.
143 public void testToString() {
144 fixture
.setString(new StringBuilder());
145 String result
= fixture
.toString();
146 assertNotNull(result
);