25 using lumiera::error::LUMIERA_ERROR_BOTTOM_VALUE;
37 const int MAX_FRAMES = 25*500;
38 const int DIRT_GRAIN = 50;
40 const FSecs F25(1,25);
75 checkSimpleQuantisation();
76 coverQuantisationStandardCases();
77 coverQuantisationCornerCases();
82 checkSimpleQuantisation ()
86 int frames =
rani(MAX_FRAMES);
87 FSecs dirt = (F25 / (2 +
rani(DIRT_GRAIN)));
91 CHECK (
Time( frames *F25) <= rawTime);
92 CHECK (
Time((frames+1)*F25) > rawTime);
96 CHECK (
Time(frames*F25) == quantTime);
111 quant (
int testPoint)
114 return int(quantised);
119 coverQuantisationStandardCases()
124 CHECK ( 6 == q0.quant(7) );
125 CHECK ( 6 == q0.quant(6) );
126 CHECK ( 3 == q0.quant(5) );
127 CHECK ( 3 == q0.quant(4) );
128 CHECK ( 3 == q0.quant(3) );
129 CHECK ( 0 == q0.quant(2) );
130 CHECK ( 0 == q0.quant(1) );
131 CHECK ( 0 == q0.quant(0) );
132 CHECK (-3 == q0.quant(-1));
133 CHECK (-3 == q0.quant(-2));
134 CHECK (-3 == q0.quant(-3));
135 CHECK (-6 == q0.quant(-4));
137 CHECK ( 6 == q1.quant(7) );
138 CHECK ( 3 == q1.quant(6) );
139 CHECK ( 3 == q1.quant(5) );
140 CHECK ( 3 == q1.quant(4) );
141 CHECK ( 0 == q1.quant(3) );
142 CHECK ( 0 == q1.quant(2) );
143 CHECK ( 0 == q1.quant(1) );
144 CHECK (-3 == q1.quant(0) );
145 CHECK (-3 == q1.quant(-1));
146 CHECK (-3 == q1.quant(-2));
147 CHECK (-6 == q1.quant(-3));
148 CHECK (-6 == q1.quant(-4));
153 coverQuantisationCornerCases()
157 CHECK (secs(0) == case1.
gridLocal(Time::MIN ));
159 CHECK (secs(1) == case1.
gridLocal(Time::MIN +secs(1) ));
168 CHECK (secs( 0) == case2.gridLocal(
Time::MAX ));
170 CHECK (secs(-1) == case2.gridLocal(
Time::MAX -secs(1) ));
171 CHECK (Time::MIN +secs(1) < case2.gridLocal( secs(+2) ));
172 CHECK (Time::MIN +secs(1) >= case2.gridLocal( secs(+1) ));
173 CHECK (Time::MIN < case2.gridLocal( secs(+1) ));
174 CHECK (Time::MIN == case2.gridLocal( secs( 0) ));
175 CHECK (Time::MIN == case2.gridLocal( secs(-1) ));
176 CHECK (Time::MIN == case2.gridLocal( secs(-2) ));
181 CHECK (Time::MIN == case3.
gridLocal(Time::MIN ));
183 CHECK (Time::MIN == case3.
gridLocal( secs(-1) ));
191 CHECK (Time::MIN == case4.gridLocal(Time::MIN ));
192 CHECK (Time::MIN == case4.gridLocal(Time::MIN +
TimeValue(1) ));
193 CHECK (Time::MIN == case4.gridLocal(Time::MIN +secs(1) ));
194 CHECK (Time::MIN == case4.gridLocal( secs(-1) ));
195 CHECK (Time::MIN == case4.gridLocal( secs( 0) ));
196 CHECK (
TimeValue(0) == case4.gridLocal( secs(+1) ));
201 Duration superHuge{secs(12345) + hugeFrame};
211 CHECK (Time::MIN == case5.
gridLocal( secs(-1) ));
213 CHECK (Time::MIN == case5.
gridLocal(Time::MIN ));
220 CHECK (Time::MIN == case6.gridLocal(
Time::MAX -secs(2) ));
221 CHECK (Time::MIN == case6.gridLocal( secs( 1) ));
222 CHECK (Time::MIN == case6.gridLocal( secs(-12345) ));
223 CHECK (Time::MIN == case6.gridLocal( secs(-12345-1) ));
224 CHECK (Time::MIN == case6.gridLocal( secs(-12345-2) ));
225 CHECK (Time::MIN == case6.gridLocal(Time::MIN +
TimeValue(1) ));
226 CHECK (Time::MIN == case6.gridLocal(Time::MIN ));
231 CHECK (
TimeValue(0) == case7.gridLocal( secs( 0) ));
232 CHECK (
TimeValue(0) == case7.gridLocal(Time::MIN+secs(2) ));
233 CHECK (
TimeValue(0) == case7.gridLocal(Time::MIN+secs(1) ));
234 CHECK (Time::MIN == case7.gridLocal(Time::MIN ));
237 Duration not_really_larger(secs(10000) + extraHuge);
238 CHECK (extraHuge == not_really_larger);
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
static const Duration MAX
maximum possible temporal extension
FixedFrameQuantiser(FrameRate const &frames_per_second, TimeValue referencePoint=TimeValue(0))
Create a quantiser based on a fixed constant spaced grid, rooted at the reference point as origin of ...
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())
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Implementation namespace for support and library code.
Lumiera's internal time value datatype.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
TimeValue gridLocal(TimeValue const &) const
transform into the local time scale grid aligned.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
A collection of frequently used helper functions to support unit testing.
Library functions to support the formation of grid-aligned time values.
Generating (pseudo) random numbers with controlled seed.
Duration is the internal Lumiera time metric.
Test Quantiser allowing to use plain numbers.
basic constant internal time value.
Simple stand-alone Quantiser implementation based on a constant sized gird.