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

Function test_multiply_impl

tests/fl/math/fixed_point.cpp:448–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446
447template<typename T>
448void test_multiply_impl() {
449 T a(2.0f), b(3.0f);
450 T c = a * b;
451 FL_CHECK_EQ(c.to_int(), 6);
452
453 // 0.5 * 0.5 = 0.25
454 T half(0.5f);
455 T quarter = half * half;
456 using R = raw_t<T>;
457 FL_CHECK_EQ(quarter.raw(), R(1) << (T::FRAC_BITS - 2)); // 0.25
458
459 // Multiply by 1 = identity
460 T one(1.0f);
461 FL_CHECK_EQ((a * one).raw(), a.raw());
462
463 // Multiply by 0 = zero
464 T zero;
465 FL_CHECK_EQ((a * zero).raw(), raw_t<T>(0));
466
467 // Commutativity
468 FL_CHECK_EQ((a * b).raw(), (b * a).raw());
469}
470
471template<typename T>
472void test_divide_impl() {

Callers

nothing calls this directly

Calls 2

to_intMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected