Commit | Line | Data |
---|---|---|
81c8e6f7 MK |
1 | package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor; |
2 | ||
3 | import static org.junit.Assert.assertEquals; | |
4 | import static org.junit.Assert.assertNotNull; | |
5 | ||
6 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp; | |
7 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp.TimestampType; | |
8 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; | |
9 | import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; | |
10 | import org.junit.After; | |
11 | import org.junit.Before; | |
12 | import org.junit.Test; | |
13 | ||
14 | /** | |
15 | * The class <code>CtfTmfTimestampTest</code> contains tests for the class <code>{@link CtfTmfTimestamp}</code>. | |
16 | * | |
17 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
18 | * @author ematkho | |
19 | * @version $Revision: 1.0 $ | |
20 | */ | |
21 | public class CtfTmfTimestampTest { | |
22 | /** | |
23 | * Run the CtfTmfTimestamp(long) constructor test. | |
24 | * | |
25 | * @throws Exception | |
26 | * | |
27 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
28 | */ | |
29 | @Test | |
30 | public void testCtfTmfTimestamp() | |
31 | throws Exception { | |
32 | long timestamp = 1L; | |
33 | ||
34 | CtfTmfTimestamp result = new CtfTmfTimestamp(timestamp); | |
35 | result.setType(TimestampType.NANOS); | |
36 | ||
37 | // add additional test code here | |
38 | assertNotNull(result); | |
39 | assertEquals("1 ns", result.toString()); //$NON-NLS-1$ | |
40 | assertEquals(0, result.getPrecision()); | |
41 | assertEquals(-9, result.getScale()); | |
42 | assertEquals(1L, result.getValue()); | |
43 | } | |
44 | ||
45 | ||
46 | /** | |
47 | * Run the boolean equals(Object) method test. | |
48 | * | |
49 | * @throws Exception | |
50 | * | |
51 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
52 | */ | |
53 | @Test | |
54 | public void testEquals_1() | |
55 | throws Exception { | |
56 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
57 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
58 | CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); | |
59 | obj.setType(CtfTmfTimestamp.TimestampType.DAY); | |
60 | ||
61 | boolean result = fixture.equals(obj); | |
62 | ||
63 | // add additional test code here | |
64 | assertEquals(true, result); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Run the boolean equals(Object) method test. | |
69 | * | |
70 | * @throws Exception | |
71 | * | |
72 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
73 | */ | |
74 | @Test | |
75 | public void testEquals_2() | |
76 | throws Exception { | |
77 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
78 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
79 | Object obj = new Object(); | |
80 | ||
81 | boolean result = fixture.equals(obj); | |
82 | ||
83 | // add additional test code here | |
84 | assertEquals(false, result); | |
85 | } | |
86 | ||
87 | /** | |
88 | * Run the boolean equals(Object) method test. | |
89 | * | |
90 | * @throws Exception | |
91 | * | |
92 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
93 | */ | |
94 | @Test | |
95 | public void testEquals_3() | |
96 | throws Exception { | |
97 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
98 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
99 | Object obj = new Object(); | |
100 | ||
101 | boolean result = fixture.equals(obj); | |
102 | ||
103 | // add additional test code here | |
104 | assertEquals(false, result); | |
105 | } | |
106 | ||
107 | /** | |
108 | * Run the boolean equals(Object) method test. | |
109 | * | |
110 | * @throws Exception | |
111 | * | |
112 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
113 | */ | |
114 | @Test | |
115 | public void testEquals_4() | |
116 | throws Exception { | |
117 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
118 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
119 | CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); | |
120 | obj.setType(CtfTmfTimestamp.TimestampType.DAY); | |
121 | ||
122 | boolean result = fixture.equals(obj); | |
123 | ||
124 | // add additional test code here | |
125 | assertEquals(true, result); | |
126 | } | |
127 | ||
128 | /** | |
129 | * Run the boolean equals(Object) method test. | |
130 | * | |
131 | * @throws Exception | |
132 | * | |
133 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
134 | */ | |
135 | @Test | |
136 | public void testEquals_5() | |
137 | throws Exception { | |
138 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
139 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
140 | CtfTmfTimestamp obj = new CtfTmfTimestamp(1L); | |
141 | obj.setType(CtfTmfTimestamp.TimestampType.DAY); | |
142 | ||
143 | boolean result = fixture.equals(obj); | |
144 | ||
145 | // add additional test code here | |
146 | assertEquals(true, result); | |
147 | } | |
148 | ||
149 | /** | |
150 | * Run the ITmfTimestamp getDelta(ITmfTimestamp) method test. | |
151 | * | |
152 | * @throws Exception | |
153 | * | |
154 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
155 | */ | |
156 | @Test | |
157 | public void testGetDelta_1() | |
158 | throws Exception { | |
159 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
160 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
161 | ITmfTimestamp ts = new TmfTimestamp(); | |
162 | ||
163 | ITmfTimestamp result = fixture.getDelta(ts); | |
164 | ||
165 | // add additional test code here | |
166 | assertNotNull(result); | |
167 | assertEquals(0, result.getPrecision()); | |
168 | assertEquals(-9, result.getScale()); | |
169 | assertEquals(1L, result.getValue()); | |
170 | } | |
171 | ||
172 | /** | |
173 | * Run the ITmfTimestamp getDelta(ITmfTimestamp) method test. | |
174 | * | |
175 | * @throws Exception | |
176 | * | |
177 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
178 | */ | |
179 | @Test | |
180 | public void testGetDelta_2() | |
181 | throws Exception { | |
182 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
183 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
184 | ITmfTimestamp ts = new TmfTimestamp(); | |
185 | ||
186 | ITmfTimestamp result = fixture.getDelta(ts); | |
187 | ||
188 | // add additional test code here | |
189 | assertNotNull(result); | |
190 | assertEquals(0, result.getPrecision()); | |
191 | assertEquals(-9, result.getScale()); | |
192 | assertEquals(1L, result.getValue()); | |
193 | } | |
194 | ||
195 | /** | |
196 | * Run the CtfTmfTimestamp.TimestampType getType() method test. | |
197 | * | |
198 | * @throws Exception | |
199 | * | |
200 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
201 | */ | |
202 | @Test | |
203 | public void testGetType_1() | |
204 | throws Exception { | |
205 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
206 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
207 | ||
208 | CtfTmfTimestamp.TimestampType result = fixture.getType(); | |
209 | ||
210 | // add additional test code here | |
211 | assertNotNull(result); | |
212 | assertEquals("DAY", result.name()); //$NON-NLS-1$ | |
213 | assertEquals("DAY", result.toString()); //$NON-NLS-1$ | |
214 | assertEquals(1, result.ordinal()); | |
215 | } | |
216 | ||
217 | /** | |
218 | * Run the int hashCode() method test. | |
219 | * | |
220 | * @throws Exception | |
221 | * | |
222 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
223 | */ | |
224 | @Test | |
225 | public void testHashCode_1() | |
226 | throws Exception { | |
227 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
228 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
229 | ||
230 | int result = fixture.hashCode(); | |
231 | ||
232 | // add additional test code here | |
233 | assertEquals(1012115, result); | |
234 | } | |
235 | ||
236 | /** | |
237 | * Run the int hashCode() method test. | |
238 | * | |
239 | * @throws Exception | |
240 | * | |
241 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
242 | */ | |
243 | @Test | |
244 | public void testHashCode_2() | |
245 | throws Exception { | |
246 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
247 | fixture.setType(null); | |
248 | ||
249 | int result = fixture.hashCode(); | |
250 | ||
251 | // add additional test code here | |
252 | assertEquals(944663, result); | |
253 | } | |
254 | ||
255 | /** | |
256 | * Run the void setType(TimestampType) method test. | |
257 | * | |
258 | * @throws Exception | |
259 | * | |
260 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
261 | */ | |
262 | @Test | |
263 | public void testSetType_1() | |
264 | throws Exception { | |
265 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
266 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
267 | CtfTmfTimestamp.TimestampType value = CtfTmfTimestamp.TimestampType.DAY; | |
268 | ||
269 | fixture.setType(value); | |
270 | ||
271 | // add additional test code here | |
272 | } | |
273 | ||
274 | /** | |
275 | * Run the String toString() method test. | |
276 | * | |
277 | * @throws Exception | |
278 | * | |
279 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
280 | */ | |
281 | @Test | |
282 | public void testToString_1() | |
283 | throws Exception { | |
284 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
285 | fixture.setType(CtfTmfTimestamp.TimestampType.NANOS); | |
286 | ||
287 | String result = fixture.toString(); | |
288 | ||
289 | // add additional test code here | |
290 | assertEquals("1 ns", result); //$NON-NLS-1$ | |
291 | } | |
292 | ||
293 | /** | |
294 | * Run the String toString() method test. | |
295 | * | |
296 | * @throws Exception | |
297 | * | |
298 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
299 | */ | |
300 | @Test | |
301 | public void testToString_2() | |
302 | throws Exception { | |
303 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
304 | fixture.setType(CtfTmfTimestamp.TimestampType.SECONDS); | |
305 | ||
306 | String result = fixture.toString(); | |
307 | ||
308 | // add additional test code here | |
309 | assertEquals("1.0E-9 s", result); //$NON-NLS-1$ | |
310 | } | |
311 | ||
312 | /** | |
313 | * Run the String toString() method test. | |
314 | * | |
315 | * @throws Exception | |
316 | * | |
317 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
318 | */ | |
319 | @Test | |
320 | public void testToString_3() | |
321 | throws Exception { | |
322 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
323 | fixture.setType(CtfTmfTimestamp.TimestampType.DAY); | |
324 | ||
325 | String result = fixture.toString(); | |
326 | ||
327 | // add additional test code here | |
328 | assertEquals("19:00:00.000000001", result); //$NON-NLS-1$ | |
329 | } | |
330 | ||
331 | /** | |
332 | * Run the String toString() method test. | |
333 | * | |
334 | * @throws Exception | |
335 | * | |
336 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
337 | */ | |
338 | @Test | |
339 | public void testToString_4() | |
340 | throws Exception { | |
341 | CtfTmfTimestamp fixture = new CtfTmfTimestamp(1L); | |
342 | fixture.setType(CtfTmfTimestamp.TimestampType.FULL_DATE); | |
343 | ||
344 | String result = fixture.toString(); | |
345 | ||
346 | // add additional test code here | |
347 | assertEquals("1969-12-31 19:00:00.000000001", result); //$NON-NLS-1$ | |
348 | } | |
349 | ||
350 | /** | |
351 | * Perform pre-test initialization. | |
352 | * | |
353 | * @throws Exception | |
354 | * if the initialization fails for some reason | |
355 | * | |
356 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
357 | */ | |
358 | @Before | |
359 | public void setUp() | |
360 | throws Exception { | |
361 | // add additional set up code here | |
362 | } | |
363 | ||
364 | /** | |
365 | * Perform post-test clean-up. | |
366 | * | |
367 | * @throws Exception | |
368 | * if the clean-up fails for some reason | |
369 | * | |
370 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
371 | */ | |
372 | @After | |
373 | public void tearDown() | |
374 | throws Exception { | |
375 | // Add additional tear down code here | |
376 | } | |
377 | ||
378 | /** | |
379 | * Launch the test. | |
380 | * | |
381 | * @param args the command line arguments | |
382 | * | |
383 | * @generatedBy CodePro at 03/05/12 2:29 PM | |
384 | */ | |
385 | public static void main(String[] args) { | |
386 | new org.junit.runner.JUnitCore().run(CtfTmfTimestampTest.class); | |
387 | } | |
388 | } |