26using lumiera::error::LUMIERA_ERROR_BOTTOM_VALUE;
87 int frames =
rani(MAX_FRAMES);
88 FSecs dirt = (F25 / (2 +
rani(DIRT_GRAIN)));
92 CHECK (
Time( frames *F25) <= rawTime);
93 CHECK (
Time((frames+1)*F25) > rawTime);
97 CHECK (
Time(frames*F25) == quantTime);
115 return _raw(quantised);
125 CHECK ( 6 == q0.
quant(7) );
126 CHECK ( 6 == q0.
quant(6) );
127 CHECK ( 3 == q0.
quant(5) );
128 CHECK ( 3 == q0.
quant(4) );
129 CHECK ( 3 == q0.
quant(3) );
130 CHECK ( 0 == q0.
quant(2) );
131 CHECK ( 0 == q0.
quant(1) );
132 CHECK ( 0 == q0.
quant(0) );
133 CHECK (-3 == q0.
quant(-1));
134 CHECK (-3 == q0.
quant(-2));
135 CHECK (-3 == q0.
quant(-3));
136 CHECK (-6 == q0.
quant(-4));
138 CHECK ( 6 == q1.
quant(7) );
139 CHECK ( 3 == q1.
quant(6) );
140 CHECK ( 3 == q1.
quant(5) );
141 CHECK ( 3 == q1.
quant(4) );
142 CHECK ( 0 == q1.
quant(3) );
143 CHECK ( 0 == q1.
quant(2) );
144 CHECK ( 0 == q1.
quant(1) );
145 CHECK (-3 == q1.
quant(0) );
146 CHECK (-3 == q1.
quant(-1));
147 CHECK (-3 == q1.
quant(-2));
148 CHECK (-6 == q1.
quant(-3));
149 CHECK (-6 == q1.
quant(-4));
162 CHECK (secs(0) == case1.
gridLocal(SUB_MIN ));
164 CHECK (secs(1) == case1.
gridLocal(SUB_MIN +secs(1) ));
165 CHECK (SUP_MAX -secs(1) > case1.
gridLocal( secs(-1) ));
166 CHECK (SUP_MAX -secs(1) <= case1.
gridLocal( secs (0) ));
167 CHECK (SUP_MAX > case1.
gridLocal( secs (0) ));
168 CHECK (SUP_MAX > case1.
gridLocal( secs(+1) ));
169 CHECK (SUP_MAX > case1.
gridLocal( secs(+2) ));
172 CHECK (largestPoint == case1.
gridLocal( secs(+1) ));
173 CHECK (largestPoint == case1.
gridLocal( secs(+2) ));
174 CHECK (largestPoint < SUP_MAX);
179 CHECK (secs( 0) == case2.gridLocal(SUP_MAX ));
180 CHECK (secs(-1) == case2.gridLocal(SUP_MAX -
TimeValue(1) ));
181 CHECK (secs(-1) == case2.gridLocal(SUP_MAX -secs(1) ));
182 CHECK (SUB_MIN +secs(1) < case2.gridLocal( secs(+2) ));
183 CHECK (SUB_MIN +secs(1) >= case2.gridLocal( secs(+1) ));
184 CHECK (SUB_MIN < case2.gridLocal( secs(+1) ));
185 CHECK (SUB_MIN == case2.gridLocal( secs( 0) ));
186 CHECK (SUB_MIN == case2.gridLocal( secs(-1) ));
187 CHECK (SUB_MIN == case2.gridLocal( secs(-2) ));
192 CHECK (SUB_MIN == case3.
gridLocal(SUB_MIN ));
194 CHECK (SUB_MIN == case3.
gridLocal( secs(-1) ));
198 CHECK (SUP_MAX == case3.
gridLocal(SUP_MAX ));
202 CHECK (SUB_MIN == case4.
gridLocal(SUB_MIN ));
204 CHECK (SUB_MIN == case4.
gridLocal(SUB_MIN +secs(1) ));
205 CHECK (SUB_MIN == case4.
gridLocal( secs(-1) ));
206 CHECK (SUB_MIN == case4.
gridLocal( secs( 0) ));
212 TimeVar excess{SUP_MAX +secs(1)};
213 CHECK (SUP_MAX < excess);
215 CHECK (
Duration{excess} == SUP_MAX);
217 CHECK (SUP_MAX == case4.
gridLocal(excess ));
219 CHECK (secs(1) == case4.
timeOf(0));
220 CHECK (excess == case4.
timeOf(1));
221 CHECK (excess == case4.
timeOf(2));
224 CHECK (secs(0) == broken.
timeOf(-1));
225 CHECK (SUP_MAX == broken.
timeOf(0));
227 CHECK (SUP_MAX+SUP_MAX == broken.
timeOf(1));
228 CHECK (SUP_MAX+SUP_MAX == broken.
timeOf(2));
Duration is the internal Lumiera time metric.
static const Duration MAX
maximum possible temporal extension
Simple stand-alone Quantiser implementation based on a constant sized gird.
FrameCnt gridPoint(TimeValue const &) const override
grid quantisation (alignment).
Offset gridLocal(TimeValue const &) const override
transform into the local time scale grid aligned.
TimeValue timeOf(FrameCnt gridPoint) const override
calculate time value of a grid interval (frame) start point
Framerate specified as frames per second.
Offset measures a distance in time.
basic constant internal time value.
static const raw_time_64 SCALE
Number of micro ticks (µs) per second as basic time scale.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
void coverQuantisationCornerCases()
void checkSimpleQuantisation()
void coverQuantisationStandardCases()
Helpers typically used while writing tests.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Implementation namespace for support and library code.
int rani(uint bound=_iBOUND())
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Library functions to support the formation of grid-aligned time values.
Generating (pseudo) random numbers with controlled seed.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Test Quantiser allowing to use plain numbers.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...