ctf: Clean up unit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / IntegerDefinitionTest.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 java.nio.ByteOrder;
18
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;
26
27 /**
28 * The class <code>IntegerDefinitionTest</code> contains tests for the class
29 * <code>{@link IntegerDefinition}</code>.
30 *
31 * @author ematkho
32 * @version $Revision: 1.0 $
33 */
34 public class IntegerDefinitionTest {
35
36 private IntegerDefinition fixture;
37 String name = "testInt";
38 String clockName = "clock";
39
40 /**
41 * Perform pre-test initialization.
42 */
43 @Before
44 public void setUp() {
45 IntegerDeclaration id = new IntegerDeclaration( 1, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
46 fixture = id.createDefinition(null, name);
47 }
48
49 /**
50 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
51 * constructor test.
52 */
53 @Test
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 = "";
59
60 IntegerDefinition result = new IntegerDefinition(declaration,
61 definitionScope, fieldName);
62 assertNotNull(result);
63 }
64
65 /**
66 * Run the IntegerDeclaration getDeclaration() method test.
67 */
68 @Test
69 public void testGetDeclaration() {
70 fixture.setValue(1L);
71
72 IntegerDeclaration result = fixture.getDeclaration();
73 assertNotNull(result);
74 }
75
76 /**
77 * Run the long getValue() method test.
78 */
79 @Test
80 public void testGetValue() {
81 fixture.setValue(1L);
82
83 long result = fixture.getValue();
84 assertEquals(1L, result);
85 }
86
87 /**
88 * Run the void read(BitBuffer) method test.
89 */
90 @Test
91 public void testRead() {
92 fixture.setValue(1L);
93 BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
94
95 fixture.read(input);
96 }
97
98 /**
99 * Run the String toString() method test.
100 */
101 @Test
102 public void testToString() {
103 fixture.setValue(1L);
104
105 String result = fixture.toString();
106 assertNotNull(result);
107 }
108 }
This page took 0.033614 seconds and 5 git commands to generate.