[{"data":1,"prerenderedAt":887},["ShallowReactive",2],{"doc-other-macros":3},{"id":4,"title":5,"body":6,"description":127,"extension":880,"meta":881,"navigation":793,"path":882,"seo":883,"slug":53,"source":884,"stem":885,"__hash__":886},"docs\u002Fdocs\u002Fother-macros.md","Other macros",{"type":7,"value":8,"toc":876},"minimark",[9,50,54,57,62,74,110,118,121,210,217,233,236,244,251,264,267,323,333,347,361,363,434,445,462,464,526,536,545,559,570,572,676,680,687,701,703,726,731,738,743,759,761,872],[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},"other-macros",[13,55,56],{},"This page serves as a reference for macros that are not documented\nelsewhere. For now, these macros are separated into 2 rough categories,\n\"assertion related macros\" and \"test case related macros\".",[58,59,61],"h2",{"id":60},"assertion-related-macros","Assertion related macros",[63,64,65],"ul",{},[66,67,68,24,71],"li",{},[21,69,70],{},"CHECKED_IF",[21,72,73],{},"CHECKED_ELSE",[13,75,76,79,80,83,84,88,89,91,92,94,95,98,99,102,103,105,106,109],{},[21,77,78],{},"CHECKED_IF( expr )"," is an ",[21,81,82],{},"if"," replacement, that also applies Catch2's\nstringification machinery to the ",[85,86,87],"em",{},"expr"," and records the result. As with\n",[21,90,82],{},", the block after a ",[21,93,70],{}," is entered only if the expression\nevaluates to ",[21,96,97],{},"true",". ",[21,100,101],{},"CHECKED_ELSE( expr )"," work similarly, but the block\nis entered only if the ",[85,104,87],{}," evaluated to ",[21,107,108],{},"false",".",[10,111,112],{},[13,113,114,117],{},[21,115,116],{},"CHECKED_X"," macros were changed to not count as failure in Catch2 3.0.1.",[13,119,120],{},"Example:",[122,123,128],"pre",{"className":124,"code":125,"language":126,"meta":127,"style":127},"language-cpp shiki shiki-themes github-dark","int a = ...;\nint b = ...;\nCHECKED_IF( a == b ) {\n    \u002F\u002F This block is entered when a == b\n} CHECKED_ELSE ( a == b ) {\n    \u002F\u002F This block is entered when a != b\n}\n","cpp","",[21,129,130,149,161,176,183,198,204],{"__ignoreMap":127},[131,132,135,139,143,146],"span",{"class":133,"line":134},"line",1,[131,136,138],{"class":137},"snl16","int",[131,140,142],{"class":141},"s95oV"," a ",[131,144,145],{"class":137},"=",[131,147,148],{"class":141}," ...;\n",[131,150,152,154,157,159],{"class":133,"line":151},2,[131,153,138],{"class":137},[131,155,156],{"class":141}," b ",[131,158,145],{"class":137},[131,160,148],{"class":141},[131,162,164,167,170,173],{"class":133,"line":163},3,[131,165,70],{"class":166},"svObZ",[131,168,169],{"class":141},"( a ",[131,171,172],{"class":137},"==",[131,174,175],{"class":141}," b ) {\n",[131,177,179],{"class":133,"line":178},4,[131,180,182],{"class":181},"sAwPA","    \u002F\u002F This block is entered when a == b\n",[131,184,186,189,191,194,196],{"class":133,"line":185},5,[131,187,188],{"class":141},"} ",[131,190,73],{"class":166},[131,192,193],{"class":141}," ( a ",[131,195,172],{"class":137},[131,197,175],{"class":141},[131,199,201],{"class":133,"line":200},6,[131,202,203],{"class":181},"    \u002F\u002F This block is entered when a != b\n",[131,205,207],{"class":133,"line":206},7,[131,208,209],{"class":141},"}\n",[63,211,212],{},[66,213,214],{},[21,215,216],{},"CHECK_NOFAIL",[13,218,219,222,223,226,227,229,230,232],{},[21,220,221],{},"CHECK_NOFAIL( expr )"," is a variant of ",[21,224,225],{},"CHECK"," that does not fail the test\ncase if ",[85,228,87],{}," evaluates to ",[21,231,108],{},". This can be useful for checking some\nassumption, that might be violated without the test necessarily failing.",[13,234,235],{},"Example output:",[122,237,242],{"className":238,"code":240,"language":241},[239],"language-text","main.cpp:6:\nFAILED - but was ok:\n  CHECK_NOFAIL( 1 == 2 )\n\nmain.cpp:7:\nPASSED:\n  CHECK( 2 == 2 )\n","text",[21,243,240],{"__ignoreMap":127},[63,245,246],{},[66,247,248],{},[21,249,250],{},"SUCCEED",[13,252,253,256,257,260,261,263],{},[21,254,255],{},"SUCCEED( msg )"," is mostly equivalent with ",[21,258,259],{},"INFO( msg ); REQUIRE( true );",".\nIn other words, ",[21,262,250],{}," is for cases where just reaching a certain line\nmeans that the test has been a success.",[13,265,266],{},"Example usage:",[122,268,270],{"className":124,"code":269,"language":126,"meta":127,"style":127},"TEST_CASE( \"SUCCEED showcase\" ) {\n    int I = 1;\n    SUCCEED( \"I is \" \u003C\u003C I );\n}\n",[21,271,272,286,303,319],{"__ignoreMap":127},[131,273,274,276,279,283],{"class":133,"line":134},[131,275,23],{"class":166},[131,277,278],{"class":141},"( ",[131,280,282],{"class":281},"sU2Wk","\"SUCCEED showcase\"",[131,284,285],{"class":141}," ) {\n",[131,287,288,291,294,296,300],{"class":133,"line":151},[131,289,290],{"class":137},"    int",[131,292,293],{"class":141}," I ",[131,295,145],{"class":137},[131,297,299],{"class":298},"sDLfK"," 1",[131,301,302],{"class":141},";\n",[131,304,305,308,310,313,316],{"class":133,"line":163},[131,306,307],{"class":166},"    SUCCEED",[131,309,278],{"class":141},[131,311,312],{"class":281},"\"I is \"",[131,314,315],{"class":137}," \u003C\u003C",[131,317,318],{"class":141}," I );\n",[131,320,321],{"class":133,"line":178},[131,322,209],{"class":141},[63,324,325],{},[66,326,327,24,330],{},[21,328,329],{},"STATIC_REQUIRE",[21,331,332],{},"STATIC_CHECK",[10,334,335],{},[13,336,337,339,340,346],{},[21,338,329],{}," was ",[45,341,345],{"href":342,"rel":343},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fissues\u002F1362",[344],"nofollow","introduced"," in Catch2 2.4.2.",[13,348,349,352,353,356,357,360],{},[21,350,351],{},"STATIC_REQUIRE( expr )"," is a macro that can be used the same way as a\n",[21,354,355],{},"static_assert",", but also registers the success with Catch2, so it is\nreported as a success at runtime. The whole check can also be deferred\nto the runtime, by defining ",[21,358,359],{},"CATCH_CONFIG_RUNTIME_STATIC_REQUIRE"," before\nincluding the Catch2 header.",[13,362,120],{},[122,364,366],{"className":124,"code":365,"language":126,"meta":127,"style":127},"TEST_CASE(\"STATIC_REQUIRE showcase\", \"[traits]\") {\n    STATIC_REQUIRE( std::is_void\u003Cvoid>::value );\n    STATIC_REQUIRE_FALSE( std::is_void\u003Cint>::value );\n}\n",[21,367,368,386,411,430],{"__ignoreMap":127},[131,369,370,372,375,378,380,383],{"class":133,"line":134},[131,371,23],{"class":166},[131,373,374],{"class":141},"(",[131,376,377],{"class":281},"\"STATIC_REQUIRE showcase\"",[131,379,36],{"class":141},[131,381,382],{"class":281},"\"[traits]\"",[131,384,385],{"class":141},") {\n",[131,387,388,391,393,396,399,402,405,408],{"class":133,"line":151},[131,389,390],{"class":166},"    STATIC_REQUIRE",[131,392,278],{"class":141},[131,394,395],{"class":166},"std",[131,397,398],{"class":141},"::",[131,400,401],{"class":166},"is_void",[131,403,404],{"class":141},"\u003C",[131,406,407],{"class":137},"void",[131,409,410],{"class":141},">::value );\n",[131,412,413,416,418,420,422,424,426,428],{"class":133,"line":163},[131,414,415],{"class":166},"    STATIC_REQUIRE_FALSE",[131,417,278],{"class":141},[131,419,395],{"class":166},[131,421,398],{"class":141},[131,423,401],{"class":166},[131,425,404],{"class":141},[131,427,138],{"class":137},[131,429,410],{"class":141},[131,431,432],{"class":133,"line":178},[131,433,209],{"class":141},[10,435,436],{},[13,437,438,339,440,444],{},[21,439,332],{},[45,441,345],{"href":442,"rel":443},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fpull\u002F2318",[344]," in Catch2 3.0.1.",[13,446,447,450,451,453,454,456,457,459,460,109],{},[21,448,449],{},"STATIC_CHECK( expr )"," is equivalent to ",[21,452,351],{},", with the\ndifference that when ",[21,455,359],{}," is defined, it\nbecomes equivalent to ",[21,458,225],{}," instead of ",[21,461,27],{},[13,463,120],{},[122,465,467],{"className":124,"code":466,"language":126,"meta":127,"style":127},"TEST_CASE(\"STATIC_CHECK showcase\", \"[traits]\") {\n    STATIC_CHECK( std::is_void\u003Cvoid>::value );\n    STATIC_CHECK_FALSE( std::is_void\u003Cint>::value );\n}\n",[21,468,469,484,503,522],{"__ignoreMap":127},[131,470,471,473,475,478,480,482],{"class":133,"line":134},[131,472,23],{"class":166},[131,474,374],{"class":141},[131,476,477],{"class":281},"\"STATIC_CHECK showcase\"",[131,479,36],{"class":141},[131,481,382],{"class":281},[131,483,385],{"class":141},[131,485,486,489,491,493,495,497,499,501],{"class":133,"line":151},[131,487,488],{"class":166},"    STATIC_CHECK",[131,490,278],{"class":141},[131,492,395],{"class":166},[131,494,398],{"class":141},[131,496,401],{"class":166},[131,498,404],{"class":141},[131,500,407],{"class":137},[131,502,410],{"class":141},[131,504,505,508,510,512,514,516,518,520],{"class":133,"line":163},[131,506,507],{"class":166},"    STATIC_CHECK_FALSE",[131,509,278],{"class":141},[131,511,395],{"class":166},[131,513,398],{"class":141},[131,515,401],{"class":166},[131,517,404],{"class":141},[131,519,138],{"class":137},[131,521,410],{"class":141},[131,523,524],{"class":133,"line":178},[131,525,209],{"class":141},[63,527,528],{},[66,529,530,24,533],{},[21,531,532],{},"STATIC_REQUIRE_THAT",[21,534,535],{},"STATIC_CHECK_THAT",[10,537,538],{},[13,539,540,24,542,544],{},[21,541,532],{},[21,543,535],{}," was introduced in Catch2 3.15.0",[13,546,547,550,551,554,555,558],{},[21,548,549],{},"STATIC_{REQUIRE,CHECK}_THAT"," are analogous to ",[21,552,553],{},"STATIC_{REQUIRE,CHECK}",",\nbut for matchers. They are always defined, even if the current compiler\ndoes not support ",[21,556,557],{},"constexpr"," matchers, but in that case the compilation\nwill always fail.",[13,560,561,562,36,564,566,567,569],{},"Just like ",[21,563,553],{},[21,565,549],{}," can be\ndelayed into runtime through the ",[21,568,359],{},"\nconfiguration option.",[13,571,120],{},[122,573,575],{"className":124,"code":574,"language":126,"meta":127,"style":127},"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() || MatchAll() );\n    STATIC_REQUIRE_THAT( 1, !!MatchAll() );\n}\n",[21,576,577,593,611,634,655,672],{"__ignoreMap":127},[131,578,579,581,583,586,588,591],{"class":133,"line":134},[131,580,23],{"class":166},[131,582,374],{"class":141},[131,584,585],{"class":281},"\"Constexpr support for matchers\"",[131,587,36],{"class":141},[131,589,590],{"class":281},"\"[constexpr][matchers]\"",[131,592,385],{"class":141},[131,594,595,598,600,603,605,608],{"class":133,"line":151},[131,596,597],{"class":166},"    STATIC_REQUIRE_THAT",[131,599,278],{"class":141},[131,601,602],{"class":298},"1",[131,604,36],{"class":141},[131,606,607],{"class":166},"MatchAll",[131,609,610],{"class":141},"() );\n",[131,612,613,615,617,619,621,623,626,629,632],{"class":133,"line":163},[131,614,597],{"class":166},[131,616,278],{"class":141},[131,618,602],{"class":298},[131,620,36],{"class":141},[131,622,607],{"class":166},[131,624,625],{"class":141},"() ",[131,627,628],{"class":137},"&&",[131,630,631],{"class":166}," MatchAll",[131,633,610],{"class":141},[131,635,636,638,640,642,644,646,648,651,653],{"class":133,"line":178},[131,637,597],{"class":166},[131,639,278],{"class":141},[131,641,602],{"class":298},[131,643,36],{"class":141},[131,645,607],{"class":166},[131,647,625],{"class":141},[131,649,650],{"class":137},"||",[131,652,631],{"class":166},[131,654,610],{"class":141},[131,656,657,659,661,663,665,668,670],{"class":133,"line":185},[131,658,597],{"class":166},[131,660,278],{"class":141},[131,662,602],{"class":298},[131,664,36],{"class":141},[131,666,667],{"class":137},"!!",[131,669,607],{"class":166},[131,671,610],{"class":141},[131,673,674],{"class":133,"line":200},[131,675,209],{"class":141},[58,677,679],{"id":678},"test-case-related-macros","Test case related macros",[63,681,682],{},[66,683,684],{},[21,685,686],{},"REGISTER_TEST_CASE",[13,688,689,692,693,696,697,700],{},[21,690,691],{},"REGISTER_TEST_CASE( function, description )"," let's you register\na ",[21,694,695],{},"function"," as a test case. The function has to have ",[21,698,699],{},"void()"," signature,\nthe description can contain both name and tags.",[13,702,120],{},[122,704,706],{"className":124,"code":705,"language":126,"meta":127,"style":127},"REGISTER_TEST_CASE( someFunction, \"ManuallyRegistered\", \"[tags]\" );\n",[21,707,708],{"__ignoreMap":127},[131,709,710,712,715,718,720,723],{"class":133,"line":134},[131,711,686],{"class":166},[131,713,714],{"class":141},"( someFunction, ",[131,716,717],{"class":281},"\"ManuallyRegistered\"",[131,719,36],{"class":141},[131,721,722],{"class":281},"\"[tags]\"",[131,724,725],{"class":141}," );\n",[13,727,728],{},[85,729,730],{},"Note that the registration still has to happen before Catch2's session\nis initiated. This means that it either needs to be done in a global\nconstructor, or before Catch2's session is created in user's own main.",[63,732,733],{},[66,734,735],{},[21,736,737],{},"DYNAMIC_SECTION",[10,739,740],{},[13,741,742],{},"Introduced in Catch2 2.3.0.",[13,744,745,747,748,751,752,755,756,758],{},[21,746,737],{}," is a ",[21,749,750],{},"SECTION"," where the user can use ",[21,753,754],{},"operator\u003C\u003C"," to\ncreate the final name for that section. This can be useful with e.g.\ngenerators, or when creating a ",[21,757,750],{}," dynamically, within a loop.",[13,760,120],{},[122,762,764],{"className":124,"code":763,"language":126,"meta":127,"style":127},"TEST_CASE( \"looped SECTION tests\" ) {\n    int a = 1;\n\n    for( int b = 0; b \u003C 10; ++b ) {\n        DYNAMIC_SECTION( \"b is currently: \" \u003C\u003C b ) {\n            CHECK( b > a );\n        }\n    }\n}\n",[21,765,766,777,789,795,828,842,856,861,867],{"__ignoreMap":127},[131,767,768,770,772,775],{"class":133,"line":134},[131,769,23],{"class":166},[131,771,278],{"class":141},[131,773,774],{"class":281},"\"looped SECTION tests\"",[131,776,285],{"class":141},[131,778,779,781,783,785,787],{"class":133,"line":151},[131,780,290],{"class":137},[131,782,142],{"class":141},[131,784,145],{"class":137},[131,786,299],{"class":298},[131,788,302],{"class":141},[131,790,791],{"class":133,"line":163},[131,792,794],{"emptyLinePlaceholder":793},true,"\n",[131,796,797,800,802,804,806,808,811,814,816,819,822,825],{"class":133,"line":178},[131,798,799],{"class":137},"    for",[131,801,278],{"class":141},[131,803,138],{"class":137},[131,805,156],{"class":141},[131,807,145],{"class":137},[131,809,810],{"class":298}," 0",[131,812,813],{"class":141},"; b ",[131,815,404],{"class":137},[131,817,818],{"class":298}," 10",[131,820,821],{"class":141},"; ",[131,823,824],{"class":137},"++",[131,826,827],{"class":141},"b ) {\n",[131,829,830,833,835,838,840],{"class":133,"line":185},[131,831,832],{"class":166},"        DYNAMIC_SECTION",[131,834,278],{"class":141},[131,836,837],{"class":281},"\"b is currently: \"",[131,839,315],{"class":137},[131,841,175],{"class":141},[131,843,844,847,850,853],{"class":133,"line":200},[131,845,846],{"class":166},"            CHECK",[131,848,849],{"class":141},"( b ",[131,851,852],{"class":137},">",[131,854,855],{"class":141}," a );\n",[131,857,858],{"class":133,"line":206},[131,859,860],{"class":141},"        }\n",[131,862,864],{"class":133,"line":863},8,[131,865,866],{"class":141},"    }\n",[131,868,870],{"class":133,"line":869},9,[131,871,209],{"class":141},[873,874,875],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}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 .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}",{"title":127,"searchDepth":151,"depth":151,"links":877},[878,879],{"id":60,"depth":151,"text":61},{"id":678,"depth":151,"text":679},"md",{},"\u002Fdocs\u002Fother-macros",{"title":5,"description":127},"docs\u002Fother-macros.md","docs\u002Fother-macros","eqGsev_z6Bv2ZdGm8fjVeTQiR51OdWchXHgyPy593gU",1794961592285]