rcp: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.ctf.core.tests / src / org / eclipse / tracecompass / ctf / core / tests / types / FloatDeclarationTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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.tracecompass.ctf.core.tests.types;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertTrue;
18
19 import java.nio.ByteOrder;
20
21 import org.eclipse.tracecompass.ctf.core.event.types.FloatDeclaration;
22 import org.junit.Test;
23
24 @SuppressWarnings("javadoc")
25 public class FloatDeclarationTest {
26 private FloatDeclaration fixture;
27
28 @Test
29 public void ctorTest() {
30 for (int i = 1; i < 20; i++) {
31 fixture = new FloatDeclaration(i, 32 - i, ByteOrder.nativeOrder(), 0);
32 assertNotNull(fixture);
33 }
34 }
35
36 @Test
37 public void getterTest() {
38 fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 1);
39 assertEquals(fixture.getAlignment(), 1);
40 assertEquals(fixture.getByteOrder(), ByteOrder.nativeOrder());
41 assertEquals(fixture.getExponent(), 8);
42 assertEquals(fixture.getMantissa(), 24);
43 }
44
45 @Test
46 public void toStringTest() {
47 fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
48 assertTrue(fixture.toString().contains("float"));
49 }
50
51 /**
52 * Test the hashcode
53 */
54 @Test
55 public void hashcodeTest() {
56 FloatDeclaration floatDeclaration = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
57 FloatDeclaration a = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
58 FloatDeclaration b = new FloatDeclaration(8, 24, ByteOrder.LITTLE_ENDIAN, 0);
59 assertEquals(a.hashCode(), floatDeclaration.hashCode());
60 assertNotEquals(b.hashCode(), floatDeclaration.hashCode());
61 assertEquals(floatDeclaration.hashCode(), floatDeclaration.hashCode());
62 }
63
64 /**
65 * Test the equals
66 */
67 @Test
68 public void equalsTest() {
69 FloatDeclaration a = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
70 FloatDeclaration b = new FloatDeclaration(8, 24, ByteOrder.LITTLE_ENDIAN, 0);
71 FloatDeclaration c = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 8);
72 FloatDeclaration d = new FloatDeclaration(8, 8, ByteOrder.BIG_ENDIAN, 0);
73 FloatDeclaration e = new FloatDeclaration(24, 24, ByteOrder.BIG_ENDIAN, 0);
74 FloatDeclaration f = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
75 assertNotEquals(a, null);
76 assertNotEquals(a, new Object());
77 assertNotEquals(a, b);
78 assertNotEquals(a, c);
79 assertNotEquals(a, d);
80 assertNotEquals(b, a);
81 assertNotEquals(c, a);
82 assertNotEquals(d, a);
83 assertNotEquals(e, a);
84 assertNotEquals(a, e);
85
86 assertEquals(a, f);
87 assertEquals(f, a);
88 assertEquals(a, a);
89 }
90 }
This page took 0.031896 seconds and 5 git commands to generate.