40 #include <boost/lexical_cast.hpp> 44 using boost::lexical_cast;
60 using LERR_(UNCONNECTED);
69 if (isnil (arg))
return "";
70 string entry = arg[0];
71 arg.erase (arg.begin());
92 received_.create (Time::ZERO);
97 received_.create (initialValue);
101 operator() (TI
const& changeValue)
const 104 received_.create (changeValue);
108 receivedValue()
const 136 random_or_get (
string arg)
141 return lexical_cast<gavl_time_t> (arg);
150 CHECK (c!=Time::ZERO && o != c,
"unsuitable testdata");
159 verifyMatrix_of_MutationCases(o,c);
169 TestListener<Time> follower;
173 target.
accept (controller);
174 CHECK (
Time(0,10) == target);
176 CHECK (
Time(500,10) == target);
178 CHECK (follower.receivedValue() == Time::ZERO);
180 CHECK (follower.receivedValue() ==
Time(500,10));
183 CHECK (
Time(0,9) == target);
184 CHECK (
Time(0,9) == follower.receivedValue());
204 return std::is_same<T,Duration>::value;
211 return std::is_same<T,QuTime>::value;
216 materialise (T
const& someTime)
221 materialise (
QuTime const& alignedTime)
224 return grid->materialise (alignedTime);
254 return QuTime (org,
"test_grid_PAL");
285 return QuTime (c,
"test_grid_NTSC");
291 template<
class TAR,
class SRC>
293 ____verify_wasChanged (TAR
const& target,
TimeValue const& org, SRC
const& change)
295 if (isDuration<TAR>())
297 CHECK (target == org,
"Logic error: Duration was changed by time value");
300 if (isDuration<SRC>())
302 CHECK (target == org,
"Logic error: Duration used to change time value");
307 CHECK (target != org);
308 CHECK (target == materialise(change));
312 CHECK (target != org);
313 CHECK (target == change);
320 CHECK (target != org);
321 CHECK (target == otherDuration);
326 CHECK (target != org);
327 CHECK (target == span_as_change.duration());
332 CHECK (target == org,
"Logic error: Duration was used as start point of the target TimeSpan");
333 CHECK (target.duration() !=
Time(
FSecs(3,2)),
"length of the timespan should have been changed");
334 CHECK (target.duration() == changedDur);
341 ____verify_wasOffset (TAR
const& target, TAR
const& refState,
Offset const& offset)
343 CHECK (target != refState);
344 CHECK (target ==
Time(refState)+offset);
349 ____verify_wasOffsetBack (TAR
const& target, TAR
const& refState)
351 CHECK (target == refState);
357 ____verify_nudged (TAR
const& target, TAR
const& refState,
FrameCnt offsetSteps)
359 CHECK (target != refState || !offsetSteps);
366 CHECK (target != refState || !offsetSteps);
367 CHECK (target ==
Time (materialise(refState))
372 template<
class TAR,
class SRC>
376 if (isDuration<SRC>())
378 CHECK (materialise(target) == follower.receivedValue()
384 CHECK (materialise (target) == follower.receivedValue());
388 CHECK (target == follower.receivedValue());
394 CHECK (follower.receivedValue() == targetTimeSpan.duration());
399 CHECK (target == follower.receivedValue());
404 CHECK (Time::ZERO == follower.receivedValue());
405 CHECK (targetDuration == follower.receivedValue().duration());
421 cout <<
"Test-Case. Target=" << typeStr<TAR>()
422 <<
"\t <--feed--- " << typeStr<SRC>()
433 target.accept (controller);
436 ____verify_wasChanged (target, org, change);
437 ____verify_notification(target,follower);
439 TAR refState(target);
443 ____verify_wasOffset (target, refState, offset);
444 controller (-offset);
445 ____verify_wasOffsetBack (target, refState);
446 ____verify_notification(target,follower);
449 ____verify_nudged (target, refState, 0);
450 ____verify_notification(target,follower);
453 ____verify_nudged (target, refState, +1);
454 ____verify_notification(target,follower);
457 ____verify_nudged (target, refState, -1);
458 ____verify_notification(target,follower);
460 int maxInt = std::numeric_limits<int>::max();
461 int minInt = std::numeric_limits<int>::min();
464 ____verify_nudged (target, refState, -1LL + maxInt);
465 ____verify_notification(target,follower);
468 ____verify_nudged (target, refState, -1LL + maxInt+minInt);
469 ____verify_notification(target,follower);
473 BASE::performTestSequence(org,c);
493 , IterationEnd > TestMatrix;
495 TestMatrix().performTestSequence(origVal, change);
Some wrappers for coping with ownership problems.
void connectChangeNotification(SIG const &toNotify)
install a callback functor to be invoked as notification for any changes imposed onto the observed ti...
Mock object to receive change notifications.
Frontend/Interface: controller-element to retrieve and change running time values.
void verifyMatrix_of_MutationCases(TimeValue const &o, TimeValue const &c)
void accept(Mutation const &)
may change start / duration
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
Any copy and copy construction prohibited.
static const gavl_time_t SCALE
Number of micro ticks (µs) per second as basic time scale.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
static const Duration NIL
constant to indicate "no duration"
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
Metaprogramming facilities to generate combination cases.
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Inline buffer holding and owning an object similar to unique_ptr.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
A collection of frequently used helper functions to support unit testing.
Support library to represent grid-aligned time specifications This is part of Lumiera's time and time...
Offset measures a distance in time.
Manipulating and monitoring time entities with life changes.
To establish a reference scale for quantised time values.
Duration is the internal Lumiera time metric.
A time interval anchored at a specific point in time.
int64_t FrameCnt
relative framecount or frame number.
a family of time value like entities and their relationships.
basic constant internal time value.
static const FrameRate PAL
predefined constant for PAL framerate
grid aligned time specification, referring to a specific scale.