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
.assertEquals
;
15 import static org
.junit
.Assert
.assertNotNull
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
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
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
22 import org
.junit
.Before
;
23 import org
.junit
.Test
;
26 * The class <code>StringDefinitionTest</code> contains tests for the class
27 * <code>{@link StringDefinition}</code>.
30 * @version $Revision: 1.0 $
32 public class StringDefinitionTest
{
34 private StringDefinition fixture
;
37 * Perform pre-test initialization.
41 String name
= "testString";
42 StringDeclaration stringDec
= new StringDeclaration();
43 fixture
= stringDec
.createDefinition(null, name
);
47 * Run the StringDefinition(StringDeclaration,DefinitionScope,String)
51 public void testStringDefinition() {
52 StringDeclaration declaration
= new StringDeclaration();
53 IDefinitionScope definitionScope
= null;
54 String fieldName
= "";
56 StringDefinition result
= new StringDefinition(declaration
,
57 definitionScope
, fieldName
);
59 assertNotNull(result
);
63 * Run the StringDeclaration getDeclaration() method test.
66 public void testGetDeclaration() {
67 StringDeclaration result
= fixture
.getDeclaration();
68 assertNotNull(result
);
72 * Run the String getValue() method test.
75 public void testGetValue() {
76 String result
= fixture
.getValue();
77 assertNotNull(result
);
81 * Run the String setValue() method test.
84 public void testSetValue() {
85 fixture
.setValue("dummy");
86 String result
= fixture
.getValue();
87 assertNotNull(result
);
88 assertEquals("dummy", result
);
92 * Run the void read(BitBuffer) method test.
93 * @throws CTFReaderException error
96 public void testRead() throws CTFReaderException
{
97 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
102 * Run the void setDeclaration(StringDeclaration) method test.
105 public void testSetDeclaration() {
106 StringDeclaration declaration
= new StringDeclaration();
107 fixture
.setDeclaration(declaration
);
111 * Run the String toString() method test.
114 public void testToString() {
115 String result
= fixture
.toString();
116 assertNotNull(result
);