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
;
16 import static org
.junit
.Assert
.assertNull
;
17 import static org
.junit
.Assert
.assertTrue
;
19 import java
.nio
.ByteOrder
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.EnumDeclaration
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.EnumDefinition
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
25 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
26 import org
.junit
.After
;
27 import org
.junit
.Before
;
28 import org
.junit
.Test
;
31 * The class <code>EnumDeclarationTest</code> contains tests for the class
32 * <code>{@link EnumDeclaration}</code>.
35 * @version $Revision: 1.0 $
37 public class EnumDeclarationTest
{
39 private EnumDeclaration fixture
;
45 * the command line arguments
47 public static void main(String
[] args
) {
48 new org
.junit
.runner
.JUnitCore().run(EnumDeclarationTest
.class);
52 * Perform pre-test initialization.
56 fixture
= new EnumDeclaration(new IntegerDeclaration(1, true, 1,
57 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null, 8));
61 * Perform post-test clean-up.
64 public void tearDown() {
65 // Add additional tear down code here
69 * Run the EnumDeclaration(IntegerDeclaration) constructor test.
72 public void testEnumDeclaration() {
73 IntegerDeclaration containerType
= new IntegerDeclaration(1, true, 1,
74 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null, 8);
76 EnumDeclaration result
= new EnumDeclaration(containerType
);
78 assertNotNull(result
);
79 String left
= "[declaration] enum[";
80 assertEquals(left
, result
.toString().substring(0, left
.length()));
84 * Run the boolean add(long,long,String) method test.
87 public void testAdd() {
92 boolean result
= fixture
.add(low
, high
, label
);
98 * Run the EnumDefinition createDefinition(DefinitionScope,String) method
102 public void testCreateDefinition() {
103 IDefinitionScope definitionScope
= null;
104 String fieldName
= "";
106 EnumDefinition result
= fixture
.createDefinition(definitionScope
,
109 assertNotNull(result
);
113 * Run the String query(long) method test.
116 public void testQuery() {
118 String result
= fixture
.query(value
);
124 * Run the String toString() method test.
127 public void testToString() {
128 String result
= fixture
.toString();
130 String left
= "[declaration] enum[";
131 assertEquals(left
, result
.substring(0, left
.length()));