31 #include <boost/lexical_cast.hpp> 35 using boost::lexical_cast;
51 using LERR_(UNCONNECTED);
60 if (isnil (arg))
return "";
61 string entry = arg[0];
62 arg.erase (arg.begin());
83 received_.create (Time::ZERO);
88 received_.create (initialValue);
92 operator() (TI
const& changeValue)
const 95 received_.create (changeValue);
127 random_or_get (
string arg)
132 return lexical_cast<gavl_time_t> (arg);
143 CHECK (c!=Time::ZERO && o != c,
"unsuitable testdata");
152 verifyMatrix_of_MutationCases(o,c);
162 TestListener<Time> follower;
166 target.
accept (controller);
167 CHECK (
Time(0,10) == target);
169 CHECK (
Time(500,10) == target);
171 CHECK (follower.receivedValue() == Time::ZERO);
173 CHECK (follower.receivedValue() ==
Time(500,10));
176 CHECK (
Time(0,9) == target);
177 CHECK (
Time(0,9) == follower.receivedValue());
197 return std::is_same<T,Duration>::value;
204 return std::is_same<T,QuTime>::value;
209 materialise (T
const& someTime)
214 materialise (
QuTime const& alignedTime)
217 return grid->materialise (alignedTime);
247 return QuTime (org,
"test_grid_PAL");
278 return QuTime (c,
"test_grid_NTSC");
284 template<
class TAR,
class SRC>
286 ____verify_wasChanged (TAR
const& target,
TimeValue const& org, SRC
const& change)
288 if (isDuration<TAR>())
290 CHECK (target == org,
"Logic error: Duration was changed by time value");
293 if (isDuration<SRC>())
295 CHECK (target == org,
"Logic error: Duration used to change time value");
300 CHECK (target != org);
301 CHECK (target == materialise(change));
305 CHECK (target != org);
306 CHECK (target == change);
313 CHECK (target != org);
314 CHECK (target == otherDuration);
319 CHECK (target != org);
320 CHECK (target == span_as_change.duration());
325 CHECK (target == org,
"Logic error: Duration was used as start point of the target TimeSpan");
326 CHECK (target.duration() !=
Time(
FSecs(3,2)),
"length of the timespan should have been changed");
327 CHECK (target.duration() == changedDur);
334 ____verify_wasOffset (TAR
const& target, TAR
const& refState,
Offset const& offset)
336 CHECK (target != refState);
337 CHECK (target ==
Time(refState)+offset);
342 ____verify_wasOffsetBack (TAR
const& target, TAR
const& refState)
344 CHECK (target == refState);
350 ____verify_nudged (TAR
const& target, TAR
const& refState,
FrameCnt offsetSteps)
352 CHECK (target != refState || !offsetSteps);
359 CHECK (target != refState || !offsetSteps);
360 CHECK (target ==
Time (materialise(refState))
365 template<
class TAR,
class SRC>
369 if (isDuration<SRC>())
371 CHECK (materialise(target) == follower.receivedValue()
377 CHECK (materialise (target) == follower.receivedValue());
381 CHECK (target == follower.receivedValue());
387 CHECK (follower.receivedValue() == targetTimeSpan.duration());
392 CHECK (target == follower.receivedValue());
397 CHECK (Time::ZERO == follower.receivedValue());
398 CHECK (targetDuration == follower.receivedValue().duration());
414 cout <<
"Test-Case. Target=" << typeStr<TAR>()
415 <<
"\t <--feed--- " << typeStr<SRC>()
426 target.accept (controller);
429 ____verify_wasChanged (target, org, change);
430 ____verify_notification(target,follower);
432 TAR refState(target);
436 ____verify_wasOffset (target, refState, offset);
437 controller (-offset);
438 ____verify_wasOffsetBack (target, refState);
439 ____verify_notification(target,follower);
442 ____verify_nudged (target, refState, 0);
443 ____verify_notification(target,follower);
446 ____verify_nudged (target, refState, +1);
447 ____verify_notification(target,follower);
450 ____verify_nudged (target, refState, -1);
451 ____verify_notification(target,follower);
453 int maxInt = std::numeric_limits<int>::max();
454 int minInt = std::numeric_limits<int>::min();
457 ____verify_nudged (target, refState, -1LL + maxInt);
458 ____verify_notification(target,follower);
461 ____verify_nudged (target, refState, -1LL + maxInt+minInt);
462 ____verify_notification(target,follower);
466 BASE::performTestSequence(org,c);
486 , IterationEnd > TestMatrix;
488 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.
int rani(uint bound=_iBOUND())
#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.
Simplistic 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.