1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
6 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
7 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
8 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDefinition
;
10 import org
.junit
.After
;
11 import org
.junit
.Before
;
12 import org
.junit
.Test
;
15 * The class <code>StringDeclarationTest</code> contains tests for the class
16 * <code>{@link StringDeclaration}</code>.
19 * @version $Revision: 1.0 $
21 public class StringDeclarationTest
{
23 private StringDeclaration fixture
;
29 * the command line arguments
31 public static void main(String
[] args
) {
32 new org
.junit
.runner
.JUnitCore().run(StringDeclarationTest
.class);
36 * Perform pre-test initialization.
40 fixture
= new StringDeclaration(Encoding
.ASCII
);
44 * Perform post-test clean-up.
47 public void tearDown() {
48 // Add additional tear down code here
52 * Run the StringDeclaration() constructor test.
55 public void testStringDeclaration() {
56 StringDeclaration result
= new StringDeclaration();
58 assertNotNull(result
);
59 String string
= "[declaration] string["; //$NON-NLS-1$
60 assertEquals(string
, result
.toString().substring(0, string
.length()));
64 * Run the StringDeclaration(Encoding) constructor test.
67 public void testStringDeclaration_2() {
68 Encoding encoding
= Encoding
.ASCII
;
69 StringDeclaration result
= new StringDeclaration(encoding
);
71 assertNotNull(result
);
72 String string
= "[declaration] string["; //$NON-NLS-1$
73 assertEquals(string
, result
.toString().substring(0, string
.length()));
77 * Run the StringDefinition createDefinition(DefinitionScope,String) method
81 public void testCreateDefinition() {
82 IDefinitionScope definitionScope
= null;
83 String fieldName
= "id"; //$NON-NLS-1$
84 StringDefinition result
= fixture
.createDefinition(definitionScope
,
87 assertNotNull(result
);
91 * Run the Encoding getEncoding() method test.
94 public void testGetEncoding() {
95 Encoding result
= fixture
.getEncoding();
97 assertNotNull(result
);
98 assertEquals("ASCII", result
.name()); //$NON-NLS-1$
99 assertEquals("ASCII", result
.toString()); //$NON-NLS-1$
100 assertEquals(1, result
.ordinal());
104 * Run the void setEncoding(Encoding) method test.
107 public void testSetEncoding() {
108 Encoding encoding
= Encoding
.ASCII
;
109 fixture
.setEncoding(encoding
);
113 * Run the String toString() method test.
116 public void testToString() {
117 String result
= fixture
.toString();
118 String left
= "[declaration] string["; //$NON-NLS-1$
119 String right
= result
.substring(0, left
.length());
121 assertEquals(left
, right
);