Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Unclear how to compare generic ranges against equalitiy

Open Viatorus opened this issue 3 years ago • 2 comments

By reading the docs as linked here:

https://github.com/catchorg/Catch2/blob/devel/docs/matchers.md#generic-range-matchers

I don't get what the required include is or the API to compare two generic ranges.

I would like to compare std::span's against equality, like this:

CHECK_THAT(std::span<char>{}, Catch::Matchers::Equals(std::span<char>{}));

But this doesn't compile. Isn't this supported or do I use the wrong syntax?

Viatorus avatar Sep 19 '22 19:09 Viatorus

Maybe something like this could be implemented? Its not perfect, but here is a rough attempt.

https://nandanv.godbolt.org/z/sova6bMoW

nandanvasudevan avatar Oct 04 '22 09:10 nandanvasudevan

Isn't this very similar to #2473?

nandanvasudevan avatar Oct 05 '22 14:10 nandanvasudevan

Maybe something like this could be implemented? Its not perfect, but here is a rough attempt.

https://nandanv.godbolt.org/z/sova6bMoW

This works in the current release still, thank you for the easy work around.

Vi1i avatar Jun 22 '23 14:06 Vi1i

@Viatorus, if you are still looking/wondering, commit https://github.com/catchorg/Catch2/commit/efca9a0f1826885c1574ed44fc37c8d82ded4546 introduces algorithm into the dev branch.

Vi1i avatar Jun 22 '23 15:06 Vi1i

@Vi1i Great, thank you very much. :)

Viatorus avatar Jun 23 '23 06:06 Viatorus