Search in sources :

Example 6 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TmfNanoTimestampTest method testBasicCompareTo.

// ------------------------------------------------------------------------
// compareTo
// ------------------------------------------------------------------------
@Test
public void testBasicCompareTo() {
    final ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(900);
    final ITmfTimestamp tstamp2 = TmfTimestamp.fromNanos(1000);
    final ITmfTimestamp tstamp3 = TmfTimestamp.fromNanos(1100);
    assertTrue(tstamp1.compareTo(tstamp1) == 0);
    assertTrue("CompareTo", tstamp1.compareTo(tstamp2) < 0);
    assertTrue("CompareTo", tstamp1.compareTo(tstamp3) < 0);
    assertTrue("CompareTo", tstamp2.compareTo(tstamp1) > 0);
    assertTrue("CompareTo", tstamp2.compareTo(tstamp3) < 0);
    assertTrue("CompareTo", tstamp3.compareTo(tstamp1) > 0);
    assertTrue("CompareTo", tstamp3.compareTo(tstamp2) > 0);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 7 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TmfNanoTimestampTest method testDelta.

// ------------------------------------------------------------------------
// getDelta
// ------------------------------------------------------------------------
@Test
public void testDelta() {
    // Delta for same scale and precision (delta > 0)
    ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10);
    ITmfTimestamp tstamp1 = TmfTimestamp.fromNanos(5);
    ITmfTimestamp expectd = TmfTimestamp.fromNanos(5);
    ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
    assertEquals("getDelta", 0, delta.compareTo(expectd));
    // Delta for same scale and precision (delta < 0)
    tstamp0 = TmfTimestamp.fromSeconds(5);
    tstamp1 = TmfTimestamp.fromSeconds(10);
    expectd = TmfTimestamp.fromSeconds(-5);
    delta = tstamp0.getDelta(tstamp1);
    assertEquals("getDelta", 0, delta.compareTo(expectd));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 8 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TmfNanoTimestampTest method testDelta2.

@Test
public void testDelta2() {
    // Delta for different scale and same precision (delta > 0)
    final ITmfTimestamp tstamp0 = TmfTimestamp.fromNanos(10);
    final ITmfTimestamp tstamp1 = TmfTimestamp.create(1, -8);
    final ITmfTimestamp expectd = TmfTimestamp.create(0, 0);
    final ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
    assertEquals("getDelta", 0, delta.compareTo(expectd));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 9 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TmfSecondTimestampTest method testHashCode.

// ------------------------------------------------------------------------
// hashCode
// ------------------------------------------------------------------------
@Test
public void testHashCode() {
    final ITmfTimestamp ts0copy = TmfTimestamp.create(ts0.getValue(), ts0.getScale());
    final ITmfTimestamp ts1copy = TmfTimestamp.create(ts1.getValue(), ts1.getScale());
    final ITmfTimestamp ts2copy = TmfTimestamp.create(ts2.getValue(), ts2.getScale());
    assertEquals("hashCode", ts0.hashCode(), ts0copy.hashCode());
    assertEquals("hashCode", ts1.hashCode(), ts1copy.hashCode());
    assertEquals("hashCode", ts2.hashCode(), ts2copy.hashCode());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 10 with ITmfTimestamp

use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.

the class TmfSecondTimestampTest method testNormalizeScaleNot0.

@Test
public void testNormalizeScaleNot0() {
    ITmfTimestamp ts = ts0.normalize(0, 1);
    assertEquals("Zero test", TmfTimestamp.ZERO, ts);
    ts = ts0.normalize(12345, 1);
    assertEquals("getValue", 12345, ts.getValue());
    assertEquals("getscale", 1, ts.getScale());
    ts = ts0.normalize(10, 1);
    assertEquals("getValue", 10, ts.getValue());
    assertEquals("getscale", 1, ts.getScale());
    ts = ts0.normalize(-10, 1);
    assertEquals("getValue", -10, ts.getValue());
    assertEquals("getscale", 1, ts.getScale());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Aggregations

ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)162 Test (org.junit.Test)102 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)52 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)12 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)10 Point (org.eclipse.swt.graphics.Point)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)8 ArrayList (java.util.ArrayList)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4 File (java.io.File)3 Path (java.nio.file.Path)3 HashSet (java.util.HashSet)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3