diff options
author | Matthew Khouzam | 2012-05-03 22:55:57 +0000 |
---|---|---|
committer | Matthew Khouzam | 2012-05-03 22:56:58 +0000 |
commit | 3dc0613f6e647e5f8c5312b01a74d65ed243acc7 (patch) | |
tree | b385d6c91e59a70be01788e77537be6bf4f3cc8b /lttng/org.eclipse.linuxtools.tmf.core | |
parent | ab1843f1f0e06dbfb81360c81592c4efa714884e (diff) | |
download | org.eclipse.linuxtools-3dc0613f6e647e5f8c5312b01a74d65ed243acc7.tar.gz org.eclipse.linuxtools-3dc0613f6e647e5f8c5312b01a74d65ed243acc7.tar.xz org.eclipse.linuxtools-3dc0613f6e647e5f8c5312b01a74d65ed243acc7.zip |
Improve test cases. Coverage of 85%+ and fix bugs.
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core')
4 files changed, 49 insertions, 8 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java index e0bc5b9630..db31c723c0 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java @@ -67,4 +67,41 @@ public class CtfLocation implements ITmfLocation<Long> { return new CtfLocation(getLocation()); } + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = (prime * result) + + ((fTimestamp == null) ? 0 : fTimestamp.hashCode()); + 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 CtfLocation)) { + return false; + } + CtfLocation other = (CtfLocation) obj; + if (fTimestamp == null) { + if (other.fTimestamp != null) { + return false; + } + } else if (!fTimestamp.equals(other.fTimestamp)) { + return false; + } + return true; + } + } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java index 49b150139e..acb3a658c2 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java @@ -156,7 +156,8 @@ public final class CtfTmfEvent implements ITmfEvent { this.typeId = -1; this.fileName = NO_STREAM; this.eventName = EMPTY_CTF_EVENT_NAME; - this.fContent = null; + this.fContent = new CtfTmfContent("", new CtfTmfEventField[0]); + } // ------------------------------------------------------------------------ diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java index 6e5353ccbb..2fa7d65e17 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java @@ -43,7 +43,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { * @param name String */ protected CtfTmfEventField(String name) { - /* Strip the damn underscores, screw you CTF */ + /* Strip the underscore*/ if ( name.startsWith("_") ) { //$NON-NLS-1$ this.name = name.substring(1); } else { @@ -150,6 +150,9 @@ public abstract class CtfTmfEventField implements ITmfEventField { case 2: return new CTFIntegerArrayField( ((CTFIntegerArrayField) other).getValue(), other.name); + case 3: + return new CTFFloatField( + ((CTFFloatField) other).getValue(), other.name); default: return null; } @@ -168,7 +171,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { /** * Return the int representing this field's value type * - + * @return the field type */ public abstract int getFieldType(); @@ -176,7 +179,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { * Return this field's value. You can cast it to the correct type depending * on what getFieldType says. * - + * @return the field value * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue() */ @Override @@ -186,7 +189,7 @@ public abstract class CtfTmfEventField implements ITmfEventField { * Other methods defined by ITmfEventField, but not used here: the CTF * fields do not have sub-fields (yet!) * - + * @return the field names * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getFieldNames() */ @Override @@ -426,7 +429,7 @@ final class CTFFloatField extends CtfTmfEventField { * @see org.eclipse.linuxtools.tmf.core.event.ITmfEventField#getValue() */ @Override - public Object getValue() { + public Double getValue() { return this.value; } diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java index c0464fa546..9e1deddc46 100644 --- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java +++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTimestamp.java @@ -171,8 +171,8 @@ public class CtfTmfTimestamp extends TmfTimestamp { @Override public int hashCode() { final int prime = 31; - int result = super.hashCode(); - result = (prime * result) + ((type == null) ? 0 : type.hashCode()); + int result = super.hashCode() * prime; + result += ((type == null) ? 0 : type.toString().hashCode()); return result; } |