package org.eclipse.linuxtools.ctf.core.tests.trace;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* The class <code>StreamInputTest</code> contains tests for the class
* <code>{@link StreamInput}</code>.
- *
+ *
* @author ematkho
* @version $Revision: 1.0 $
*/
/**
* Launch the test.
- *
+ *
* @param args
* the command line arguments
*/
/**
* Perform pre-test initialization.
- *
- * @throws CTFReaderException
+ *
+ * @throws CTFReaderException
*/
@Before
public void setUp() throws CTFReaderException {
/**
* Run the FileChannel getFileChannel() method test.
- *
- * @throws IOException
+ *
+ * @throws IOException
*/
@Test
public void testGetFileChannel() throws IOException {
@Test
public void testSetTimestampEnd() {
fixture.setTimestampEnd(1L);
+ assertEquals(fixture.getTimestampEnd(), 1L);
+ }
+
+ StreamInput s1;
+ StreamInput s2;
+
+
+ @Test
+ public void testEquals1() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ assertFalse(s1.equals(null));
+ }
+
+ @Test
+ public void testEquals2() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ assertFalse(s1.equals(new Long(23L)));
+
+ }
+ @Test
+ public void testEquals3() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ assertEquals(s1,s1);
+
+ }
+ @Test
+ public void testEquals4() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ s2 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ assertEquals(s1,s2);
+ }
+ @Test
+ public void testEquals5() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ s2 = new StreamInput(new Stream(null),
+ (FileChannel) null, new File("")); //$NON-NLS-1$
+ assertFalse(s1.equals(s2));
+ }
+ @Test
+ public void testEquals6(){
+ s1 = new StreamInput(new Stream(null),
+ (FileChannel) null, null);
+ s2 = new StreamInput(new Stream(null),
+ (FileChannel) null, new File("")); //$NON-NLS-1$
+
+
+ assertFalse(s1.equals(s2));
+ }
+ @Test
+ public void testEquals7() throws CTFReaderException{
+ s1 = new StreamInput(new Stream(null),
+ (FileChannel) null, new File("")); //$NON-NLS-1$
+ s2 = new StreamInput(new Stream(TestParams.createTrace()),
+ (FileChannel) null, createFile());
+ assertFalse(s1.equals(s2));
}
}
\ No newline at end of file
assertNotNull(ed.toString());
ed.setContext( ed.getFields());
assertNotNull(ed.toString());
+ }
+
+ EventDeclaration e1;
+ EventDeclaration e2;
+
+
+ @Test
+ public void testEquals1(){
+ e1 = new EventDeclaration();
+ assertFalse(e1.equals(null));
+ }
+
+ @Test
+ public void testEquals2(){
+ e1 = EventDeclaration.getLostEventDeclaration();
+ assertFalse(e1.equals(new Long(23L)));
+ }
+
+ @Test
+ public void testEquals3(){
+ e1 = EventDeclaration.getLostEventDeclaration();
+ assertEquals(e1,e1);
+ }
+ @Test
+ public void testEquals4(){
+ e1 = EventDeclaration.getLostEventDeclaration();
+ e2 = EventDeclaration.getLostEventDeclaration();
+ assertEquals(e1,e2);
+ }
+
+ @Test
+ public void testEquals5(){
+ e1 = EventDeclaration.getLostEventDeclaration();
+ e2 = new EventDeclaration();
+ assertFalse(e1.equals(e2));
}
}
return "[declaration] struct[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result)
+ + ((fieldsList == null) ? 0 : fieldsList.hashCode());
+ result = (prime * result) + (int) (maxAlign ^ (maxAlign >>> 32));
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof StructDeclaration)) {
+ return false;
+ }
+ StructDeclaration other = (StructDeclaration) obj;
+ if (fieldsList == null) {
+ if (other.fieldsList != null) {
+ return false;
+ }
+ } else if (!fieldsList.equals(other.fieldsList)) {
+ return false;
+ }
+ if (maxAlign != other.maxAlign) {
+ return false;
+ }
+ return true;
+ }
+
}