Skip to content

Add casts to avoid warnings when using unity in CPP#836

Open
lucasssvaz wants to merge 1 commit into
ThrowTheSwitch:masterfrom
lucasssvaz:fix/cast_each_float
Open

Add casts to avoid warnings when using unity in CPP#836
lucasssvaz wants to merge 1 commit into
ThrowTheSwitch:masterfrom
lucasssvaz:fix/cast_each_float

Conversation

@lucasssvaz
Copy link
Copy Markdown

Summary

TEST_ASSERT_EACH_EQUAL_FLOAT and TEST_ASSERT_EACH_EQUAL_DOUBLE fail to compile in C++ because UnityFloatToPtr() / UnityDoubleToPtr() return UNITY_INTERNAL_PTR (const void*), while UnityAssertWithinFloatArray() / UnityAssertWithinDoubleArray() expect const UNITY_FLOAT* / const UNITY_DOUBLE*.

C allows that conversion implicitly; C++ does not.

Fix

Cast the helper return value in the internal macros:

(const UNITY_FLOAT*)UnityFloatToPtr(expected)
(const UNITY_DOUBLE*)UnityDoubleToPtr(expected)

Integer TEST_ASSERT_EACH_EQUAL_* macros are unaffected because they call UnityAssertEqualIntArray(), which already takes UNITY_INTERNAL_PTR.

Tested locally. Solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant