use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange 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.TmfTimeRange 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.TmfTimeRange 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));
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfTimeRangeTest method testEqualsEndTime.
@Test
public void testEqualsEndTime() {
final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(12355);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(ts1, ts3);
final TmfTimeRange range3 = new TmfTimeRange(ts2, ts3);
assertTrue("equals", !range1.equals(range2));
assertTrue("equals", !range1.equals(range3));
}
use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.
the class TmfTimeRangeTest method testHashCode.
// ------------------------------------------------------------------------
// hashCode
// ------------------------------------------------------------------------
@Test
public void testHashCode() {
final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range1b = new TmfTimeRange(ts1, ts2);
final TmfTimeRange range2 = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfTimeRange range2b = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
assertTrue("hashCode", range1.hashCode() == range1b.hashCode());
assertTrue("hashCode", range2.hashCode() == range2b.hashCode());
assertTrue("hashCode", range1.hashCode() != range2.hashCode());
}
Aggregations