add check for time point contained in TimeSpan
This commit is contained in:
parent
b9861ef88f
commit
481875a78a
2 changed files with 33 additions and 2 deletions
|
|
@ -409,8 +409,14 @@ namespace time {
|
|||
Time
|
||||
end() const
|
||||
{
|
||||
TimeVar startPoint (*this);
|
||||
return (startPoint + dur_);
|
||||
return TimeVar(*this) += dur_;
|
||||
}
|
||||
|
||||
bool
|
||||
contains (TimeValue const& tp) const
|
||||
{
|
||||
return *this <= tp
|
||||
&& tp < end();
|
||||
}
|
||||
|
||||
/** may change start / duration */
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ namespace test{
|
|||
buildDuration (ref);
|
||||
buildTimeSpan (ref);
|
||||
compareTimeSpan (ref);
|
||||
relateTimeIntervals (ref);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -381,6 +382,30 @@ namespace test{
|
|||
CHECK (span3y.end() < span3z.end());
|
||||
CHECK (Time(span3) < Time(span3z));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
relateTimeIntervals (TimeValue org)
|
||||
{
|
||||
TimeSpan span1 (org, FSecs(2));
|
||||
TimeSpan span2 (org+Time(FSecs(1)), FSecs(2));
|
||||
|
||||
TimeVar probe(org);
|
||||
CHECK ( span1.contains(probe));
|
||||
CHECK (!span2.contains(probe));
|
||||
|
||||
probe = span2;
|
||||
CHECK ( span1.contains(probe));
|
||||
CHECK ( span2.contains(probe));
|
||||
|
||||
probe = span1.end();
|
||||
CHECK (!span1.contains(probe)); // Note: end is always exclusive
|
||||
CHECK ( span2.contains(probe));
|
||||
|
||||
probe = span2.end();
|
||||
CHECK (!span1.contains(probe));
|
||||
CHECK (!span2.contains(probe));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue