Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Doc: How are generic range matchers used?

Open PaulFocus opened this issue 2 years ago • 3 comments

Hello,

using Catch2 v3.4.0.

I'm struggling to get the generic range matchers (defined in matchers/catch_matchers_range_equals.hpp) to work (as in: compile). I wasn't even able to find an example on the internet. Is there some documentation explaining them?

Best regards, Paul

PaulFocus avatar Jan 07 '24 18:01 PaulFocus

Got confused by a false-positive IDE warning ... but it is as easy as that:

std::vector<int>   tableContent{1,2,3,5};
std::vector<int>   values{3,5,2,1};

REQUIRE_THAT(tableContent, Catch::Matchers::UnorderedRangeEquals(values));

PaulFocus avatar Jan 08 '24 12:01 PaulFocus

Hi @PaulFocus and @horenmar

We want to work on this issue as part of our course project. Could you please assign it to me and, if possible, can you please help us to know the issue better. Our question is is it either a bug or just a query by the author ?

Thanks

chaitu9780 avatar Jul 30 '24 01:07 chaitu9780

Hello chaitu9780,

the code itself works fine. I just had problems with the syntax for reasons I'm not able to remember anymore.

I recommend adding a code example to the documentation for various matchers under the following heading: https://github.com/catchorg/Catch2/blob/devel/docs/matchers.md#generic-range-matchers

EDIT: I'm not allowed to assign tickets to you.

BR, Paul

PaulFocus avatar Jul 30 '24 06:07 PaulFocus