Snaipe / Criterion

A cross-platform C and C++ unit testing framework for the 21st century
MIT License
1.94k stars 176 forks source link

assertion for string should take const char * instead of char * #521

Open 2LeoCode opened 3 months ago

2LeoCode commented 3 months ago

when doing for example:

const char * foo = "foo";

cr_assert(eq(str, foo, "foo"));

we get a compiler warning because eq(str, ...) expects a char as second argument, so we loose the const qualifier for foo, but it should take a const char instead

EDIT

same for ptr, should take const void , but takes void (I guess it's the same for every typed pointers too)

jakeru commented 2 months ago

Right! This issue is similar to #512.

As a workaround you may use cr_expect_str_eq() for strings and cr_expect_arr_eq to compare arrays. Both are part of the "old" API.