ctf: Disable NLS warnings in test plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / StructDeclarationTest.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 import static org.junit.Assert.assertTrue;
17
18 import java.util.HashMap;
19 import java.util.List;
20
21 import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration;
22 import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
23 import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
24 import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 /**
30 * The class <code>StructDeclarationTest</code> contains tests for the class
31 * <code>{@link StructDeclaration}</code>.
32 *
33 * @author ematkho
34 * @version $Revision: 1.0 $
35 */
36 public class StructDeclarationTest {
37
38 private StructDeclaration fixture;
39
40 /**
41 * Launch the test.
42 *
43 * @param args
44 * the command line arguments
45 */
46 public static void main(String[] args) {
47 new org.junit.runner.JUnitCore().run(StructDeclarationTest.class);
48 }
49
50 /**
51 * Perform pre-test initialization.
52 */
53 @Before
54 public void setUp() {
55 fixture = new StructDeclaration(1L);
56 }
57
58 /**
59 * Perform post-test clean-up.
60 */
61 @After
62 public void tearDown() {
63 // Add additional tear down code here
64 }
65
66 /**
67 * Run the StructDeclaration(long) constructor test.
68 */
69 @Test
70 public void testStructDeclaration() {
71 assertNotNull(fixture);
72 assertEquals(1L, fixture.getMaxAlign());
73
74 String regex = "^\\[declaration\\] struct\\[[0-9a-f]{1,8}\\]$";
75 assertTrue(fixture.toString().matches(regex));
76 }
77
78 /**
79 * Run the void addField(String,Declaration) method test.
80 */
81 @Test
82 public void testAddField() {
83 String name = "";
84 IDeclaration declaration = new StringDeclaration();
85 fixture.addField(name, declaration);
86 }
87
88 /**
89 * Run the StructDefinition createDefinition(DefinitionScope,String) method
90 * test.
91 */
92 @Test
93 public void testCreateDefinition() {
94 String fieldName = "";
95 StructDefinition result = fixture.createDefinition(null, fieldName);
96 assertNotNull(result);
97 }
98
99 /**
100 * Run the HashMap<String, Declaration> getFields() method test.
101 */
102 @Test
103 public void testGetFields() {
104 HashMap<String, IDeclaration> result = fixture.getFields();
105
106 assertNotNull(result);
107 assertEquals(0, result.size());
108 }
109
110 /**
111 * Run the List<String> getFieldsList() method test.
112 */
113 @Test
114 public void testGetFieldsList() {
115 List<String> result = fixture.getFieldsList();
116
117 assertNotNull(result);
118 assertEquals(0, result.size());
119 }
120
121 /**
122 * Run the long getMinAlign() method test.
123 */
124 @Test
125 public void testGetMinAlign() {
126 long result = fixture.getMaxAlign();
127 assertEquals(1L, result);
128 }
129
130 /**
131 * Run the boolean hasField(String) method test.
132 */
133 @Test
134 public void testHasField() {
135 String name = "";
136 boolean result = fixture.hasField(name);
137
138 assertEquals(false, result);
139 }
140
141 /**
142 * Run the String toString() method test.
143 */
144 @Test
145 public void testToString() {
146 String result = fixture.toString();
147 String trunc = result.substring(0, 21);
148
149 assertEquals("[declaration] struct[", trunc);
150 }
151 }
This page took 0.036047 seconds and 6 git commands to generate.