Commit | Line | Data |
---|---|---|
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 |
12 | package org.eclipse.linuxtools.ctf.core.tests.types; |
13 | ||
14 | import static org.junit.Assert.assertNotNull; | |
15 | ||
486efb2e | 16 | import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer; |
866e5b51 FC |
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; | |
866e5b51 FC |
20 | import org.junit.After; |
21 | import org.junit.Before; | |
22 | import org.junit.Test; | |
23 | ||
24 | /** | |
25 | * The class <code>StringDefinitionTest</code> contains tests for the class | |
26 | * <code>{@link StringDefinition}</code>. | |
024373d7 | 27 | * |
866e5b51 FC |
28 | * @author ematkho |
29 | * @version $Revision: 1.0 $ | |
30 | */ | |
31 | public class StringDefinitionTest { | |
32 | ||
33 | private StringDefinition fixture; | |
34 | ||
35 | /** | |
36 | * Launch the test. | |
024373d7 | 37 | * |
866e5b51 FC |
38 | * @param args |
39 | * the command line arguments | |
40 | */ | |
41 | public static void main(String[] args) { | |
42 | new org.junit.runner.JUnitCore().run(StringDefinitionTest.class); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Perform pre-test initialization. | |
47 | */ | |
48 | @Before | |
be6df2d8 | 49 | public void setUp() { |
024373d7 MK |
50 | String name = "testString"; //$NON-NLS-1$ |
51 | StringDeclaration stringDec = new StringDeclaration(); | |
52 | fixture = stringDec.createDefinition(null, name); | |
866e5b51 FC |
53 | } |
54 | ||
55 | /** | |
56 | * Perform post-test clean-up. | |
57 | */ | |
58 | @After | |
59 | public void tearDown() { | |
60 | // Add additional tear down code here | |
61 | } | |
62 | ||
63 | /** | |
64 | * Run the StringDefinition(StringDeclaration,DefinitionScope,String) | |
65 | * constructor test. | |
66 | */ | |
67 | @Test | |
68 | public void testStringDefinition() { | |
69 | StringDeclaration declaration = new StringDeclaration(); | |
70 | IDefinitionScope definitionScope = null; | |
71 | String fieldName = ""; //$NON-NLS-1$ | |
72 | ||
73 | StringDefinition result = new StringDefinition(declaration, | |
74 | definitionScope, fieldName); | |
75 | ||
76 | assertNotNull(result); | |
77 | } | |
78 | ||
79 | /** | |
80 | * Run the StringDeclaration getDeclaration() method test. | |
81 | */ | |
82 | @Test | |
83 | public void testGetDeclaration() { | |
84 | fixture.setString(new StringBuilder()); | |
85 | StringDeclaration result = fixture.getDeclaration(); | |
86 | assertNotNull(result); | |
87 | } | |
88 | ||
89 | /** | |
90 | * Run the StringBuilder getString() method test. | |
91 | */ | |
92 | @Test | |
93 | public void testGetString() { | |
94 | fixture.setString(new StringBuilder()); | |
95 | StringBuilder result = fixture.getString(); | |
96 | assertNotNull(result); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Run the String getValue() method test. | |
101 | */ | |
102 | @Test | |
103 | public void testGetValue() { | |
104 | fixture.setString(new StringBuilder()); | |
105 | String result = fixture.getValue(); | |
106 | assertNotNull(result); | |
107 | } | |
108 | ||
109 | /** | |
110 | * Run the void read(BitBuffer) method test. | |
111 | */ | |
112 | @Test | |
113 | public void testRead() { | |
114 | fixture.setString(new StringBuilder()); | |
115 | BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128)); | |
116 | fixture.read(input); | |
117 | } | |
118 | ||
119 | /** | |
120 | * Run the void setDeclaration(StringDeclaration) method test. | |
121 | */ | |
122 | @Test | |
123 | public void testSetDeclaration() { | |
124 | fixture.setString(new StringBuilder()); | |
125 | StringDeclaration declaration = new StringDeclaration(); | |
126 | fixture.setDeclaration(declaration); | |
127 | } | |
128 | ||
129 | /** | |
130 | * Run the void setString(StringBuilder) method test. | |
131 | */ | |
132 | @Test | |
133 | public void testSetString() { | |
134 | fixture.setString(new StringBuilder()); | |
135 | StringBuilder string = new StringBuilder(); | |
136 | fixture.setString(string); | |
137 | } | |
138 | ||
139 | /** | |
140 | * Run the String toString() method test. | |
141 | */ | |
142 | @Test | |
143 | public void testToString() { | |
144 | fixture.setString(new StringBuilder()); | |
145 | String result = fixture.toString(); | |
146 | assertNotNull(result); | |
147 | } | |
148 | } |