[Bug]: ASSERT_EQ / ASSERT_NE causes MSVC 4388 / 4389 warnings
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Describe the issue
Our users are writing the code:
```
ASSERT_EQ( myvec.size(), 1 );
ASSERT_NE( myvec.size(), 1 );
```
And, with /Wall on MSVC 19.17, we are getting C4388 and C4389 warnings - signed / unsigned mismatch
I'd rather not train all our users to write `ASSERT_EQ( myvec.size(), 1u )`.
The developers who are attentive to warnings are rewriting their asserts as `ASSERT_TRUE( myvec.size() == 1 )` or `ASSERT_EQ( (int)myvec.size(), 1 )`, both of which feel ugly.
Can these warnings be disabled inside the macro implementations? Happy to contribute a PR if it would help. I notice that others have raised the same issue for linux.
### Steps to reproduce the problem
na
### What version of GoogleTest are you using?
na
### What operating system and version are you using?
Windows 10, redhat 8
### What compiler and version are you using?
MSVC 19.17
### What build system are you using?
bazel 7.3.1
### Additional context
I see these related issues:
https://github.com/google/googletest/issues/1026
https://groups.google.com/g/googletestframework/c/xrGel-uytJg
Contributor guide
Research direction
Reproduce ASSERT_EQ(myvec.size(), 1) and ASSERT_NE(myvec.size(), 1) with MSVC 19.17 and /Wall, then inspect the ASSERT_EQ and ASSERT_NE macro implementations. Done means these calls no longer emit C4388 or C4389 without requiring users to add casts or unsigned literals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100