Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When used with CppTest should not use cast operator #27

Open
anporumb opened this issue Aug 19, 2019 · 0 comments
Open

When used with CppTest should not use cast operator #27

anporumb opened this issue Aug 19, 2019 · 0 comments

Comments

@anporumb
Copy link
Contributor

The following macro

#define ASSERT_ARE_EQUAL(type, A, B, ...) \
    do \
    { \
        char* ctrs_message = CONSTRUCT_CTRS_MESSAGE(__VA_ARGS__); \
        std::wstring cppUnitTestMessage = ToString(ctrs_message); \
        ctrs_sprintf_free(ctrs_message); \
        Assert::AreEqual((type)(A), (type)(B), cppUnitTestMessage.c_str()); \
    } while ((void)0, 0)

Will allow compilation (in C++) of something like:

ASSERT_ARE_EQUAL(uint64_t, 4873764, (void*)345)

which, frankly, should not be allowed. This creates problems when changing a type from uint64_t to a void* (on a x64 platform).

Consider letting the cast of (type)(A) be in the calling land?

Best Regards,
Andrei Porumb

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

No branches or pull requests

1 participant