[Bug]: FieldsAre cannot support struct type
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Describe the issue
the documentation about FieldsAre wrote:
```cpp
struct MyStruct {
int value = 42;
std::string greeting = "aloha";
};
MyStruct s;
EXPECT_THAT(s, FieldsAre(42, "aloha"));
```
however, when I run this:
```cpp
struct MyStruct {
int value = 42;
std::string greeting = "aloha";
};
TEST(MyTestSuite, FieldsAreMatcherTest) {
MyStruct s;
EXPECT_THAT(s, FieldsAre(42, "aloha"));
}
```
g++ cannot compile:
note: types 'std::pair<_Tp1, _Tp2>' and 'const MyStruct' have incompatible cv-qualifiers
### Steps to reproduce the problem
wrote the above code and run googletest
### What version of GoogleTest are you using?
1.15.2
### What operating system and version are you using?
windows10
### What compiler and version are you using?
gcc (tdm64-1) 9.2.0
### What build system are you using?
cmake version 3.22.2
### Additional context
_No response_
Contributor guide
Research direction
Start with the FieldsAre documentation example and reproduce the reported compilation failure using the supplied MyStruct code, GoogleTest 1.15.2, and g++ 9.2.0. Trace the matcher behavior involved in the incompatible std::pair and MyStruct types. Done means the documented struct example compiles and the corresponding matcher test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100