use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimestampDeltaTest method testCopyConstructor.
@Test
public void testCopyConstructor() {
final ITmfTimestamp ts = TmfTimestamp.create(12345, 2);
final ITmfTimestamp copy = TmfTimestamp.create(12345, 2);
assertEquals("getValue", ts.getValue(), copy.getValue());
assertEquals("getscale", ts.getScale(), copy.getScale());
assertEquals("getValue", 12345, copy.getValue());
assertEquals("getscale", 2, copy.getScale());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimestampDeltaTest method testNormalizeOffset.
// ------------------------------------------------------------------------
// normalize
// ------------------------------------------------------------------------
@Test
public void testNormalizeOffset() {
ITmfTimestamp ts = ts0.normalize(12345, 0);
assertTrue("instance", ts instanceof TmfTimestampDelta);
assertEquals("getValue", 12345, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimestampTest method testCompareToLargeScale3.
@Test
public void testCompareToLargeScale3() {
final ITmfTimestamp ts0a = TmfTimestamp.create(1, Integer.MAX_VALUE);
final ITmfTimestamp ts0b = TmfTimestamp.create(2, Integer.MAX_VALUE);
assertTrue("CompareTo", ts0b.compareTo(ts0a) > 0);
assertTrue("CompareTo", ts0a.compareTo(ts0b) < 0);
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimestampTest method testNormalizeOffsetUpperLimits.
@Test
public void testNormalizeOffsetUpperLimits() {
final ITmfTimestamp ref = TmfTimestamp.create(Long.MAX_VALUE - 5, 0);
ITmfTimestamp ts = ref.normalize(4, 0);
assertEquals("getValue", Long.MAX_VALUE - 1, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
ts = ref.normalize(5, 0);
assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
ts = ref.normalize(6, 0);
assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
}
use of org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp in project tracecompass by tracecompass.
the class TmfTimestampTest method testDelta.
// ------------------------------------------------------------------------
// getDelta
// ------------------------------------------------------------------------
@Test
public void testDelta() {
// Delta for same scale and precision (delta > 0)
ITmfTimestamp t0 = TmfTimestamp.create(10, 9);
ITmfTimestamp t1 = TmfTimestamp.create(5, 9);
ITmfTimestamp exp = TmfTimestamp.create(5, 9);
ITmfTimestamp delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for same scale and precision (delta < 0)
t0 = TmfTimestamp.create(5, 9);
t1 = TmfTimestamp.create(10, 9);
exp = TmfTimestamp.create(-5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision (delta > 0)
t0 = TmfTimestamp.create(5, 9);
t1 = TmfTimestamp.create(10, 8);
exp = TmfTimestamp.create(4, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision (delta > 0)
t0 = TmfTimestamp.create(5, 9);
t1 = TmfTimestamp.create(10, 7);
exp = TmfTimestamp.create(5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale and same precision
t0 = TmfTimestamp.create(10, 9);
t1 = TmfTimestamp.create(5, 8);
exp = TmfTimestamp.create(10, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for same scale
t0 = TmfTimestamp.create(10, 9);
t1 = TmfTimestamp.create(5, 9);
exp = TmfTimestamp.create(5, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
// Delta for different scale
t0 = TmfTimestamp.create(5, 9);
t1 = TmfTimestamp.create(10, 8);
exp = TmfTimestamp.create(4, 9);
delta = t0.getDelta(t1);
assertEquals("getDelta", 0, delta.compareTo(exp));
}
Aggregations