TMF XML: Add unit tests for XML file extension point
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / ArrayDeclarationTest.java
CommitLineData
4bd7f2db
AM
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
866e5b51
FC
12package org.eclipse.linuxtools.ctf.core.tests.types;
13
14import static org.junit.Assert.assertEquals;
15import static org.junit.Assert.assertNotNull;
16
17import org.eclipse.linuxtools.ctf.core.event.types.ArrayDeclaration;
18import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition;
19import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration;
20import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
21import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
866e5b51
FC
22import org.junit.Before;
23import org.junit.Test;
24
25/**
26 * The class <code>ArrayDeclarationTest</code> contains tests for the class
27 * <code>{@link ArrayDeclaration}</code>.
4bd7f2db 28 *
866e5b51
FC
29 * @author ematkho
30 * @version $Revision: 1.0 $
31 */
32public class ArrayDeclarationTest {
33
34 private ArrayDeclaration fixture;
35
866e5b51
FC
36 /**
37 * Perform pre-test initialization.
38 */
39 @Before
40 public void setUp() {
41 fixture = new ArrayDeclaration(1, new StringDeclaration());
42 }
43
866e5b51
FC
44 /**
45 * Run the ArrayDeclaration(int,Declaration) constructor test.
46 */
47 @Test
48 public void testArrayDeclaration() {
49 int length = 1;
50 IDeclaration elemType = new StringDeclaration();
51 ArrayDeclaration result = new ArrayDeclaration(length, elemType);
52
53 assertNotNull(result);
4a9c1f07 54 String left = "[declaration] array[";
866e5b51
FC
55 String right = result.toString().substring(0, left.length());
56 assertEquals(left, right);
57 assertEquals(1, result.getLength());
58 }
59
60 /**
61 * Run the ArrayDefinition createDefinition(DefinitionScope,String) method
62 * test.
63 */
64 @Test
65 public void testCreateDefinition() {
4a9c1f07 66 String fieldName = "";
866e5b51
FC
67 IDefinitionScope definitionScope = null;
68 ArrayDefinition result;
69 result = fixture.createDefinition(definitionScope, fieldName);
70
71 assertNotNull(result);
72 }
73
74 /**
75 * Run the Declaration getElementType() method test.
76 */
77 @Test
78 public void testGetElementType() {
79 IDeclaration result = fixture.getElementType();
80 assertNotNull(result);
81 }
82
83 /**
84 * Run the int getLength() method test.
85 */
86 @Test
87 public void testGetLength() {
88 int result = fixture.getLength();
89 assertEquals(1, result);
90 }
91
92 /**
93 * Run the String toString() method test.
94 */
95 @Test
96 public void testToString() {
97 String result = fixture.toString();
4a9c1f07 98 String left = "[declaration] array[";
866e5b51
FC
99 String right = result.substring(0, left.length());
100
101 assertEquals(left, right);
102 }
103}
This page took 0.039741 seconds and 5 git commands to generate.