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

Function test_sqrt_impl

tests/fl/math/fixed_point.cpp:694–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

692
693template<typename T>
694void test_sqrt_impl(float sqrt_max) {
695 FL_CHECK_CLOSE(T::sqrt(T(4.0f)).to_float(), 2.0f, sqrt_max);
696 FL_CHECK_CLOSE(T::sqrt(T(1.0f)).to_float(), 1.0f, sqrt_max);
697 FL_CHECK_CLOSE(T::sqrt(T(2.0f)).to_float(), 1.4142f, sqrt_max);
698
699 FL_CHECK_EQ(T::sqrt(T()).raw(), raw_t<T>(0)); // sqrt(0) = 0
700 FL_CHECK_EQ(T::sqrt(T(-1.0f)).raw(), raw_t<T>(0)); // sqrt(neg) = 0
701
702 // sqrt(9) = 3 (only for types that can represent 9)
703 if (T::INT_BITS > 4) {
704 FL_CHECK_CLOSE(T::sqrt(T(9.0f)).to_float(), 3.0f, sqrt_max);
705 }
706}
707
708template<typename T>
709void test_rsqrt_impl(float rsqrt_max) {

Callers

nothing calls this directly

Calls 4

sqrtFunction · 0.85
TEnum · 0.85
to_floatMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected