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

Function test_floor_ceil_impl

tests/fl/math/fixed_point.cpp:565–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563
564template<typename T>
565void test_floor_ceil_impl() {
566 using R = raw_t<T>;
567 T a(2.75f);
568 T floored = T::floor(a);
569 FL_CHECK_EQ(floored.raw(), R(2) << T::FRAC_BITS);
570
571 T ceiled = T::ceil(a);
572 FL_CHECK_EQ(ceiled.raw(), R(3) << T::FRAC_BITS);
573
574 // Negative values
575 T neg(-1.25f);
576 FL_CHECK_EQ(T::floor(neg).raw(), R(-2) * (R(1) << T::FRAC_BITS));
577 FL_CHECK_EQ(T::ceil(neg).raw(), R(-1) * (R(1) << T::FRAC_BITS));
578
579 // Integer values (no change)
580 T whole(3.0f);
581 FL_CHECK_EQ(T::floor(whole).raw(), whole.raw());
582 FL_CHECK_EQ(T::ceil(whole).raw(), whole.raw());
583}
584
585template<typename T>
586void test_fract_impl() {

Callers

nothing calls this directly

Calls 3

floorFunction · 0.85
ceilFunction · 0.85
rawMethod · 0.45

Tested by

no test coverage detected