[{"data":1,"prerenderedAt":2546},["ShallowReactive",2],{"doc-matchers":3},{"id":4,"title":5,"body":6,"description":129,"extension":2539,"meta":2540,"navigation":159,"path":2541,"seo":2542,"slug":53,"source":2543,"stem":2544,"__hash__":2545},"docs\u002Fdocs\u002Fmatchers.md","Matchers",{"type":7,"value":8,"toc":2521},"minimark",[9,50,54,92,102,106,120,123,188,202,274,288,299,304,310,316,319,372,375,449,452,534,548,551,566,569,576,582,612,625,634,659,662,671,675,680,686,689,723,734,737,821,827,835,839,842,864,872,880,887,907,911,914,929,932,1028,1036,1039,1044,1047,1050,1058,1073,1084,1091,1160,1163,1170,1182,1195,1208,1223,1226,1276,1284,1288,1293,1296,1359,1372,1379,1387,1402,1415,1424,1429,1441,1462,1479,1495,1503,1508,1511,1529,1540,1543,1550,1751,1762,1765,1775,1778,1783,1796,1805,1816,2339,2342,2351,2354,2359,2372,2379,2459,2463,2469,2517],[10,11,12],"blockquote",{},[13,14,15,19,20,24,25,28,29,32,33,36,37,36,40,43,44,49],"p",{},[16,17,18],"strong",{},"Catch3 compatibility reference:"," This page describes the test-writing API Catch3 shares with Catch2: the macros, such as ",[21,22,23],"code",{},"TEST_CASE"," and ",[21,26,27],{},"REQUIRE",", and the ",[21,30,31],{},"Catch::"," namespace keep Catch2's names. Headers and build names are Catch3's own (",[21,34,35],{},"\u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>",", ",[21,38,39],{},"find_package(Catch3)",[21,41,42],{},"Catch3::Catch3WithMain","). See ",[45,46,48],"a",{"href":47},"\u002Fdocs\u002Fprogmasoft-catch3\u002F","Catch3 additions"," for Progmasoft APIs.",[51,52,5],"h1",{"id":53},"matchers",[13,55,56,59,62,66,68,72,74,78,80,84,86,90],{},[16,57,58],{},"Contents",[60,61],"br",{},[45,63,65],{"href":64},"#using-matchers","Using Matchers",[60,67],{},[45,69,71],{"href":70},"#built-in-matchers","Built-in matchers",[60,73],{},[45,75,77],{"href":76},"#writing-custom-matchers-old-style","Writing custom matchers (old style)",[60,79],{},[45,81,83],{"href":82},"#writing-custom-matchers-new-style","Writing custom matchers (new style)",[60,85],{},[45,87,89],{"href":88},"#constexpr-matchers","Constexpr matchers",[60,91],{},[13,93,94,95,101],{},"Matchers, as popularized by the ",[45,96,100],{"href":97,"rel":98},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FHamcrest",[99],"nofollow","Hamcrest","\nframework are an alternative way to write assertions, useful for tests\nwhere you work with complex types or need to assert more complex\nproperties. Matchers are easily composable and users can write their\nown and combine them with the Catch2-provided matchers seamlessly.",[103,104,65],"h2",{"id":105},"using-matchers",[13,107,108,109,112,113,116,117,119],{},"Matchers are most commonly used in tandem with the ",[21,110,111],{},"REQUIRE_THAT"," or\n",[21,114,115],{},"CHECK_THAT"," macros. The ",[21,118,111],{}," macro takes two arguments,\nthe first one is the input (object\u002Fvalue) to test, the second argument\nis the matcher itself.",[13,121,122],{},"For example, to assert that a string ends with the \"as a service\"\nsubstring, you can write the following assertion",[124,125,130],"pre",{"className":126,"code":127,"language":128,"meta":129,"style":129},"language-cpp shiki shiki-themes github-dark","using Catch::Matchers::EndsWith;\n\nREQUIRE_THAT( getSomeString(), EndsWith(\"as a service\") );\n","cpp","",[21,131,132,154,161],{"__ignoreMap":129},[133,134,137,141,145,149,151],"span",{"class":135,"line":136},"line",1,[133,138,140],{"class":139},"snl16","using",[133,142,144],{"class":143},"svObZ"," Catch",[133,146,148],{"class":147},"s95oV","::",[133,150,5],{"class":143},[133,152,153],{"class":147},"::EndsWith;\n",[133,155,157],{"class":135,"line":156},2,[133,158,160],{"emptyLinePlaceholder":159},true,"\n",[133,162,164,166,169,172,175,178,181,185],{"class":135,"line":163},3,[133,165,111],{"class":143},[133,167,168],{"class":147},"( ",[133,170,171],{"class":143},"getSomeString",[133,173,174],{"class":147},"(), ",[133,176,177],{"class":143},"EndsWith",[133,179,180],{"class":147},"(",[133,182,184],{"class":183},"sU2Wk","\"as a service\"",[133,186,187],{"class":147},") );\n",[13,189,190,191,36,194,197,198,201],{},"Individual matchers can also be combined using the C++ logical\noperators, that is ",[21,192,193],{},"&&",[21,195,196],{},"||",", and ",[21,199,200],{},"!",", like so:",[124,203,205],{"className":126,"code":204,"language":128,"meta":129,"style":129},"using Catch::Matchers::EndsWith;\nusing Catch::Matchers::ContainsSubstring;\n\nREQUIRE_THAT( getSomeString(),\n              EndsWith(\"as a service\") && ContainsSubstring(\"web scale\"));\n",[21,206,207,219,232,236,248],{"__ignoreMap":129},[133,208,209,211,213,215,217],{"class":135,"line":136},[133,210,140],{"class":139},[133,212,144],{"class":143},[133,214,148],{"class":147},[133,216,5],{"class":143},[133,218,153],{"class":147},[133,220,221,223,225,227,229],{"class":135,"line":156},[133,222,140],{"class":139},[133,224,144],{"class":143},[133,226,148],{"class":147},[133,228,5],{"class":143},[133,230,231],{"class":147},"::ContainsSubstring;\n",[133,233,234],{"class":135,"line":163},[133,235,160],{"emptyLinePlaceholder":159},[133,237,239,241,243,245],{"class":135,"line":238},4,[133,240,111],{"class":143},[133,242,168],{"class":147},[133,244,171],{"class":143},[133,246,247],{"class":147},"(),\n",[133,249,251,254,256,258,261,263,266,268,271],{"class":135,"line":250},5,[133,252,253],{"class":143},"              EndsWith",[133,255,180],{"class":147},[133,257,184],{"class":183},[133,259,260],{"class":147},") ",[133,262,193],{"class":139},[133,264,265],{"class":143}," ContainsSubstring",[133,267,180],{"class":147},[133,269,270],{"class":183},"\"web scale\"",[133,272,273],{"class":147},"));\n",[13,275,276,277,279,283,284,287],{},"The example above asserts that the string returned from ",[21,278,171],{},[280,281,282],"em",{},"both"," ends with the suffix \"as a service\" ",[280,285,286],{},"and"," contains the string\n\"web scale\" somewhere.",[13,289,290,291,294,295,298],{},"Both of the string matchers used in the examples above live in the\n",[21,292,293],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FString.hpp"," header, so to compile the code above also\nrequires ",[21,296,297],{},"#include \u003CProgmasoft\u002FCatch3\u002FMatchers\u002FString.hpp>",".",[300,301,303],"h3",{"id":302},"combining-operators-and-lifetimes","Combining operators and lifetimes",[13,305,306,309],{},[16,307,308],{},"IMPORTANT",": The combining operators do not take ownership of the\nmatcher objects being combined.",[13,311,312,313,315],{},"This means that if you store combined matcher object, you have to ensure\nthat the individual matchers being combined outlive the combined matcher.\nNote that the negation matcher from ",[21,314,200],{}," also counts as combining matcher\nfor this.",[13,317,318],{},"Explained on an example, this is fine",[124,320,322],{"className":126,"code":321,"language":128,"meta":129,"style":129},"CHECK_THAT(value, WithinAbs(0, 2e-2) && !WithinULP(0., 1));\n",[21,323,324],{"__ignoreMap":129},[133,325,326,328,331,334,336,340,342,345,348,350,352,354,357,360,362,365,367,370],{"class":135,"line":136},[133,327,115],{"class":143},[133,329,330],{"class":147},"(value, ",[133,332,333],{"class":143},"WithinAbs",[133,335,180],{"class":147},[133,337,339],{"class":338},"sDLfK","0",[133,341,36],{"class":147},[133,343,344],{"class":338},"2",[133,346,347],{"class":139},"e-",[133,349,344],{"class":338},[133,351,260],{"class":147},[133,353,193],{"class":139},[133,355,356],{"class":139}," !",[133,358,359],{"class":143},"WithinULP",[133,361,180],{"class":147},[133,363,364],{"class":338},"0.",[133,366,36],{"class":147},[133,368,369],{"class":338},"1",[133,371,273],{"class":147},[13,373,374],{},"and so is this",[124,376,378],{"className":126,"code":377,"language":128,"meta":129,"style":129},"auto is_close_to_zero = WithinAbs(0, 2e-2);\nauto is_zero          = WithinULP(0., 1);\n\nCHECK_THAT(value, is_close_to_zero && !is_zero);\n",[21,379,380,409,431,435],{"__ignoreMap":129},[133,381,382,385,388,391,394,396,398,400,402,404,406],{"class":135,"line":136},[133,383,384],{"class":139},"auto",[133,386,387],{"class":147}," is_close_to_zero ",[133,389,390],{"class":139},"=",[133,392,393],{"class":143}," WithinAbs",[133,395,180],{"class":147},[133,397,339],{"class":338},[133,399,36],{"class":147},[133,401,344],{"class":338},[133,403,347],{"class":139},[133,405,344],{"class":338},[133,407,408],{"class":147},");\n",[133,410,411,413,416,418,421,423,425,427,429],{"class":135,"line":156},[133,412,384],{"class":139},[133,414,415],{"class":147}," is_zero          ",[133,417,390],{"class":139},[133,419,420],{"class":143}," WithinULP",[133,422,180],{"class":147},[133,424,364],{"class":338},[133,426,36],{"class":147},[133,428,369],{"class":338},[133,430,408],{"class":147},[133,432,433],{"class":135,"line":163},[133,434,160],{"emptyLinePlaceholder":159},[133,436,437,439,442,444,446],{"class":135,"line":238},[133,438,115],{"class":143},[133,440,441],{"class":147},"(value, is_close_to_zero ",[133,443,193],{"class":139},[133,445,356],{"class":139},[133,447,448],{"class":147},"is_zero);\n",[13,450,451],{},"but this is not",[124,453,455],{"className":126,"code":454,"language":128,"meta":129,"style":129},"auto is_close_to_zero = WithinAbs(0, 2e-2);\nauto is_zero          = WithinULP(0., 1);\nauto is_close_to_but_not_zero = is_close_to_zero && !is_zero;\n\nCHECK_THAT(a_value, is_close_to_but_not_zero); \u002F\u002F UAF\n",[21,456,457,481,501,519,523],{"__ignoreMap":129},[133,458,459,461,463,465,467,469,471,473,475,477,479],{"class":135,"line":136},[133,460,384],{"class":139},[133,462,387],{"class":147},[133,464,390],{"class":139},[133,466,393],{"class":143},[133,468,180],{"class":147},[133,470,339],{"class":338},[133,472,36],{"class":147},[133,474,344],{"class":338},[133,476,347],{"class":139},[133,478,344],{"class":338},[133,480,408],{"class":147},[133,482,483,485,487,489,491,493,495,497,499],{"class":135,"line":156},[133,484,384],{"class":139},[133,486,415],{"class":147},[133,488,390],{"class":139},[133,490,420],{"class":143},[133,492,180],{"class":147},[133,494,364],{"class":338},[133,496,36],{"class":147},[133,498,369],{"class":338},[133,500,408],{"class":147},[133,502,503,505,508,510,512,514,516],{"class":135,"line":163},[133,504,384],{"class":139},[133,506,507],{"class":147}," is_close_to_but_not_zero ",[133,509,390],{"class":139},[133,511,387],{"class":147},[133,513,193],{"class":139},[133,515,356],{"class":139},[133,517,518],{"class":147},"is_zero;\n",[133,520,521],{"class":135,"line":238},[133,522,160],{"emptyLinePlaceholder":159},[133,524,525,527,530],{"class":135,"line":250},[133,526,115],{"class":143},[133,528,529],{"class":147},"(a_value, is_close_to_but_not_zero);",[133,531,533],{"class":532},"sAwPA"," \u002F\u002F UAF\n",[13,535,536,537,540,541,544,545,547],{},"because ",[21,538,539],{},"!is_zero"," creates a temporary instance of Negation matcher,\nwhich the ",[21,542,543],{},"is_close_to_but_not_zero"," refers to. After the line ends,\nthe temporary is destroyed and the combined ",[21,546,543],{},"\nmatcher now refers to non-existent object, so using it causes use-after-free.",[103,549,71],{"id":550},"built-in-matchers",[13,552,553,554,557,558,561,562,565],{},"Every matcher provided by Catch2 is split into 2 parts, a factory\nfunction that lives in the ",[21,555,556],{},"Catch::Matchers"," namespace, and the actual\nmatcher type that is in some deeper namespace and should not be used by\nthe user. In the examples above, we used ",[21,559,560],{},"Catch::Matchers::Contains",".\nThis is the factory function for the\n",[21,563,564],{},"Catch::Matchers::StdString::ContainsMatcher"," type that does the actual\nmatching.",[13,567,568],{},"Out of the box, Catch2 provides the following matchers:",[300,570,572,575],{"id":571},"stdstring-matchers",[21,573,574],{},"std::string"," matchers",[13,577,578,579,581],{},"Catch2 provides 5 different matchers that work with ",[21,580,574],{},",",[583,584,585,591,596,601,607],"ul",{},[586,587,588,581],"li",{},[21,589,590],{},"StartsWith(std::string str, CaseSensitive)",[586,592,593,581],{},[21,594,595],{},"EndsWith(std::string str, CaseSensitive)",[586,597,598,581],{},[21,599,600],{},"ContainsSubstring(std::string str, CaseSensitive)",[586,602,603,606],{},[21,604,605],{},"Equals(std::string str, CaseSensitive)",", and",[586,608,609,298],{},[21,610,611],{},"Matches(std::string str, CaseSensitive)",[13,613,614,615,618,619,621,622,624],{},"The first three should be fairly self-explanatory, they succeed if\nthe argument starts with ",[21,616,617],{},"str",", ends with ",[21,620,617],{},", or contains ",[21,623,617],{},"\nsomewhere inside it.",[13,626,627,628,631,632,298],{},"The ",[21,629,630],{},"Equals"," matcher matches a string if (and only if) the argument\nstring is equal to ",[21,633,617],{},[13,635,636,637,640,641,643,644,647,648,651,652,654,655,658],{},"Finally, the ",[21,638,639],{},"Matches"," matcher performs an ECMAScript regex match using\n",[21,642,617],{}," against the argument string. It is important to know that\nthe match is performed against the string as a whole, meaning that\nthe regex ",[21,645,646],{},"\"abc\""," will not match input string ",[21,649,650],{},"\"abcd\"",". To match\n",[21,653,650],{},", you need to use e.g. ",[21,656,657],{},"\"abc.*\""," as your regex.",[13,660,661],{},"The second argument sets whether the matching should be case-sensitive\nor not. By default, it is case-sensitive.",[10,663,664],{},[13,665,666,668,669],{},[21,667,574],{}," matchers live in ",[21,670,293],{},[300,672,674],{"id":673},"vector-matchers","Vector matchers",[13,676,677],{},[280,678,679],{},"Vector matchers have been deprecated in favour of the generic\nrange matchers with the same functionality.",[13,681,682,683,298],{},"Catch2 provides 5 built-in matchers that work on ",[21,684,685],{},"std::vector",[13,687,688],{},"These are",[583,690,691,697,703,708,714],{},[586,692,693,696],{},[21,694,695],{},"Contains"," which checks whether a specified vector is present in the result",[586,698,699,702],{},[21,700,701],{},"VectorContains"," which checks whether a specified element is present in the result",[586,704,705,707],{},[21,706,630],{}," which checks whether the result is exactly equal (order matters) to a specific vector",[586,709,710,713],{},[21,711,712],{},"UnorderedEquals"," which checks whether the result is equal to a specific vector under a permutation",[586,715,716,719,720,722],{},[21,717,718],{},"Approx"," which checks whether the result is \"approx-equal\" (order matters, but comparison is done via ",[21,721,718],{},") to a specific vector",[10,724,725],{},[13,726,727,728,733],{},"Approx matcher was ",[45,729,732],{"href":730,"rel":731},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fissues\u002F1499",[99],"introduced"," in Catch2 2.7.2.",[13,735,736],{},"An example usage:",[124,738,740],{"className":126,"code":739,"language":128,"meta":129,"style":129},"    std::vector\u003Cint> some_vec{ 1, 2, 3 };\n    REQUIRE_THAT(some_vec, Catch::Matchers::UnorderedEquals(std::vector\u003Cint>{ 3, 2, 1 }));\n",[21,741,742,775],{"__ignoreMap":129},[133,743,744,747,749,752,755,758,761,763,765,767,769,772],{"class":135,"line":136},[133,745,746],{"class":143},"    std",[133,748,148],{"class":147},[133,750,751],{"class":143},"vector",[133,753,754],{"class":147},"\u003C",[133,756,757],{"class":139},"int",[133,759,760],{"class":147},"> some_vec{ ",[133,762,369],{"class":338},[133,764,36],{"class":147},[133,766,344],{"class":338},[133,768,36],{"class":147},[133,770,771],{"class":338},"3",[133,773,774],{"class":147}," };\n",[133,776,777,780,783,786,788,790,792,794,796,799,802,805,808,810,812,814,816,818],{"class":135,"line":156},[133,778,779],{"class":143},"    REQUIRE_THAT",[133,781,782],{"class":147},"(some_vec, ",[133,784,785],{"class":143},"Catch",[133,787,148],{"class":147},[133,789,5],{"class":143},[133,791,148],{"class":147},[133,793,712],{"class":143},[133,795,180],{"class":147},[133,797,798],{"class":143},"std",[133,800,801],{"class":147},"::vector",[133,803,804],{"class":139},"\u003Cint>",[133,806,807],{"class":147},"{ ",[133,809,771],{"class":338},[133,811,36],{"class":147},[133,813,344],{"class":338},[133,815,36],{"class":147},[133,817,369],{"class":338},[133,819,820],{"class":147}," }));\n",[13,822,823,824,298],{},"This assertions will pass, because the elements given to the matchers\nare a permutation of the ones in ",[21,825,826],{},"some_vec",[10,828,829],{},[13,830,831,832],{},"vector matchers live in ",[21,833,834],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FVector.hpp",[300,836,838],{"id":837},"floating-point-matchers","Floating point matchers",[13,840,841],{},"Catch2 provides 4 matchers that target floating point numbers. These\nare:",[583,843,844,849,854,859],{},[586,845,846,581],{},[21,847,848],{},"WithinAbs(double target, double margin)",[586,850,851,606],{},[21,852,853],{},"WithinULP(FloatingPoint target, uint64_t maxUlpDiff)",[586,855,856,298],{},[21,857,858],{},"WithinRel(FloatingPoint target, FloatingPoint eps)",[586,860,861],{},[21,862,863],{},"IsNaN()",[10,865,866],{},[13,867,868,871],{},[21,869,870],{},"WithinRel"," matcher was introduced in Catch2 2.10.0",[10,873,874],{},[13,875,876,879],{},[21,877,878],{},"IsNaN"," matcher was introduced in Catch2 3.3.2.",[13,881,882,883,298],{},"The first three serve to compare two floating pointe numbers. For more\ndetails about how they work, read ",[45,884,886],{"href":885},"\u002Fdocs\u002Fcomparing-floating-point-numbers\u002F#floating-point-matchers","the docs on comparing floating point\nnumbers",[13,888,889,891,892,895,896,898,899,902,903,906],{},[21,890,878],{}," then does exactly what it says on the tin. It matches the input\nif it is a NaN (Not a Number). The advantage of using it over just plain\n",[21,893,894],{},"REQUIRE(std::isnan(x))",", is that if the check fails, with ",[21,897,27],{}," you\nwon't see the value of ",[21,900,901],{},"x",", but with ",[21,904,905],{},"REQUIRE_THAT(x, IsNaN())",", you will.",[300,908,910],{"id":909},"miscellaneous-matchers","Miscellaneous matchers",[13,912,913],{},"Catch2 also provides some matchers and matcher utilities that do not\nquite fit into other categories.",[13,915,916,917,920,921,924,925,928],{},"The first one of them is the ",[21,918,919],{},"Predicate(Callable pred, std::string description)","\nmatcher. It creates a matcher object that calls ",[21,922,923],{},"pred"," for the provided\nargument. The ",[21,926,927],{},"description"," argument allows users to set what the\nresulting matcher should self-describe as if required.",[13,930,931],{},"Do note that you will need to explicitly specify the type of the\nargument, like in this example:",[124,933,935],{"className":126,"code":934,"language":128,"meta":129,"style":129},"REQUIRE_THAT(\"Hello olleH\",\n             Predicate\u003Cstd::string>(\n                 [] (std::string const& str) -> bool { return str.front() == str.back(); },\n                 \"First and last character should be equal\")\n);\n",[21,936,937,949,966,1016,1024],{"__ignoreMap":129},[133,938,939,941,943,946],{"class":135,"line":136},[133,940,111],{"class":143},[133,942,180],{"class":147},[133,944,945],{"class":183},"\"Hello olleH\"",[133,947,948],{"class":147},",\n",[133,950,951,954,956,958,960,963],{"class":135,"line":156},[133,952,953],{"class":143},"             Predicate",[133,955,754],{"class":147},[133,957,798],{"class":143},[133,959,148],{"class":147},[133,961,962],{"class":143},"string",[133,964,965],{"class":147},">(\n",[133,967,968,971,973,975,977,980,984,987,990,993,996,999,1002,1005,1008,1010,1013],{"class":135,"line":163},[133,969,970],{"class":147},"                 [] (",[133,972,798],{"class":143},[133,974,148],{"class":147},[133,976,962],{"class":143},[133,978,979],{"class":139}," const&",[133,981,983],{"class":982},"s9osk"," str",[133,985,986],{"class":147},") -> ",[133,988,989],{"class":139},"bool",[133,991,992],{"class":147}," { ",[133,994,995],{"class":139},"return",[133,997,998],{"class":147}," str.",[133,1000,1001],{"class":143},"front",[133,1003,1004],{"class":147},"() ",[133,1006,1007],{"class":139},"==",[133,1009,998],{"class":147},[133,1011,1012],{"class":143},"back",[133,1014,1015],{"class":147},"(); },\n",[133,1017,1018,1021],{"class":135,"line":238},[133,1019,1020],{"class":183},"                 \"First and last character should be equal\"",[133,1022,1023],{"class":147},")\n",[133,1025,1026],{"class":135,"line":250},[133,1027,408],{"class":147},[10,1029,1030],{},[13,1031,1032,1033],{},"the predicate matcher lives in ",[21,1034,1035],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FPredicate.hpp",[13,1037,1038],{},"The other miscellaneous matcher utility is exception matching.",[1040,1041,1043],"h4",{"id":1042},"matching-exceptions","Matching exceptions",[13,1045,1046],{},"Because exceptions are a bit special, Catch2 has a separate macro for them.",[13,1048,1049],{},"The basic form is",[124,1051,1056],{"className":1052,"code":1054,"language":1055},[1053],"language-text","REQUIRE_THROWS_MATCHES(expr, ExceptionType, Matcher)\n","text",[21,1057,1054],{"__ignoreMap":129},[13,1059,1060,1061,1064,1065,1068,1069,1072],{},"and it checks that the ",[21,1062,1063],{},"expr"," throws an exception, that exception is derived\nfrom the ",[21,1066,1067],{},"ExceptionType"," type, and then ",[21,1070,1071],{},"Matcher::match"," is called on\nthe caught exception.",[10,1074,1075],{},[13,1076,1077,1080,1081],{},[21,1078,1079],{},"REQUIRE_THROWS_MATCHES"," macro lives in ",[21,1082,1083],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FMatchers.hpp",[13,1085,1086,1087,1090],{},"For one-off checks you can use the ",[21,1088,1089],{},"Predicate"," matcher above, e.g.",[124,1092,1094],{"className":126,"code":1093,"language":128,"meta":129,"style":129},"REQUIRE_THROWS_MATCHES(parse(...),\n                       parse_error,\n                       Predicate\u003Cparse_error>([] (parse_error const& err) -> bool { return err.line() == 1; })\n);\n",[21,1095,1096,1108,1113,1156],{"__ignoreMap":129},[133,1097,1098,1100,1102,1105],{"class":135,"line":136},[133,1099,1079],{"class":143},[133,1101,180],{"class":147},[133,1103,1104],{"class":143},"parse",[133,1106,1107],{"class":147},"(...),\n",[133,1109,1110],{"class":135,"line":156},[133,1111,1112],{"class":147},"                       parse_error,\n",[133,1114,1115,1118,1120,1123,1126,1128,1130,1133,1135,1137,1139,1141,1144,1146,1148,1150,1153],{"class":135,"line":163},[133,1116,1117],{"class":143},"                       Predicate",[133,1119,754],{"class":147},[133,1121,1122],{"class":143},"parse_error",[133,1124,1125],{"class":147},">([] (",[133,1127,1122],{"class":143},[133,1129,979],{"class":139},[133,1131,1132],{"class":982}," err",[133,1134,986],{"class":147},[133,1136,989],{"class":139},[133,1138,992],{"class":147},[133,1140,995],{"class":139},[133,1142,1143],{"class":147}," err.",[133,1145,135],{"class":143},[133,1147,1004],{"class":147},[133,1149,1007],{"class":139},[133,1151,1152],{"class":338}," 1",[133,1154,1155],{"class":147},"; })\n",[133,1157,1158],{"class":135,"line":238},[133,1159,408],{"class":147},[13,1161,1162],{},"but if you intend to thoroughly test your error reporting, I recommend\ndefining a specialized matcher.",[13,1164,1165,1166,1169],{},"Catch2 also provides 2 built-in matchers for checking the error message\ninside an exception (it must be derived from ",[21,1167,1168],{},"std::exception","):",[583,1171,1172,1177],{},[586,1173,1174,298],{},[21,1175,1176],{},"Message(std::string message)",[586,1178,1179,298],{},[21,1180,1181],{},"MessageMatches(Matcher matcher)",[10,1183,1184],{},[13,1185,1186,1189,1190,1194],{},[21,1187,1188],{},"MessageMatches"," was ",[45,1191,732],{"href":1192,"rel":1193},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fpull\u002F2570",[99]," in Catch2 3.3.0",[13,1196,1197,1200,1201,1204,1205,298],{},[21,1198,1199],{},"Message"," checks that the exception's\nmessage, as returned from ",[21,1202,1203],{},"what"," is exactly equal to ",[21,1206,1207],{},"message",[13,1209,1210,1212,1213,1215,1216,1218,1219,1222],{},[21,1211,1188],{}," applies the provided matcher on the exception's\nmessage, as returned from ",[21,1214,1203],{},". This is useful in conjunctions with the ",[21,1217,574],{}," matchers (e.g. ",[21,1220,1221],{},"StartsWith",")",[13,1224,1225],{},"Example use:",[124,1227,1229],{"className":126,"code":1228,"language":128,"meta":129,"style":129},"REQUIRE_THROWS_MATCHES(throwsDerivedException(),  DerivedException,  Message(\"DerivedException::what\"));\nREQUIRE_THROWS_MATCHES(throwsDerivedException(),  DerivedException,  MessageMatches(StartsWith(\"DerivedException\")));\n",[21,1230,1231,1252],{"__ignoreMap":129},[133,1232,1233,1235,1237,1240,1243,1245,1247,1250],{"class":135,"line":136},[133,1234,1079],{"class":143},[133,1236,180],{"class":147},[133,1238,1239],{"class":143},"throwsDerivedException",[133,1241,1242],{"class":147},"(),  DerivedException,  ",[133,1244,1199],{"class":143},[133,1246,180],{"class":147},[133,1248,1249],{"class":183},"\"DerivedException::what\"",[133,1251,273],{"class":147},[133,1253,1254,1256,1258,1260,1262,1264,1266,1268,1270,1273],{"class":135,"line":156},[133,1255,1079],{"class":143},[133,1257,180],{"class":147},[133,1259,1239],{"class":143},[133,1261,1242],{"class":147},[133,1263,1188],{"class":143},[133,1265,180],{"class":147},[133,1267,1221],{"class":143},[133,1269,180],{"class":147},[133,1271,1272],{"class":183},"\"DerivedException\"",[133,1274,1275],{"class":147},")));\n",[10,1277,1278],{},[13,1279,1280,1281],{},"the exception message matchers live in ",[21,1282,1283],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FException.hpp",[300,1285,1287],{"id":1286},"generic-range-matchers","Generic range Matchers",[10,1289,1290],{},[13,1291,1292],{},"Generic range matchers were introduced in Catch2 3.0.1",[13,1294,1295],{},"Catch2 also provides some matchers that use the new style matchers\ndefinitions to handle generic range-like types. These are:",[583,1297,1298,1303,1308,1313,1318,1323,1328,1333,1338,1349,1354],{},[586,1299,1300],{},[21,1301,1302],{},"IsEmpty()",[586,1304,1305],{},[21,1306,1307],{},"SizeIs(size_t target_size)",[586,1309,1310],{},[21,1311,1312],{},"SizeIs(Matcher size_matcher)",[586,1314,1315],{},[21,1316,1317],{},"Contains(T&& target_element, Comparator = std::equal_to\u003C>{})",[586,1319,1320],{},[21,1321,1322],{},"Contains(Matcher element_matcher)",[586,1324,1325],{},[21,1326,1327],{},"AllMatch(Matcher element_matcher)",[586,1329,1330],{},[21,1331,1332],{},"AnyMatch(Matcher element_matcher)",[586,1334,1335],{},[21,1336,1337],{},"NoneMatch(Matcher element_matcher)",[586,1339,1340,36,1343,36,1346],{},[21,1341,1342],{},"AllTrue()",[21,1344,1345],{},"AnyTrue()",[21,1347,1348],{},"NoneTrue()",[586,1350,1351],{},[21,1352,1353],{},"RangeEquals(TargetRangeLike&&, Comparator = std::equal_to\u003C>{})",[586,1355,1356],{},[21,1357,1358],{},"UnorderedRangeEquals(TargetRangeLike&&, Comparator = std::equal_to\u003C>{})",[10,1360,1361],{},[13,1362,1363,36,1366,36,1369,1371],{},[21,1364,1365],{},"IsEmpty",[21,1367,1368],{},"SizeIs",[21,1370,695],{}," were introduced in Catch2 3.0.1",[10,1373,1374],{},[13,1375,1376,1371],{},[21,1377,1378],{},"All\u002FAny\u002FNoneMatch",[10,1380,1381],{},[13,1382,1383,1386],{},[21,1384,1385],{},"All\u002FAny\u002FNoneTrue"," were introduced in Catch2 3.1.0",[10,1388,1389],{},[13,1390,1391,24,1394,1397,1398,1194],{},[21,1392,1393],{},"RangeEquals",[21,1395,1396],{},"UnorderedRangeEquals"," matchers were ",[45,1399,732],{"href":1400,"rel":1401},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fpull\u002F2377",[99],[13,1403,1404,1406,1407,1410,1411,1414],{},[21,1405,1365],{}," should be self-explanatory. It successfully matches objects\nthat are empty according to either ",[21,1408,1409],{},"std::empty",", or ADL-found ",[21,1412,1413],{},"empty","\nfree function.",[13,1416,1417,1419,1420,1423],{},[21,1418,1368],{}," checks range's size. If constructed with ",[21,1421,1422],{},"size_t"," arg, the\nmatchers accepts ranges whose size is exactly equal to the arg. If\nconstructed from another matcher, then the resulting matcher accepts\nranges whose size is accepted by the provided matcher.",[13,1425,1426,1428],{},[21,1427,695],{}," accepts ranges that contain specific element. There are\nagain two variants, one that accepts the desired element directly,\nin which case a range is accepted if any of its elements is equal to\nthe target element. The other variant is constructed from a matcher,\nin which case a range is accepted if any of its elements is accepted\nby the provided matcher.",[13,1430,1431,36,1434,197,1437,1440],{},[21,1432,1433],{},"AllMatch",[21,1435,1436],{},"NoneMatch",[21,1438,1439],{},"AnyMatch"," match ranges for which either\nall, none, or any of the contained elements matches the given matcher,\nrespectively.",[13,1442,1443,36,1446,197,1449,1452,1453,1456,1457,1459,1460,298],{},[21,1444,1445],{},"AllTrue",[21,1447,1448],{},"NoneTrue",[21,1450,1451],{},"AnyTrue"," match ranges for which either\nall, none, or any of the contained elements are ",[21,1454,1455],{},"true",", respectively.\nIt works for ranges of ",[21,1458,989],{},"s and ranges of elements (explicitly)\nconvertible to ",[21,1461,989],{},[13,1463,1464,1466,1467,1470,1471,1474,1475,1478],{},[21,1465,1393],{}," compares the range that the matcher is constructed with\n(the \"target range\") against the range to be tested, element-wise. The\nmatch succeeds if all elements from the two ranges compare equal (using\n",[21,1468,1469],{},"operator=="," by default). The ranges do not need to be the same type,\nand the element types do not need to be the same, as long as they are\ncomparable. (e.g. you may compare ",[21,1472,1473],{},"std::vector\u003Cint>"," to ",[21,1476,1477],{},"std::array\u003Cchar>",").",[13,1480,1481,1483,1484,1486,1487,36,1489,1491,1492,1494],{},[21,1482,1396],{}," is similar to ",[21,1485,1393],{},", but the order\ndoes not matter. For example \"1, 2, 3\" would match \"3, 2, 1\", but not\n\"1, 1, 2, 3\" As with ",[21,1488,1393],{},[21,1490,1396],{}," compares\nthe individual elements using ",[21,1493,1469],{}," by default.",[13,1496,1497,1498,24,1500,1502],{},"Both ",[21,1499,1393],{},[21,1501,1396],{}," optionally accept a\npredicate which can be used to compare the containers element-wise.",[13,1504,1505,1506,298],{},"To check a container elementwise against a given matcher, use\n",[21,1507,1433],{},[103,1509,77],{"id":1510},"writing-custom-matchers-old-style",[13,1512,1513,1514,1517,1518,1521,1522,1525,1526,298],{},"The old style of writing matchers has been introduced back in Catch\nClassic. To create an old-style matcher, you have to create your own\ntype that derives from ",[21,1515,1516],{},"Catch::Matchers::MatcherBase\u003CArgT>",", where\n",[21,1519,1520],{},"ArgT"," is the type your matcher works for. Your type has to override\ntwo methods, ",[21,1523,1524],{},"bool match(ArgT const&) const",",\nand ",[21,1527,1528],{},"std::string describe() const",[13,1530,1531,1532,1535,1536,1539],{},"As the name suggests, ",[21,1533,1534],{},"match"," decides whether the provided argument\nis matched (accepted) by the matcher. ",[21,1537,1538],{},"describe"," then provides a\nhuman-oriented description of what the matcher does.",[13,1541,1542],{},"We also recommend that you create factory function, just like Catch2\ndoes, but that is mostly useful for template argument deduction for\ntemplated matchers (assuming you do not have CTAD available).",[13,1544,1545,1546,1549],{},"To combine these into an example, let's say that you want to write\na matcher that decides whether the provided argument is a number\nwithin certain range. We will call it ",[21,1547,1548],{},"IsBetweenMatcher\u003CT>",":",[124,1551,1555],{"className":1552,"code":1553,"language":1554,"meta":129,"style":129},"language-c++ shiki shiki-themes github-dark","#include \u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>\n#include \u003CProgmasoft\u002FCatch3\u002FMatchers\u002FMatchers.hpp>\n\u002F\u002F ...\n\n\ntemplate \u003Ctypename T>\nclass IsBetweenMatcher : public Catch::Matchers::MatcherBase\u003CT> {\n    T m_begin, m_end;\npublic:\n    IsBetweenMatcher(T begin, T end) : m_begin(begin), m_end(end) {}\n\n    bool match(T const& in) const override {\n        return in >= m_begin && in \u003C= m_end;\n    }\n\n    std::string describe() const override {\n        std::ostringstream ss;\n        ss \u003C\u003C \"is between \" \u003C\u003C m_begin \u003C\u003C \" and \" \u003C\u003C m_end;\n        return ss.str();\n    }\n};\n\ntemplate \u003Ctypename T>\nIsBetweenMatcher\u003CT> IsBetween(T begin, T end) {\n    return { begin, end };\n}\n\n\u002F\u002F ...\n\nTEST_CASE(\"Numbers are within range\") {\n    \u002F\u002F infers `double` for the argument type of the matcher\n    CHECK_THAT(3., IsBetween(1., 10.));\n    \u002F\u002F infers `int` for the argument type of the matcher\n    CHECK_THAT(100, IsBetween(1, 10));\n}\n","c++",[21,1556,1557,1562,1567,1572,1576,1580,1586,1592,1598,1604,1610,1615,1621,1627,1633,1638,1644,1650,1656,1662,1667,1673,1678,1683,1689,1695,1701,1706,1711,1716,1722,1728,1734,1740,1746],{"__ignoreMap":129},[133,1558,1559],{"class":135,"line":136},[133,1560,1561],{},"#include \u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>\n",[133,1563,1564],{"class":135,"line":156},[133,1565,1566],{},"#include \u003CProgmasoft\u002FCatch3\u002FMatchers\u002FMatchers.hpp>\n",[133,1568,1569],{"class":135,"line":163},[133,1570,1571],{},"\u002F\u002F ...\n",[133,1573,1574],{"class":135,"line":238},[133,1575,160],{"emptyLinePlaceholder":159},[133,1577,1578],{"class":135,"line":250},[133,1579,160],{"emptyLinePlaceholder":159},[133,1581,1583],{"class":135,"line":1582},6,[133,1584,1585],{},"template \u003Ctypename T>\n",[133,1587,1589],{"class":135,"line":1588},7,[133,1590,1591],{},"class IsBetweenMatcher : public Catch::Matchers::MatcherBase\u003CT> {\n",[133,1593,1595],{"class":135,"line":1594},8,[133,1596,1597],{},"    T m_begin, m_end;\n",[133,1599,1601],{"class":135,"line":1600},9,[133,1602,1603],{},"public:\n",[133,1605,1607],{"class":135,"line":1606},10,[133,1608,1609],{},"    IsBetweenMatcher(T begin, T end) : m_begin(begin), m_end(end) {}\n",[133,1611,1613],{"class":135,"line":1612},11,[133,1614,160],{"emptyLinePlaceholder":159},[133,1616,1618],{"class":135,"line":1617},12,[133,1619,1620],{},"    bool match(T const& in) const override {\n",[133,1622,1624],{"class":135,"line":1623},13,[133,1625,1626],{},"        return in >= m_begin && in \u003C= m_end;\n",[133,1628,1630],{"class":135,"line":1629},14,[133,1631,1632],{},"    }\n",[133,1634,1636],{"class":135,"line":1635},15,[133,1637,160],{"emptyLinePlaceholder":159},[133,1639,1641],{"class":135,"line":1640},16,[133,1642,1643],{},"    std::string describe() const override {\n",[133,1645,1647],{"class":135,"line":1646},17,[133,1648,1649],{},"        std::ostringstream ss;\n",[133,1651,1653],{"class":135,"line":1652},18,[133,1654,1655],{},"        ss \u003C\u003C \"is between \" \u003C\u003C m_begin \u003C\u003C \" and \" \u003C\u003C m_end;\n",[133,1657,1659],{"class":135,"line":1658},19,[133,1660,1661],{},"        return ss.str();\n",[133,1663,1665],{"class":135,"line":1664},20,[133,1666,1632],{},[133,1668,1670],{"class":135,"line":1669},21,[133,1671,1672],{},"};\n",[133,1674,1676],{"class":135,"line":1675},22,[133,1677,160],{"emptyLinePlaceholder":159},[133,1679,1681],{"class":135,"line":1680},23,[133,1682,1585],{},[133,1684,1686],{"class":135,"line":1685},24,[133,1687,1688],{},"IsBetweenMatcher\u003CT> IsBetween(T begin, T end) {\n",[133,1690,1692],{"class":135,"line":1691},25,[133,1693,1694],{},"    return { begin, end };\n",[133,1696,1698],{"class":135,"line":1697},26,[133,1699,1700],{},"}\n",[133,1702,1704],{"class":135,"line":1703},27,[133,1705,160],{"emptyLinePlaceholder":159},[133,1707,1709],{"class":135,"line":1708},28,[133,1710,1571],{},[133,1712,1714],{"class":135,"line":1713},29,[133,1715,160],{"emptyLinePlaceholder":159},[133,1717,1719],{"class":135,"line":1718},30,[133,1720,1721],{},"TEST_CASE(\"Numbers are within range\") {\n",[133,1723,1725],{"class":135,"line":1724},31,[133,1726,1727],{},"    \u002F\u002F infers `double` for the argument type of the matcher\n",[133,1729,1731],{"class":135,"line":1730},32,[133,1732,1733],{},"    CHECK_THAT(3., IsBetween(1., 10.));\n",[133,1735,1737],{"class":135,"line":1736},33,[133,1738,1739],{},"    \u002F\u002F infers `int` for the argument type of the matcher\n",[133,1741,1743],{"class":135,"line":1742},34,[133,1744,1745],{},"    CHECK_THAT(100, IsBetween(1, 10));\n",[133,1747,1749],{"class":135,"line":1748},35,[133,1750,1700],{},[13,1752,1753,1754,1757,1758,1761],{},"Obviously, the code above can be improved somewhat, for example you\nmight want to ",[21,1755,1756],{},"static_assert"," over the fact that ",[21,1759,1760],{},"T"," is an arithmetic\ntype... or generalize the matcher to cover any type for which the user\ncan provide a comparison function object.",[13,1763,1764],{},"Note that while any matcher written using the old style can also be\nwritten using the new style, combining old style matchers should\ngenerally compile faster. Also note that you can combine old and new\nstyle matchers arbitrarily.",[10,1766,1767],{},[13,1768,1769,1772,1773],{},[21,1770,1771],{},"MatcherBase"," lives in ",[21,1774,1083],{},[103,1776,83],{"id":1777},"writing-custom-matchers-new-style",[10,1779,1780],{},[13,1781,1782],{},"New style matchers were introduced in Catch2 3.0.1",[13,1784,1785,1786,1789,1790,1793,1794,298],{},"To create a new-style matcher, you have to create your own type that\nderives from ",[21,1787,1788],{},"Catch::Matchers::MatcherGenericBase",". Your type has to\nalso provide two methods, ",[21,1791,1792],{},"bool match( ... ) const"," and overridden\n",[21,1795,1528],{},[13,1797,1798,1799,1801,1802,1804],{},"Unlike with old-style matchers, there are no requirements on how\nthe ",[21,1800,1534],{}," member function takes its argument. This means that the\nargument can be taken by value or by mutating reference, but also that\nthe matcher's ",[21,1803,1534],{}," member function can be templated.",[13,1806,1807,1808,1811,1812,1815],{},"This allows you to write more complex matcher, such as a matcher that\ncan compare one range-like (something that responds to ",[21,1809,1810],{},"begin"," and\n",[21,1813,1814],{},"end",") object to another, like in the following example:",[124,1817,1819],{"className":126,"code":1818,"language":128,"meta":129,"style":129},"#include \u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>\n#include \u003CProgmasoft\u002FCatch3\u002FMatchers\u002FTemplated.hpp>\n\u002F\u002F ...\n\ntemplate\u003Ctypename Range>\nstruct EqualsRangeMatcher : Catch::Matchers::MatcherGenericBase {\n    EqualsRangeMatcher(Range const& range):\n        range{ range }\n    {}\n\n    template\u003Ctypename OtherRange>\n    bool match(OtherRange const& other) const {\n        using std::begin; using std::end;\n\n        return std::equal(begin(range), end(range), begin(other), end(other));\n    }\n\n    std::string describe() const override {\n        return \"Equals: \" + Catch::rangeToString(range);\n    }\n\nprivate:\n    Range const& range;\n};\n\ntemplate\u003Ctypename Range>\nauto EqualsRange(const Range& range) -> EqualsRangeMatcher\u003CRange> {\n    return EqualsRangeMatcher\u003CRange>{range};\n}\n\nTEST_CASE(\"Combining templated matchers\", \"[matchers][templated]\") {\n    std::array\u003Cint, 3> container{{ 1,2,3 }};\n\n    std::array\u003Cint, 3> a{{ 1,2,3 }};\n    std::vector\u003Cint> b{ 0,1,2 };\n    std::list\u003Cint> c{ 4,5,6 };\n\n    REQUIRE_THAT(container, EqualsRange(a) || EqualsRange(b) || EqualsRange(c));\n}\n",[21,1820,1821,1829,1836,1840,1844,1860,1881,1899,1907,1912,1916,1930,1955,1973,1977,2010,2014,2018,2038,2058,2062,2066,2071,2082,2086,2090,2102,2132,2149,2153,2157,2174,2207,2211,2242,2269,2301,2306,2334],{"__ignoreMap":129},[133,1822,1823,1826],{"class":135,"line":136},[133,1824,1825],{"class":139},"#include",[133,1827,1828],{"class":183}," \u003CProgmasoft\u002FCatch3\u002FTestMacros.hpp>\n",[133,1830,1831,1833],{"class":135,"line":156},[133,1832,1825],{"class":139},[133,1834,1835],{"class":183}," \u003CProgmasoft\u002FCatch3\u002FMatchers\u002FTemplated.hpp>\n",[133,1837,1838],{"class":135,"line":163},[133,1839,1571],{"class":532},[133,1841,1842],{"class":135,"line":238},[133,1843,160],{"emptyLinePlaceholder":159},[133,1845,1846,1849,1851,1854,1857],{"class":135,"line":250},[133,1847,1848],{"class":139},"template",[133,1850,754],{"class":147},[133,1852,1853],{"class":139},"typename",[133,1855,1856],{"class":143}," Range",[133,1858,1859],{"class":147},">\n",[133,1861,1862,1865,1868,1871,1873,1875,1878],{"class":135,"line":1582},[133,1863,1864],{"class":139},"struct",[133,1866,1867],{"class":143}," EqualsRangeMatcher",[133,1869,1870],{"class":147}," : Catch::",[133,1872,5],{"class":143},[133,1874,148],{"class":147},[133,1876,1877],{"class":143},"MatcherGenericBase",[133,1879,1880],{"class":147}," {\n",[133,1882,1883,1886,1888,1891,1893,1896],{"class":135,"line":1588},[133,1884,1885],{"class":143},"    EqualsRangeMatcher",[133,1887,180],{"class":147},[133,1889,1890],{"class":143},"Range",[133,1892,979],{"class":139},[133,1894,1895],{"class":982}," range",[133,1897,1898],{"class":147},"):\n",[133,1900,1901,1904],{"class":135,"line":1594},[133,1902,1903],{"class":143},"        range",[133,1905,1906],{"class":147},"{ range }\n",[133,1908,1909],{"class":135,"line":1600},[133,1910,1911],{"class":147},"    {}\n",[133,1913,1914],{"class":135,"line":1606},[133,1915,160],{"emptyLinePlaceholder":159},[133,1917,1918,1921,1923,1925,1928],{"class":135,"line":1612},[133,1919,1920],{"class":139},"    template",[133,1922,754],{"class":147},[133,1924,1853],{"class":139},[133,1926,1927],{"class":143}," OtherRange",[133,1929,1859],{"class":147},[133,1931,1932,1935,1938,1940,1943,1945,1948,1950,1953],{"class":135,"line":1617},[133,1933,1934],{"class":139},"    bool",[133,1936,1937],{"class":143}," match",[133,1939,180],{"class":147},[133,1941,1942],{"class":143},"OtherRange",[133,1944,979],{"class":139},[133,1946,1947],{"class":982}," other",[133,1949,260],{"class":147},[133,1951,1952],{"class":139},"const",[133,1954,1880],{"class":147},[133,1956,1957,1960,1963,1966,1968,1970],{"class":135,"line":1623},[133,1958,1959],{"class":139},"        using",[133,1961,1962],{"class":143}," std",[133,1964,1965],{"class":147},"::begin; ",[133,1967,140],{"class":139},[133,1969,1962],{"class":143},[133,1971,1972],{"class":147},"::end;\n",[133,1974,1975],{"class":135,"line":1629},[133,1976,160],{"emptyLinePlaceholder":159},[133,1978,1979,1982,1984,1986,1989,1991,1993,1996,1998,2000,2002,2005,2007],{"class":135,"line":1635},[133,1980,1981],{"class":139},"        return",[133,1983,1962],{"class":143},[133,1985,148],{"class":147},[133,1987,1988],{"class":143},"equal",[133,1990,180],{"class":147},[133,1992,1810],{"class":143},[133,1994,1995],{"class":147},"(range), ",[133,1997,1814],{"class":143},[133,1999,1995],{"class":147},[133,2001,1810],{"class":143},[133,2003,2004],{"class":147},"(other), ",[133,2006,1814],{"class":143},[133,2008,2009],{"class":147},"(other));\n",[133,2011,2012],{"class":135,"line":1640},[133,2013,1632],{"class":147},[133,2015,2016],{"class":135,"line":1646},[133,2017,160],{"emptyLinePlaceholder":159},[133,2019,2020,2022,2024,2026,2029,2031,2033,2036],{"class":135,"line":1652},[133,2021,746],{"class":143},[133,2023,148],{"class":147},[133,2025,962],{"class":143},[133,2027,2028],{"class":143}," describe",[133,2030,1004],{"class":147},[133,2032,1952],{"class":139},[133,2034,2035],{"class":139}," override",[133,2037,1880],{"class":147},[133,2039,2040,2042,2045,2048,2050,2052,2055],{"class":135,"line":1658},[133,2041,1981],{"class":139},[133,2043,2044],{"class":183}," \"Equals: \"",[133,2046,2047],{"class":139}," +",[133,2049,144],{"class":143},[133,2051,148],{"class":147},[133,2053,2054],{"class":143},"rangeToString",[133,2056,2057],{"class":147},"(range);\n",[133,2059,2060],{"class":135,"line":1664},[133,2061,1632],{"class":147},[133,2063,2064],{"class":135,"line":1669},[133,2065,160],{"emptyLinePlaceholder":159},[133,2067,2068],{"class":135,"line":1675},[133,2069,2070],{"class":139},"private:\n",[133,2072,2073,2076,2079],{"class":135,"line":1680},[133,2074,2075],{"class":147},"    Range ",[133,2077,2078],{"class":139},"const&",[133,2080,2081],{"class":147}," range;\n",[133,2083,2084],{"class":135,"line":1685},[133,2085,1672],{"class":147},[133,2087,2088],{"class":135,"line":1691},[133,2089,160],{"emptyLinePlaceholder":159},[133,2091,2092,2094,2096,2098,2100],{"class":135,"line":1697},[133,2093,1848],{"class":139},[133,2095,754],{"class":147},[133,2097,1853],{"class":139},[133,2099,1856],{"class":143},[133,2101,1859],{"class":147},[133,2103,2104,2106,2109,2111,2113,2115,2118,2120,2122,2125,2127,2129],{"class":135,"line":1703},[133,2105,384],{"class":139},[133,2107,2108],{"class":143}," EqualsRange",[133,2110,180],{"class":147},[133,2112,1952],{"class":139},[133,2114,1856],{"class":143},[133,2116,2117],{"class":139},"&",[133,2119,1895],{"class":982},[133,2121,986],{"class":147},[133,2123,2124],{"class":143},"EqualsRangeMatcher",[133,2126,754],{"class":147},[133,2128,1890],{"class":143},[133,2130,2131],{"class":147},"> {\n",[133,2133,2134,2137,2139,2141,2143,2146],{"class":135,"line":1708},[133,2135,2136],{"class":139},"    return",[133,2138,1867],{"class":147},[133,2140,754],{"class":139},[133,2142,1890],{"class":147},[133,2144,2145],{"class":139},">",[133,2147,2148],{"class":147},"{range};\n",[133,2150,2151],{"class":135,"line":1713},[133,2152,1700],{"class":147},[133,2154,2155],{"class":135,"line":1718},[133,2156,160],{"emptyLinePlaceholder":159},[133,2158,2159,2161,2163,2166,2168,2171],{"class":135,"line":1724},[133,2160,23],{"class":143},[133,2162,180],{"class":147},[133,2164,2165],{"class":183},"\"Combining templated matchers\"",[133,2167,36],{"class":147},[133,2169,2170],{"class":183},"\"[matchers][templated]\"",[133,2172,2173],{"class":147},") {\n",[133,2175,2176,2178,2180,2183,2185,2187,2189,2191,2194,2196,2198,2200,2202,2204],{"class":135,"line":1730},[133,2177,746],{"class":143},[133,2179,148],{"class":147},[133,2181,2182],{"class":143},"array",[133,2184,754],{"class":147},[133,2186,757],{"class":139},[133,2188,36],{"class":147},[133,2190,771],{"class":338},[133,2192,2193],{"class":147},"> container{{ ",[133,2195,369],{"class":338},[133,2197,581],{"class":147},[133,2199,344],{"class":338},[133,2201,581],{"class":147},[133,2203,771],{"class":338},[133,2205,2206],{"class":147}," }};\n",[133,2208,2209],{"class":135,"line":1736},[133,2210,160],{"emptyLinePlaceholder":159},[133,2212,2213,2215,2217,2219,2221,2223,2225,2227,2230,2232,2234,2236,2238,2240],{"class":135,"line":1742},[133,2214,746],{"class":143},[133,2216,148],{"class":147},[133,2218,2182],{"class":143},[133,2220,754],{"class":147},[133,2222,757],{"class":139},[133,2224,36],{"class":147},[133,2226,771],{"class":338},[133,2228,2229],{"class":147},"> a{{ ",[133,2231,369],{"class":338},[133,2233,581],{"class":147},[133,2235,344],{"class":338},[133,2237,581],{"class":147},[133,2239,771],{"class":338},[133,2241,2206],{"class":147},[133,2243,2244,2246,2248,2250,2252,2254,2257,2259,2261,2263,2265,2267],{"class":135,"line":1748},[133,2245,746],{"class":143},[133,2247,148],{"class":147},[133,2249,751],{"class":143},[133,2251,754],{"class":147},[133,2253,757],{"class":139},[133,2255,2256],{"class":147},"> b{ ",[133,2258,339],{"class":338},[133,2260,581],{"class":147},[133,2262,369],{"class":338},[133,2264,581],{"class":147},[133,2266,344],{"class":338},[133,2268,774],{"class":147},[133,2270,2272,2274,2276,2279,2281,2283,2286,2289,2291,2294,2296,2299],{"class":135,"line":2271},36,[133,2273,746],{"class":143},[133,2275,148],{"class":147},[133,2277,2278],{"class":143},"list",[133,2280,754],{"class":147},[133,2282,757],{"class":139},[133,2284,2285],{"class":147},"> c{ ",[133,2287,2288],{"class":338},"4",[133,2290,581],{"class":147},[133,2292,2293],{"class":338},"5",[133,2295,581],{"class":147},[133,2297,2298],{"class":338},"6",[133,2300,774],{"class":147},[133,2302,2304],{"class":135,"line":2303},37,[133,2305,160],{"emptyLinePlaceholder":159},[133,2307,2309,2311,2314,2317,2320,2322,2324,2327,2329,2331],{"class":135,"line":2308},38,[133,2310,779],{"class":143},[133,2312,2313],{"class":147},"(container, ",[133,2315,2316],{"class":143},"EqualsRange",[133,2318,2319],{"class":147},"(a) ",[133,2321,196],{"class":139},[133,2323,2108],{"class":143},[133,2325,2326],{"class":147},"(b) ",[133,2328,196],{"class":139},[133,2330,2108],{"class":143},[133,2332,2333],{"class":147},"(c));\n",[133,2335,2337],{"class":135,"line":2336},39,[133,2338,1700],{"class":147},[13,2340,2341],{},"Do note that while you can rewrite any matcher from the old style to\na new style matcher, combining new style matchers is more expensive\nin terms of compilation time. Also note that you can combine old style\nand new style matchers arbitrarily.",[10,2343,2344],{},[13,2345,2346,1772,2348],{},[21,2347,1877],{},[21,2349,2350],{},"Progmasoft\u002FCatch3\u002FMatchers\u002FTemplated.hpp",[103,2352,89],{"id":2353},"constexpr-matchers",[10,2355,2356],{},[13,2357,2358],{},"Support for constexpr matchers was introduced in Catch2 3.15.0",[13,2360,2361,2362,2365,2366,2368,2369,2371],{},"When compiled for C++20, the new-style matchers (can) support ",[21,2363,2364],{},"constexpr","\nmatching, albeit not ",[21,2367,2364],{}," stringification. The matcher combinators\nrequire C++26 (or at least P2738) to be ",[21,2370,2364],{}," compatible.",[13,2373,2374,2375,2378],{},"This can be used together with the ",[21,2376,2377],{},"STATIC_REQUIRE_THAT"," macro to write\nmatcher-based static assertions like this:",[124,2380,2382],{"className":126,"code":2381,"language":128,"meta":129,"style":129},"TEST_CASE(\"Constexpr support for matchers\", \"[constexpr][matchers]\") {\n    STATIC_REQUIRE_THAT( 1, MatchAll() );\n    STATIC_REQUIRE_THAT( 1, MatchAll() || MatchAll() );\n    STATIC_REQUIRE_THAT( 1, !!MatchAll() );\n}\n",[21,2383,2384,2400,2417,2438,2455],{"__ignoreMap":129},[133,2385,2386,2388,2390,2393,2395,2398],{"class":135,"line":136},[133,2387,23],{"class":143},[133,2389,180],{"class":147},[133,2391,2392],{"class":183},"\"Constexpr support for matchers\"",[133,2394,36],{"class":147},[133,2396,2397],{"class":183},"\"[constexpr][matchers]\"",[133,2399,2173],{"class":147},[133,2401,2402,2405,2407,2409,2411,2414],{"class":135,"line":156},[133,2403,2404],{"class":143},"    STATIC_REQUIRE_THAT",[133,2406,168],{"class":147},[133,2408,369],{"class":338},[133,2410,36],{"class":147},[133,2412,2413],{"class":143},"MatchAll",[133,2415,2416],{"class":147},"() );\n",[133,2418,2419,2421,2423,2425,2427,2429,2431,2433,2436],{"class":135,"line":163},[133,2420,2404],{"class":143},[133,2422,168],{"class":147},[133,2424,369],{"class":338},[133,2426,36],{"class":147},[133,2428,2413],{"class":143},[133,2430,1004],{"class":147},[133,2432,196],{"class":139},[133,2434,2435],{"class":143}," MatchAll",[133,2437,2416],{"class":147},[133,2439,2440,2442,2444,2446,2448,2451,2453],{"class":135,"line":238},[133,2441,2404],{"class":143},[133,2443,168],{"class":147},[133,2445,369],{"class":338},[133,2447,36],{"class":147},[133,2449,2450],{"class":139},"!!",[133,2452,2413],{"class":143},[133,2454,2416],{"class":147},[133,2456,2457],{"class":135,"line":250},[133,2458,1700],{"class":147},[300,2460,2462],{"id":2461},"first-party-constexpr-matchers","First party constexpr matchers",[13,2464,2465,2466,2468],{},"Some (but not all) of Catch2's generic matchers support ",[21,2467,2364],{},"\nmatching. Currently, this includes:",[583,2470,2471,2475,2481,2485,2489,2493,2501,2505,2509,2513],{},[586,2472,2473],{},[21,2474,1302],{},[586,2476,2477,36,2479],{},[21,2478,1307],{},[21,2480,1312],{},[586,2482,2483],{},[21,2484,1327],{},[586,2486,2487],{},[21,2488,1332],{},[586,2490,2491],{},[21,2492,1337],{},[586,2494,2495,36,2497,36,2499],{},[21,2496,1342],{},[21,2498,1345],{},[21,2500,1348],{},[586,2502,2503],{},[21,2504,1317],{},[586,2506,2507],{},[21,2508,1322],{},[586,2510,2511],{},[21,2512,1353],{},[586,2514,2515],{},[21,2516,1358],{},[2518,2519,2520],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}",{"title":129,"searchDepth":156,"depth":156,"links":2522},[2523,2526,2534,2535,2536],{"id":105,"depth":156,"text":65,"children":2524},[2525],{"id":302,"depth":163,"text":303},{"id":550,"depth":156,"text":71,"children":2527},[2528,2530,2531,2532,2533],{"id":571,"depth":163,"text":2529},"std::string matchers",{"id":673,"depth":163,"text":674},{"id":837,"depth":163,"text":838},{"id":909,"depth":163,"text":910},{"id":1286,"depth":163,"text":1287},{"id":1510,"depth":156,"text":77},{"id":1777,"depth":156,"text":83},{"id":2353,"depth":156,"text":89,"children":2537},[2538],{"id":2461,"depth":163,"text":2462},"md",{},"\u002Fdocs\u002Fmatchers",{"title":5,"description":129},"docs\u002Fmatchers.md","docs\u002Fmatchers","Vnqad0q5xwiJS53cCNoa4SfPuns2EfXqhRyQvuwC2Bg",1794961595176]