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
.After
;
25 import org
.junit
.Before
;
26 import org
.junit
.Test
;
29 * The class <code>IntegerDefinitionTest</code> contains tests for the class
30 * <code>{@link IntegerDefinition}</code>.
33 * @version $Revision: 1.0 $
35 public class IntegerDefinitionTest
{
37 private IntegerDefinition fixture
;
38 String name
= "testInt"; //$NON-NLS-1$
39 String clockName
= "clock"; //$NON-NLS-1$
44 * the command line arguments
46 public static void main(String
[] args
) {
47 new org
.junit
.runner
.JUnitCore().run(IntegerDefinitionTest
.class);
51 * Perform pre-test initialization. We know the structDef won't be null (or
52 * else the tests will fail), so we can safely suppress the warning.
57 // StructDefinition structDef = null;
58 // boolean found = false;
59 IntegerDeclaration id
= new IntegerDeclaration( 1, true, 1, ByteOrder
.BIG_ENDIAN
, Encoding
.NONE
, clockName
, 8);
60 fixture
= id
.createDefinition(null, name
);
64 * Perform post-test clean-up.
67 public void tearDown() {
68 // Add additional tear down code here
72 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
76 public void testIntegerDefinition() {
77 IntegerDeclaration declaration
= new IntegerDeclaration(1, true, 1,
78 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null, 8);
79 IDefinitionScope definitionScope
= null;
80 String fieldName
= ""; //$NON-NLS-1$
82 IntegerDefinition result
= new IntegerDefinition(declaration
,
83 definitionScope
, fieldName
);
84 assertNotNull(result
);
88 * Run the IntegerDeclaration getDeclaration() method test.
91 public void testGetDeclaration() {
94 IntegerDeclaration result
= fixture
.getDeclaration();
95 assertNotNull(result
);
99 * Run the long getValue() method test.
102 public void testGetValue() {
103 fixture
.setValue(1L);
105 long result
= fixture
.getValue();
106 assertEquals(1L, result
);
110 * Run the void read(BitBuffer) method test.
113 public void testRead() {
114 fixture
.setValue(1L);
115 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
121 * Run the String toString() method test.
124 public void testToString() {
125 fixture
.setValue(1L);
127 String result
= fixture
.toString();
128 assertNotNull(result
);