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);
}
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));
}
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));
}
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());
}
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());
}
Aggregations