Skip to content

When used with CppTest should not use cast operator #27

@anporumb

Description

@anporumb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions