use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfSecondTimestampTest method testDelta.
// ------------------------------------------------------------------------
// getDelta
// ------------------------------------------------------------------------
@Test
public void testDelta() {
// Delta for same scale and precision (delta > 0)
ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10);
ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(5);
ITmfTimestamp expectd = TmfTimestamp.fromSeconds(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 TmfSecondTimestampTest method testNormalizeScale0.
// ------------------------------------------------------------------------
// normalize
// ------------------------------------------------------------------------
@Test
public void testNormalizeScale0() {
ITmfTimestamp ts = ts0.normalize(0, 0);
assertEquals("getValue", 0, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
ts = ts0.normalize(12345, 0);
assertEquals("getValue", 12345, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
ts = ts0.normalize(10, 0);
assertEquals("getValue", 10, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
ts = ts0.normalize(-10, 0);
assertEquals("getValue", -10, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimeRangeTest method testContainsRange.
@Test
public void testContainsRange() {
final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(10);
final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(20);
final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(30);
final ITmfTimestamp ts4 = TmfTimestamp.fromSeconds(40);
final ITmfTimestamp ts5 = TmfTimestamp.fromSeconds(50);
final ITmfTimestamp ts6 = TmfTimestamp.fromSeconds(60);
final ITmfTimestamp ts7 = TmfTimestamp.fromSeconds(70);
final ITmfTimestamp ts8 = TmfTimestamp.fromSeconds(80);
// Reference range
final TmfTimeRange range0 = new TmfTimeRange(ts3, ts6);
// Start time below range
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3);
final TmfTimeRange range3 = new TmfTimeRange(ts2, ts4);
final TmfTimeRange range4 = new TmfTimeRange(ts2, ts6);
final TmfTimeRange range5 = new TmfTimeRange(ts2, ts7);
assertFalse("contains", range0.contains(range1));
assertFalse("contains", range0.contains(range2));
assertFalse("contains", range0.contains(range3));
assertFalse("contains", range0.contains(range4));
assertFalse("contains", range0.contains(range5));
// End time above range
final TmfTimeRange range6 = new TmfTimeRange(ts3, ts7);
final TmfTimeRange range7 = new TmfTimeRange(ts4, ts7);
final TmfTimeRange range8 = new TmfTimeRange(ts6, ts7);
final TmfTimeRange range9 = new TmfTimeRange(ts7, ts8);
assertFalse("contains", range0.contains(range6));
assertFalse("contains", range0.contains(range7));
assertFalse("contains", range0.contains(range8));
assertFalse("contains", range0.contains(range9));
// Within range
final TmfTimeRange range10 = new TmfTimeRange(ts3, ts4);
final TmfTimeRange range11 = new TmfTimeRange(ts3, ts6);
final TmfTimeRange range12 = new TmfTimeRange(ts4, ts5);
final TmfTimeRange range13 = new TmfTimeRange(ts4, ts6);
assertTrue("contains", range0.contains(range10));
assertTrue("contains", range0.contains(range11));
assertTrue("contains", range0.contains(range12));
assertTrue("contains", range0.contains(range13));
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimeRangeTest method testOpenRange2.
@Test
public void testOpenRange2() {
final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
assertEquals("startTime", ts1, range.getStartTime());
assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimeRangeTest method testEqualsBadType.
@Test
public void testEqualsBadType() {
final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
assertTrue("equals", !range1.equals(ts1));
}
Aggregations