MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_from_raw_impl

Function test_from_raw_impl

tests/fl/math/fixed_point.cpp:387–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385
386template<typename T>
387void test_from_raw_impl() {
388 using R = raw_t<T>;
389 // 1.0
390 T a = T::from_raw(R(1) << T::FRAC_BITS);
391 FL_CHECK_EQ(a.to_int(), 1);
392 FL_CHECK_EQ(a.raw(), R(1) << T::FRAC_BITS);
393
394 // 2.5
395 R raw_2_5 = (R(2) << T::FRAC_BITS) + (R(1) << (T::FRAC_BITS - 1));
396 T b = T::from_raw(raw_2_5);
397 FL_CHECK_EQ(b.to_int(), 2);
398 FL_CHECK_EQ(b.raw(), raw_2_5);
399
400 // smallest negative fraction
401 T c = T::from_raw(R(-1));
402 FL_CHECK_EQ(c.raw(), R(-1));
403 FL_CHECK_EQ(c.to_int(), -1); // arithmetic shift
404}
405
406template<typename T>
407void test_addition_impl() {

Callers

nothing calls this directly

Calls 2

to_intMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected