Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chghehe opened this issue Aug 15, 2024 · 0 comments
Open

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

chghehe opened this issue Aug 15, 2024 · 0 comments

Comments

@chghehe
Copy link

chghehe commented Aug 15, 2024

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

#include <catch2/catch_all.hpp>
#include <generator>
#include <ranges>

TEST_CASE("fibonacci")
{
  auto fibonacci = []<typename T = int>() -> std::generator<int>
    {
      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

@chghehe chghehe changed the title Range matchers do not stringify a range with std::generator<> Range matchers do not stringify a range produced by std::generator<> Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant