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 java
.nio
.ByteOrder
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDefinition
;
24 import org
.junit
.Before
;
25 import org
.junit
.Test
;
28 * The class <code>IntegerDefinitionTest</code> contains tests for the class
29 * <code>{@link IntegerDefinition}</code>.
32 * @version $Revision: 1.0 $
34 public class IntegerDefinitionTest
{
36 private IntegerDefinition fixture
;
37 String name
= "testInt";
38 String clockName
= "clock";
41 * Perform pre-test initialization.
45 IntegerDeclaration id
= new IntegerDeclaration( 1, true, 1, ByteOrder
.BIG_ENDIAN
, Encoding
.NONE
, clockName
, 8);
46 fixture
= id
.createDefinition(null, name
);
50 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
54 public void testIntegerDefinition() {
55 IntegerDeclaration declaration
= new IntegerDeclaration(1, true, 1,
56 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null, 8);
57 IDefinitionScope definitionScope
= null;
58 String fieldName
= "";
60 IntegerDefinition result
= new IntegerDefinition(declaration
,
61 definitionScope
, fieldName
);
62 assertNotNull(result
);
66 * Run the IntegerDeclaration getDeclaration() method test.
69 public void testGetDeclaration() {
72 IntegerDeclaration result
= fixture
.getDeclaration();
73 assertNotNull(result
);
77 * Run the long getValue() method test.
80 public void testGetValue() {
83 long result
= fixture
.getValue();
84 assertEquals(1L, result
);
88 * Run the void read(BitBuffer) method test.
91 public void testRead() {
93 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
99 * Run the String toString() method test.
102 public void testToString() {
103 fixture
.setValue(1L);
105 String result
= fixture
.toString();
106 assertNotNull(result
);