34 using lumiera::error::LUMIERA_ERROR_BOTTOM_VALUE;
46 const int MAX_FRAMES = 25*500;
47 const int DIRT_GRAIN = 50;
49 const FSecs F25(1,25);
83 checkSimpleQuantisation ();
84 coverQuantisationStandardCases();
85 coverQuantisationCornerCases();
90 checkSimpleQuantisation ()
94 int frames = (rand() % MAX_FRAMES);
95 FSecs dirt = (F25 / (2 + rand() % DIRT_GRAIN));
99 CHECK (
Time( frames *F25) <= rawTime);
100 CHECK (
Time((frames+1)*F25) > rawTime);
104 CHECK (
Time(frames*F25) == quantTime);
119 quant (
int testPoint)
122 return int(quantised);
127 coverQuantisationStandardCases()
132 CHECK ( 6 == q0.quant(7) );
133 CHECK ( 6 == q0.quant(6) );
134 CHECK ( 3 == q0.quant(5) );
135 CHECK ( 3 == q0.quant(4) );
136 CHECK ( 3 == q0.quant(3) );
137 CHECK ( 0 == q0.quant(2) );
138 CHECK ( 0 == q0.quant(1) );
139 CHECK ( 0 == q0.quant(0) );
140 CHECK (-3 == q0.quant(-1));
141 CHECK (-3 == q0.quant(-2));
142 CHECK (-3 == q0.quant(-3));
143 CHECK (-6 == q0.quant(-4));
145 CHECK ( 6 == q1.quant(7) );
146 CHECK ( 3 == q1.quant(6) );
147 CHECK ( 3 == q1.quant(5) );
148 CHECK ( 3 == q1.quant(4) );
149 CHECK ( 0 == q1.quant(3) );
150 CHECK ( 0 == q1.quant(2) );
151 CHECK ( 0 == q1.quant(1) );
152 CHECK (-3 == q1.quant(0) );
153 CHECK (-3 == q1.quant(-1));
154 CHECK (-3 == q1.quant(-2));
155 CHECK (-6 == q1.quant(-3));
156 CHECK (-6 == q1.quant(-4));
161 coverQuantisationCornerCases()
165 CHECK (secs(0) == case1.
gridLocal(Time::MIN ));
167 CHECK (secs(1) == case1.
gridLocal(Time::MIN +secs(1) ));
176 CHECK (secs( 0) == case2.gridLocal(
Time::MAX ));
178 CHECK (secs(-1) == case2.gridLocal(
Time::MAX -secs(1) ));
179 CHECK (Time::MIN +secs(1) < case2.gridLocal( secs(+2) ));
180 CHECK (Time::MIN +secs(1) >= case2.gridLocal( secs(+1) ));
181 CHECK (Time::MIN < case2.gridLocal( secs(+1) ));
182 CHECK (Time::MIN == case2.gridLocal( secs( 0) ));
183 CHECK (Time::MIN == case2.gridLocal( secs(-1) ));
184 CHECK (Time::MIN == case2.gridLocal( secs(-2) ));
189 CHECK (Time::MIN == case3.
gridLocal(Time::MIN ));
191 CHECK (Time::MIN == case3.
gridLocal( secs(-1) ));
199 CHECK (Time::MIN == case4.gridLocal(Time::MIN ));
200 CHECK (Time::MIN == case4.gridLocal(Time::MIN +
TimeValue(1) ));
201 CHECK (Time::MIN == case4.gridLocal(Time::MIN +secs(1) ));
202 CHECK (Time::MIN == case4.gridLocal( secs(-1) ));
203 CHECK (Time::MIN == case4.gridLocal( secs( 0) ));
204 CHECK (
TimeValue(0) == case4.gridLocal( secs(+1) ));
209 Duration superHuge{secs(12345) + hugeFrame};
219 CHECK (Time::MIN == case5.
gridLocal( secs(-1) ));
221 CHECK (Time::MIN == case5.
gridLocal(Time::MIN ));
228 CHECK (Time::MIN == case6.gridLocal(
Time::MAX -secs(2) ));
229 CHECK (Time::MIN == case6.gridLocal( secs( 1) ));
230 CHECK (Time::MIN == case6.gridLocal( secs(-12345) ));
231 CHECK (Time::MIN == case6.gridLocal( secs(-12345-1) ));
232 CHECK (Time::MIN == case6.gridLocal( secs(-12345-2) ));
233 CHECK (Time::MIN == case6.gridLocal(Time::MIN +
TimeValue(1) ));
234 CHECK (Time::MIN == case6.gridLocal(Time::MIN ));
239 CHECK (
TimeValue(0) == case7.gridLocal( secs( 0) ));
240 CHECK (
TimeValue(0) == case7.gridLocal(Time::MIN+secs(2) ));
241 CHECK (
TimeValue(0) == case7.gridLocal(Time::MIN+secs(1) ));
242 CHECK (Time::MIN == case7.gridLocal(Time::MIN ));
245 Duration not_really_larger(secs(10000) + extraHuge);
246 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.
#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.
Simple 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.
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.