25 #include <boost/lexical_cast.hpp> 28 using boost::lexical_cast;
32 using LERR_(BOTTOM_VALUE);
48 random_or_get (Arg arg)
53 return 1 +
rani(10000);
56 return lexical_cast<gavl_time_t> (arg[1]);
69 verify_invalidFramerateProtection();
73 compareTimeSpan (
Time(ref));
74 relateTimeIntervals (ref);
75 verify_extremeValues();
76 verify_fractionalOffset();
131 CHECK (zero == (var - 2*(org + two)) );
134 CHECK (var == 2*two + org + org);
138 CHECK (zero == (var - org));
143 CHECK (var > Time::MIN);
145 gavl_time_t raw (var);
147 CHECK (raw > org - two);
150 CHECK (zero == -var + var);
151 CHECK (zero != -var);
174 CHECK (0.5 == boost::rational_cast<double> (halve));
185 CHECK (
"1:01:01.001" ==
string(tx3));
190 CHECK (((t1-th)*=2) == t1);
204 CHECK (0 == hashFunc (Time::ZERO));
205 size_t hh =
sizeof(size_t)*CHAR_BIT/2;
206 CHECK (
size_t(1)<<hh == hashFunc (
TimeValue{1}));
207 CHECK (
size_t(1) == hashFunc (
TimeValue(
size_t(1)<<hh)));
209 size_t h1 = hashFunc (org);
212 CHECK (h1 > 0 || org == Time::ZERO);
213 CHECK (h2 - h1 ==
size_t(1)<<hh);
214 CHECK (h3 ==
size_t(_raw(org)));
219 verify_invalidFramerateProtection()
227 CHECK (FrameRate::approx(2000) ==
"2000FPS"_expect);
228 CHECK (FrameRate::approx(1e05) ==
"100000FPS"_expect);
229 CHECK (FrameRate::approx(1e06) ==
"1000000FPS"_expect);
230 CHECK (FrameRate::approx(1e12) ==
"4194303FPS"_expect);
231 CHECK (FrameRate::approx(1e14) ==
"4194303FPS"_expect);
232 CHECK (FrameRate::approx(1e-5) ==
"14/1398101FPS"_expect);
233 CHECK (FrameRate::approx(1e-6) ==
"4/4194303FPS"_expect);
234 CHECK (FrameRate::approx(1e-7) ==
"1/4194303FPS"_expect);
235 CHECK (FrameRate::approx(1e-9) ==
"1/4194303FPS"_expect);
237 CHECK (
FrameRate( 20
'000, Duration{Time{0,10}}) == "2000FPS"_expect); // exact 263 Offset reverse(point,org);
264 CHECK (reverse < off5);
265 CHECK (reverse.
abs() == off5);
267 CHECK (0 == off5 + reverse);
273 CHECK (7 == -2*off9 + off5*5);
292 Offset backwards(point,org);
293 CHECK (backwards < zero);
296 CHECK (distance > zero);
297 CHECK (distance == backwards.
abs());
300 CHECK (len1 ==
Time(
FSecs(23,1000)) +
Time(0, 4 + 5*60 + 6*3600));
307 CHECK (
Time(0,2,0,0) == unit);
310 CHECK (FrameRate::NTSC.duration() ==
Time(
FSecs(1001,30000)));
311 cout <<
"NTSC-Framerate = " << FrameRate::NTSC.asDouble() << endl;
319 CHECK (point < zero);
320 CHECK (point < backwards);
322 CHECK (distance + point < zero);
323 CHECK (distance == backwards.
abs());
328 verify_extremeValues()
331 CHECK (_raw(
Time::MAX) < std::numeric_limits<int64_t>::max());
332 CHECK (_raw(Time::MIN) > std::numeric_limits<int64_t>::min());
341 CHECK (outlier < Time::MIN);
344 CHECK (_raw(
Duration::MAX) < std::numeric_limits<int64_t>::max());
360 CHECK (
TimeSpan(outlier, Duration::MAX).conform() ==
TimeSpan(Time::MIN,Duration::MAX));
369 verify_fractionalOffset()
371 typedef boost::rational<FrameCnt> Frac;
375 Offset o1 = Frac(1,2) * three;
376 CHECK (o1 > Time::ZERO);
379 Offset o2 = -Frac(1,2) * three;
380 CHECK (o2 < Time::ZERO);
383 CHECK (three * Frac(1,2) * 2 != three);
384 CHECK (three *(Frac(1,2) * 2) == three);
398 CHECK (org == interval);
402 CHECK (theLength ==
Offset(org,five).abs());
404 Time endpoint = interval.end();
407 CHECK (
Offset(interval,endpoint) ==
Offset(org,five).abs());
410 cout <<
"Interval-1: " << interval
411 <<
" Interval-2: " << successor
412 <<
" End point: " << successor.end()
418 compareTimeSpan (
Time const& org)
425 CHECK (span1 == span2);
426 CHECK (span2 == span1);
427 CHECK (span3 == span4);
428 CHECK (span4 == span3);
430 CHECK (span1 != span3);
431 CHECK (span3 != span1);
432 CHECK (span1 != span4);
433 CHECK (span4 != span1);
434 CHECK (span2 != span3);
435 CHECK (span3 != span2);
436 CHECK (span2 != span4);
437 CHECK (span4 != span2);
440 CHECK (span1.end() == span2.end());
441 CHECK (span3.end() == span4.end());
448 CHECK (span1 != span1x);
449 CHECK (span3 != span3y);
450 CHECK (span3 != span3z);
452 CHECK ( span1 < span1x);
453 CHECK ( span1 <= span1x);
454 CHECK (!(span1 > span1x));
455 CHECK (!(span1 >= span1x));
457 CHECK ( span3 > span3y);
458 CHECK ( span3 >= span3y);
459 CHECK (!(span3 < span3y));
460 CHECK (!(span3 <= span3y));
462 CHECK ( span3 < span3z);
463 CHECK ( span3y < span3z);
467 CHECK (span1 < span1x);
468 CHECK (span1.duration() == span1x.duration());
469 CHECK (span1.start() < span1x.start());
470 CHECK (span1.end() < span1x.end());
472 CHECK (span3 > span3y);
473 CHECK (span3.duration() > span3y.duration());
474 CHECK (span3.start() == span3y.start());
475 CHECK (span3.end() > span3y.end());
476 CHECK (
Time(span3) ==
Time(span3y));
478 CHECK (span3 < span3z);
479 CHECK (span3.duration() > span3z.duration());
480 CHECK (span3.start() < span3z.start());
481 CHECK (span3.end() != span3z.end());
484 CHECK (span3y < span3z);
485 CHECK (span3y.duration() == span3z.duration());
486 CHECK (span3y.start() < span3z.start());
487 CHECK (span3y.end() < span3z.end());
501 CHECK ( span1.contains(probe));
502 CHECK (!span2.contains(probe));
505 CHECK ( span1.contains(probe));
506 CHECK ( span2.contains(probe));
509 CHECK (!span1.contains(probe));
510 CHECK ( span2.contains(probe));
513 CHECK (!span1.contains(probe));
514 CHECK (!span2.contains(probe));
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
static const Duration MAX
maximum possible temporal extension
Framerate specified as frames per second.
static const gavl_time_t SCALE
Number of micro ticks (µs) per second as basic time scale.
int rani(uint bound=_iBOUND())
Primary class template for std::hash.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
void checkTimeConvenience(TimeValue org)
static const Duration NIL
constant to indicate "no duration"
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
void checkTimeHash(TimeValue org)
Simplistic test class runner.
Duration abs() const
interpret the distance given by this offset as a time duration
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
boost::rational< int64_t > FSecs
rational representation of fractional seconds
A collection of frequently used helper functions to support unit testing.
void checkBasicTimeValues(TimeValue org)
ExampleStrategy::Qualifier two(string additionalArg)
definition of another qualifier two(arg), accepting an additional argument
Offset measures a distance in time.
Duration is the internal Lumiera time metric.
A time interval anchored at a specific point in time.
ExampleStrategy::Qualifier one()
definition of a qualifier one()
a family of time value like entities and their relationships.
basic constant internal time value.
void checkMutableTime(TimeValue org)
static const FrameRate PAL
predefined constant for PAL framerate