catchorg / catchorg/Catch2

Range matchers do not stringify a range produced by std::generator<>

Open
#2,899 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

Range matchers do not stringify ranges produced by synchronous co_yield generator.

```c++
#include
#include
#include

TEST_CASE("fibonacci")
{
auto fibonacci = []() -> std::generator
{
T j = 0;
T i = 1;
co_yield j;
for(;;) {
co_yield i;
T tmp = i;
i += j;
j = tmp;
}
};

CHECK_THAT(fibonacci() | std::views::take(7), Catch::Matchers::RangeEquals(std::array{0, 1, 1, 2, 3, 5, 9}));
}
```

**Expected behavior**
```
FAILED:
CHECK_THAT( fibonacci() | std::views::take(7), Catch::Matchers::RangeEquals(std::array{0, 1, 1, 2, 3, 5, 9}) )
with expansion:
{ 0, 1, 1, 2, 3, 5, 8 } elements are { 0, 1, 1, 2, 3, 5, 9 }
```

**Actual behaviour**
```
FAILED:
CHECK_THAT( fibonacci() | std::views::take(7), Catch::Matchers::RangeEquals(std::array{0, 1, 1, 2, 3, 5, 9}) )
with expansion:
{?} elements are { 0, 1, 1, 2, 3, 5, 9 }
```

**Platform information:**
- OS: **Ubuntu 24.04**
- Compiler: **gcc-14**
- Catch version: **3.6.0**

Probably, related to #2646

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.