fix: Updated CMock default assert styles from HEX to proper UINT types#510
fix: Updated CMock default assert styles from HEX to proper UINT types#510burakutkuc wants to merge 1 commit intoThrowTheSwitch:masterfrom
Conversation
|
Hi. I saw your fix on Unity and, assuming it passes tests, will likely merge that. This particular PR, though, I'm probably not going to merge. CMock has the ability for you to map these types to whatever you would prefer. The defaults represent the generally-preferred values after quite a few years of polling the community, etc. More developers preferred to see hex for their unsigned values than an unsigned int. So that's become the default. |
Hi Mark, Thanks for your reply. In the case where UINT32 is mapped to HEX32, the generated test uses UNITY_TEST_ASSERT_EQUAL_HEX32. But this macro casts the values to int32_t, which overflows when given UINT32_MAX. Is this the intended behavior by default? Or am I missing something? Thanks again! |
|
Hi Mark, If the current solution isn’t ideal, I can also fix the issue by modifying Unity itself. Currently, UNITY_TEST_ASSERT_EQUAL_HEX32 looks like this: To prevent overflow when passing values like UINT32_MAX, I suggest updating it to use the unsigned version instead: Let me know if this approach would be acceptable. |
|
Hi @burakutkuc -- yes, what you describe is the intended behavior! A hex comparison should be an unsigned comparison, just displayed differently. I think fixing it in Unity is the write thing to do. |
Hi @mvandervoord, I’ve made the improvements in Unity; |
Related to #509