Azure / Azure/c-testrunnerswitcher

When used with CppTest should not use cast operator

Open
#27 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CMake
Stars
9
Forks
17
Avg merge
32m
Merged PRs (30d)
3

Description

The following macro
```c
#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:
```c
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.