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

Function test_float_construction_impl

tests/fl/math/fixed_point.cpp:362–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360
361template<typename T>
362void test_float_construction_impl() {
363 using R = raw_t<T>;
364 T one(1.0f);
365 FL_CHECK_EQ(one.raw(), R(1) << T::FRAC_BITS);
366 FL_CHECK_EQ(one.to_int(), 1);
367
368 T half(0.5f);
369 FL_CHECK_EQ(half.raw(), R(1) << (T::FRAC_BITS - 1));
370 FL_CHECK_EQ(half.to_int(), 0);
371
372 T neg(-1.0f);
373 FL_CHECK_EQ(neg.raw(), -(R(1) << T::FRAC_BITS));
374 FL_CHECK_EQ(neg.to_int(), -1);
375
376 T neg_half(-0.5f);
377 FL_CHECK_EQ(neg_half.to_int(), -1); // floor(-0.5) via arithmetic shift
378
379 T val(3.0f);
380 FL_CHECK_EQ(val.to_int(), 3);
381
382 T neg_val(-3.0f);
383 FL_CHECK_EQ(neg_val.to_int(), -3);
384}
385
386template<typename T>
387void test_from_raw_impl() {

Callers

nothing calls this directly

Calls 2

rawMethod · 0.45
to_intMethod · 0.45

Tested by

no test coverage detected