d03fe9311f7afe6eb14eea5d2fc5e8cb199ea7f5
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StringDeclarationTest.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.types.Encoding;
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.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24
25 /**
26 * The class <code>StringDeclarationTest</code> contains tests for the class
27 * <code>{@link StringDeclaration}</code>.
28 *
29 * @author ematkho
30 * @version $Revision: 1.0 $
31 */
32 public class StringDeclarationTest {
33
34 private StringDeclaration fixture;
35
36 /**
37 * Launch the test.
38 *
39 * @param args
40 * the command line arguments
41 */
42 public static void main(String[] args) {
43 new org.junit.runner.JUnitCore().run(StringDeclarationTest.class);
44 }
45
46 /**
47 * Perform pre-test initialization.
48 */
49 @Before
50 public void setUp() {
51 fixture = new StringDeclaration(Encoding.ASCII);
52 }
53
54 /**
55 * Perform post-test clean-up.
56 */
57 @After
58 public void tearDown() {
59 // Add additional tear down code here
60 }
61
62 /**
63 * Run the StringDeclaration() constructor test.
64 */
65 @Test
66 public void testStringDeclaration() {
67 StringDeclaration result = new StringDeclaration();
68
69 assertNotNull(result);
70 String string = "[declaration] string["; //$NON-NLS-1$
71 assertEquals(string, result.toString().substring(0, string.length()));
72 }
73
74 /**
75 * Run the StringDeclaration(Encoding) constructor test.
76 */
77 @Test
78 public void testStringDeclaration_2() {
79 Encoding encoding = Encoding.ASCII;
80 StringDeclaration result = new StringDeclaration(encoding);
81
82 assertNotNull(result);
83 String string = "[declaration] string["; //$NON-NLS-1$
84 assertEquals(string, result.toString().substring(0, string.length()));
85 }
86
87 /**
88 * Run the StringDefinition createDefinition(DefinitionScope,String) method
89 * test.
90 */
91 @Test
92 public void testCreateDefinition() {
93 IDefinitionScope definitionScope = null;
94 String fieldName = "id"; //$NON-NLS-1$
95 StringDefinition result = fixture.createDefinition(definitionScope,
96 fieldName);
97
98 assertNotNull(result);
99 }
100
101 /**
102 * Run the Encoding getEncoding() method test.
103 */
104 @Test
105 public void testGetEncoding() {
106 Encoding result = fixture.getEncoding();
107
108 assertNotNull(result);
109 assertEquals("ASCII", result.name()); //$NON-NLS-1$
110 assertEquals("ASCII", result.toString()); //$NON-NLS-1$
111 assertEquals(1, result.ordinal());
112 }
113
114 /**
115 * Run the void setEncoding(Encoding) method test.
116 */
117 @Test
118 public void testSetEncoding() {
119 Encoding encoding = Encoding.ASCII;
120 fixture.setEncoding(encoding);
121 }
122
123 /**
124 * Run the String toString() method test.
125 */
126 @Test
127 public void testToString() {
128 String result = fixture.toString();
129 String left = "[declaration] string["; //$NON-NLS-1$
130 String right = result.substring(0, left.length());
131
132 assertEquals(left, right);
133 }
134 }
This page took 0.032818 seconds and 5 git commands to generate.