Commit | Line | Data |
---|---|---|
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 |
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.assertNull; | |
17 | import static org.junit.Assert.assertTrue; | |
18 | ||
19 | import java.nio.ByteOrder; | |
20 | ||
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; | |
29 | ||
30 | /** | |
31 | * The class <code>EnumDeclarationTest</code> contains tests for the class | |
32 | * <code>{@link EnumDeclaration}</code>. | |
284fdee8 | 33 | * |
866e5b51 FC |
34 | * @author ematkho |
35 | * @version $Revision: 1.0 $ | |
36 | */ | |
37 | public class EnumDeclarationTest { | |
38 | ||
39 | private EnumDeclaration fixture; | |
40 | ||
41 | /** | |
42 | * Launch the test. | |
284fdee8 | 43 | * |
866e5b51 FC |
44 | * @param args |
45 | * the command line arguments | |
46 | */ | |
47 | public static void main(String[] args) { | |
48 | new org.junit.runner.JUnitCore().run(EnumDeclarationTest.class); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Perform pre-test initialization. | |
53 | */ | |
54 | @Before | |
55 | public void setUp() { | |
56 | fixture = new EnumDeclaration(new IntegerDeclaration(1, true, 1, | |
fd74e6c1 | 57 | ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8)); |
866e5b51 FC |
58 | } |
59 | ||
60 | /** | |
61 | * Perform post-test clean-up. | |
62 | */ | |
63 | @After | |
64 | public void tearDown() { | |
65 | // Add additional tear down code here | |
66 | } | |
67 | ||
68 | /** | |
69 | * Run the EnumDeclaration(IntegerDeclaration) constructor test. | |
70 | */ | |
71 | @Test | |
72 | public void testEnumDeclaration() { | |
73 | IntegerDeclaration containerType = new IntegerDeclaration(1, true, 1, | |
fd74e6c1 | 74 | ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8); |
866e5b51 FC |
75 | |
76 | EnumDeclaration result = new EnumDeclaration(containerType); | |
77 | ||
78 | assertNotNull(result); | |
4a9c1f07 | 79 | String left = "[declaration] enum["; |
866e5b51 FC |
80 | assertEquals(left, result.toString().substring(0, left.length())); |
81 | } | |
82 | ||
83 | /** | |
84 | * Run the boolean add(long,long,String) method test. | |
85 | */ | |
86 | @Test | |
87 | public void testAdd() { | |
88 | long low = 1L; | |
89 | long high = 1L; | |
4a9c1f07 | 90 | String label = ""; |
866e5b51 FC |
91 | |
92 | boolean result = fixture.add(low, high, label); | |
93 | ||
94 | assertTrue(result); | |
95 | } | |
96 | ||
97 | /** | |
98 | * Run the EnumDefinition createDefinition(DefinitionScope,String) method | |
99 | * test. | |
100 | */ | |
101 | @Test | |
102 | public void testCreateDefinition() { | |
103 | IDefinitionScope definitionScope = null; | |
4a9c1f07 | 104 | String fieldName = ""; |
866e5b51 FC |
105 | |
106 | EnumDefinition result = fixture.createDefinition(definitionScope, | |
107 | fieldName); | |
108 | ||
109 | assertNotNull(result); | |
110 | } | |
111 | ||
866e5b51 FC |
112 | /** |
113 | * Run the String query(long) method test. | |
114 | */ | |
115 | @Test | |
116 | public void testQuery() { | |
117 | long value = 0; | |
118 | String result = fixture.query(value); | |
119 | ||
120 | assertNull(result); | |
121 | } | |
122 | ||
123 | /** | |
124 | * Run the String toString() method test. | |
125 | */ | |
126 | @Test | |
127 | public void testToString() { | |
128 | String result = fixture.toString(); | |
129 | ||
4a9c1f07 | 130 | String left = "[declaration] enum["; |
866e5b51 FC |
131 | assertEquals(left, result.substring(0, left.length())); |
132 | } | |
133 | } |