| 4 | #include "fl/stl/static_assert.h" |
| 5 | |
| 6 | FL_TEST_FILE(FL_FILEPATH) { |
| 7 | |
| 8 | // Test that FASTLED_FORCE_INLINE macro is defined and can be used |
| 9 | |
| 10 | // Define test functions using the macro |
| 11 | FASTLED_FORCE_INLINE int add_force_inline(int a, int b) { |
| 12 | return a + b; |
| 13 | } |
| 14 | |
| 15 | FASTLED_FORCE_INLINE float multiply_force_inline(float a, float b) { |
| 16 | return a * b; |
| 17 | } |
| 18 | |
| 19 | FASTLED_FORCE_INLINE bool is_positive_force_inline(int x) { |
| 20 | return x > 0; |
| 21 | } |
| 22 | |
| 23 | // Test with template functions |
| 24 | template<typename T> |
| 25 | FASTLED_FORCE_INLINE T max_force_inline(T a, T b) { |
| 26 | return (a > b) ? a : b; |
| 27 | } |
| 28 | |
| 29 | // Test with constexpr |
| 30 | FASTLED_FORCE_INLINE constexpr int square_force_inline(int x) { |
| 31 | return x * x; |
| 32 | } |
| 33 | |
| 34 | FL_TEST_CASE("FASTLED_FORCE_INLINE macro") { |
| 35 | FL_SUBCASE("basic integer functions") { |
| 36 | // Test that functions marked with FASTLED_FORCE_INLINE work correctly |
| 37 | FL_CHECK_EQ(add_force_inline(2, 3), 5); |
| 38 | FL_CHECK_EQ(add_force_inline(-5, 10), 5); |
| 39 | FL_CHECK_EQ(add_force_inline(0, 0), 0); |
| 40 | FL_CHECK_EQ(add_force_inline(100, -50), 50); |
| 41 | } |
| 42 | |
| 43 | FL_SUBCASE("floating point functions") { |
| 44 | FL_CHECK_EQ(multiply_force_inline(2.0f, 3.0f), 6.0f); |
| 45 | FL_CHECK_EQ(multiply_force_inline(0.5f, 4.0f), 2.0f); |
| 46 | FL_CHECK_EQ(multiply_force_inline(-2.0f, 3.0f), -6.0f); |
| 47 | FL_CHECK_EQ(multiply_force_inline(0.0f, 100.0f), 0.0f); |
| 48 | } |
| 49 | |
| 50 | FL_SUBCASE("boolean functions") { |
| 51 | FL_CHECK(is_positive_force_inline(1)); |
| 52 | FL_CHECK(is_positive_force_inline(100)); |
| 53 | FL_CHECK_FALSE(is_positive_force_inline(0)); |
| 54 | FL_CHECK_FALSE(is_positive_force_inline(-1)); |
| 55 | FL_CHECK_FALSE(is_positive_force_inline(-100)); |
| 56 | } |
| 57 | |
| 58 | FL_SUBCASE("template functions") { |
| 59 | // Test with int |
| 60 | FL_CHECK_EQ(max_force_inline(5, 10), 10); |
| 61 | FL_CHECK_EQ(max_force_inline(10, 5), 10); |
| 62 | FL_CHECK_EQ(max_force_inline(-5, -10), -5); |
| 63 |
nothing calls this directly
no test coverage detected