[{"data":1,"prerenderedAt":1947},["ShallowReactive",2],{"doc-test-fixtures":3},{"id":4,"title":5,"body":6,"description":180,"extension":1940,"meta":1941,"navigation":323,"path":1942,"seo":1943,"slug":53,"source":1944,"stem":1945,"__hash__":1946},"docs\u002Fdocs\u002Ftest-fixtures.md","Test fixtures",{"type":7,"value":8,"toc":1927},"minimark",[9,50,54,86,90,98,161,168,174,453,463,469,474,613,620,626,637,645,1001,1004,1014,1031,1038,1049,1061,1071,1074,1093,1114,1117,1429,1441,1444,1453,1471,1473,1810,1813,1832,1834,1923],[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},"test-fixtures",[13,55,56,59,62,66,68,72,74,78,80,84],{},[16,57,58],{},"Contents",[60,61],"br",{},[45,63,65],{"href":64},"#non-templated-test-fixtures","Non-Templated test fixtures",[60,67],{},[45,69,71],{"href":70},"#templated-test-fixtures","Templated test fixtures",[60,73],{},[45,75,77],{"href":76},"#signature-based-parameterised-test-fixtures","Signature-based parameterised test fixtures",[60,79],{},[45,81,83],{"href":82},"#template-fixtures-with-types-specified-in-template-type-lists","Template fixtures with types specified in template type lists",[60,85],{},[87,88,65],"h2",{"id":89},"non-templated-test-fixtures",[13,91,92,93,97],{},"Although Catch2 allows you to group tests together as\n",[45,94,96],{"href":95},"\u002Fdocs\u002Ftest-cases-and-sections\u002F","sections within a test case",", it can still\nbe convenient, sometimes, to group them using a more traditional test.\nCatch2 fully supports this too with 3 different macros for\nnon-templated test fixtures. They are:",[99,100,101,114],"table",{},[102,103,104],"thead",{},[105,106,107,111],"tr",{},[108,109,110],"th",{},"Macro",[108,112,113],{},"Description",[115,116,117,133,148],"tbody",{},[105,118,119,126],{},[120,121,122,123],"td",{},"1. ",[21,124,125],{},"TEST_CASE_METHOD(className, ...)",[120,127,128,129,132],{},"Creates a uniquely named class which inherits from the class specified by ",[21,130,131],{},"className",". The test function will be a member of this derived class. An instance of the derived class will be created for every partial run of the test case.",[105,134,135,141],{},[120,136,137,138],{},"2. ",[21,139,140],{},"METHOD_AS_TEST_CASE(member-function, ...)",[120,142,143,144,147],{},"Uses ",[21,145,146],{},"member-function"," as the test function. An instance of the class will be created for each partial run of the test case.",[105,149,150,156],{},[120,151,152,153],{},"3. ",[21,154,155],{},"TEST_CASE_PERSISTENT_FIXTURE(className, ...)",[120,157,128,158,160],{},[21,159,131],{},". The test function will be a member of this derived class. An instance of the derived class will be created at the start of the test run. That instance will be destroyed once the entire test case has ended.",[162,163,122,165],"h3",{"id":164},"_1-test_case_method",[21,166,167],{},"TEST_CASE_METHOD",[13,169,170,171,173],{},"You define a ",[21,172,167],{}," test fixture as a simple structure:",[175,176,181],"pre",{"className":177,"code":178,"language":179,"meta":180,"style":180},"language-c++ shiki shiki-themes github-dark","class UniqueTestsFixture {\n  private:\n   static int uniqueID;\n  protected:\n   DBConnection conn;\n  public:\n   UniqueTestsFixture() : conn(DBConnection::createConnection(\"myDB\")) {\n   }\n  protected:\n   int getID() {\n     return ++uniqueID;\n   }\n };\n\n int UniqueTestsFixture::uniqueID = 0;\n\n TEST_CASE_METHOD(UniqueTestsFixture, \"Create Employee\u002FNo Name\", \"[create]\") {\n   REQUIRE_THROWS(conn.executeSQL(\"INSERT INTO employee (id, name) VALUES (?, ?)\", getID(), \"\"));\n }\n TEST_CASE_METHOD(UniqueTestsFixture, \"Create Employee\u002FNormal\", \"[create]\") {\n   REQUIRE(conn.executeSQL(\"INSERT INTO employee (id, name) VALUES (?, ?)\", getID(), \"Joe Bloggs\"));\n }\n","c++","",[21,182,183,200,206,218,224,233,239,272,278,283,295,307,312,318,325,345,350,370,401,407,423,448],{"__ignoreMap":180},[184,185,188,192,196],"span",{"class":186,"line":187},"line",1,[184,189,191],{"class":190},"snl16","class",[184,193,195],{"class":194},"svObZ"," UniqueTestsFixture",[184,197,199],{"class":198},"s95oV"," {\n",[184,201,203],{"class":186,"line":202},2,[184,204,205],{"class":190},"  private:\n",[184,207,209,212,215],{"class":186,"line":208},3,[184,210,211],{"class":190},"   static",[184,213,214],{"class":190}," int",[184,216,217],{"class":198}," uniqueID;\n",[184,219,221],{"class":186,"line":220},4,[184,222,223],{"class":190},"  protected:\n",[184,225,227,230],{"class":186,"line":226},5,[184,228,229],{"class":194},"   DBConnection",[184,231,232],{"class":198}," conn;\n",[184,234,236],{"class":186,"line":235},6,[184,237,238],{"class":190},"  public:\n",[184,240,242,245,248,251,254,257,260,263,265,269],{"class":186,"line":241},7,[184,243,244],{"class":194},"   UniqueTestsFixture",[184,246,247],{"class":198},"() : ",[184,249,250],{"class":194},"conn",[184,252,253],{"class":198},"(",[184,255,256],{"class":194},"DBConnection",[184,258,259],{"class":198},"::",[184,261,262],{"class":194},"createConnection",[184,264,253],{"class":198},[184,266,268],{"class":267},"sU2Wk","\"myDB\"",[184,270,271],{"class":198},")) {\n",[184,273,275],{"class":186,"line":274},8,[184,276,277],{"class":198},"   }\n",[184,279,281],{"class":186,"line":280},9,[184,282,223],{"class":190},[184,284,286,289,292],{"class":186,"line":285},10,[184,287,288],{"class":190},"   int",[184,290,291],{"class":194}," getID",[184,293,294],{"class":198},"() {\n",[184,296,298,301,304],{"class":186,"line":297},11,[184,299,300],{"class":190},"     return",[184,302,303],{"class":190}," ++",[184,305,306],{"class":198},"uniqueID;\n",[184,308,310],{"class":186,"line":309},12,[184,311,277],{"class":198},[184,313,315],{"class":186,"line":314},13,[184,316,317],{"class":198}," };\n",[184,319,321],{"class":186,"line":320},14,[184,322,324],{"emptyLinePlaceholder":323},true,"\n",[184,326,328,330,332,335,338,342],{"class":186,"line":327},15,[184,329,214],{"class":190},[184,331,195],{"class":194},[184,333,334],{"class":198},"::uniqueID ",[184,336,337],{"class":190},"=",[184,339,341],{"class":340},"sDLfK"," 0",[184,343,344],{"class":198},";\n",[184,346,348],{"class":186,"line":347},16,[184,349,324],{"emptyLinePlaceholder":323},[184,351,353,356,359,362,364,367],{"class":186,"line":352},17,[184,354,355],{"class":194}," TEST_CASE_METHOD",[184,357,358],{"class":198},"(UniqueTestsFixture, ",[184,360,361],{"class":267},"\"Create Employee\u002FNo Name\"",[184,363,36],{"class":198},[184,365,366],{"class":267},"\"[create]\"",[184,368,369],{"class":198},") {\n",[184,371,373,376,379,382,384,387,389,392,395,398],{"class":186,"line":372},18,[184,374,375],{"class":194},"   REQUIRE_THROWS",[184,377,378],{"class":198},"(conn.",[184,380,381],{"class":194},"executeSQL",[184,383,253],{"class":198},[184,385,386],{"class":267},"\"INSERT INTO employee (id, name) VALUES (?, ?)\"",[184,388,36],{"class":198},[184,390,391],{"class":194},"getID",[184,393,394],{"class":198},"(), ",[184,396,397],{"class":267},"\"\"",[184,399,400],{"class":198},"));\n",[184,402,404],{"class":186,"line":403},19,[184,405,406],{"class":198}," }\n",[184,408,410,412,414,417,419,421],{"class":186,"line":409},20,[184,411,355],{"class":194},[184,413,358],{"class":198},[184,415,416],{"class":267},"\"Create Employee\u002FNormal\"",[184,418,36],{"class":198},[184,420,366],{"class":267},[184,422,369],{"class":198},[184,424,426,429,431,433,435,437,439,441,443,446],{"class":186,"line":425},21,[184,427,428],{"class":194},"   REQUIRE",[184,430,378],{"class":198},[184,432,381],{"class":194},[184,434,253],{"class":198},[184,436,386],{"class":267},[184,438,36],{"class":198},[184,440,391],{"class":194},[184,442,394],{"class":198},[184,444,445],{"class":267},"\"Joe Bloggs\"",[184,447,400],{"class":198},[184,449,451],{"class":186,"line":450},22,[184,452,406],{"class":198},[13,454,455,456,459,460,462],{},"The two test cases here will create uniquely-named derived classes of\nUniqueTestsFixture and thus can access the ",[21,457,458],{},"getID()"," protected method\nand ",[21,461,250],{}," member variables. This ensures that both the test cases\nare able to create a DBConnection using the same method\n(DRY principle) and that any ID's created are unique such that the\norder that tests are executed does not matter.",[162,464,137,466],{"id":465},"_2-method_as_test_case",[21,467,468],{},"METHOD_AS_TEST_CASE",[13,470,471,473],{},[21,472,468],{}," lets you register a member function of a class\nas a Catch2 test case. The class will be separately instantiated\nfor each method registered in this way.",[175,475,479],{"className":476,"code":477,"language":478,"meta":180,"style":180},"language-cpp shiki shiki-themes github-dark","class TestClass {\n    std::string s;\n\npublic:\n    TestClass()\n        :s( \"hello\" )\n    {}\n\n    void testCase() {\n        REQUIRE( s == \"hello\" );\n    }\n};\n\n\nMETHOD_AS_TEST_CASE( TestClass::testCase, \"Use class's method as a test case\", \"[class]\" )\n","cpp",[21,480,481,490,503,507,512,520,537,542,546,556,573,578,583,587,591],{"__ignoreMap":180},[184,482,483,485,488],{"class":186,"line":187},[184,484,191],{"class":190},[184,486,487],{"class":194}," TestClass",[184,489,199],{"class":198},[184,491,492,495,497,500],{"class":186,"line":202},[184,493,494],{"class":194},"    std",[184,496,259],{"class":198},[184,498,499],{"class":194},"string",[184,501,502],{"class":198}," s;\n",[184,504,505],{"class":186,"line":208},[184,506,324],{"emptyLinePlaceholder":323},[184,508,509],{"class":186,"line":220},[184,510,511],{"class":190},"public:\n",[184,513,514,517],{"class":186,"line":226},[184,515,516],{"class":194},"    TestClass",[184,518,519],{"class":198},"()\n",[184,521,522,525,528,531,534],{"class":186,"line":235},[184,523,524],{"class":198},"        :",[184,526,527],{"class":194},"s",[184,529,530],{"class":198},"( ",[184,532,533],{"class":267},"\"hello\"",[184,535,536],{"class":198}," )\n",[184,538,539],{"class":186,"line":241},[184,540,541],{"class":198},"    {}\n",[184,543,544],{"class":186,"line":274},[184,545,324],{"emptyLinePlaceholder":323},[184,547,548,551,554],{"class":186,"line":280},[184,549,550],{"class":190},"    void",[184,552,553],{"class":194}," testCase",[184,555,294],{"class":198},[184,557,558,561,564,567,570],{"class":186,"line":285},[184,559,560],{"class":194},"        REQUIRE",[184,562,563],{"class":198},"( s ",[184,565,566],{"class":190},"==",[184,568,569],{"class":267}," \"hello\"",[184,571,572],{"class":198}," );\n",[184,574,575],{"class":186,"line":297},[184,576,577],{"class":198},"    }\n",[184,579,580],{"class":186,"line":309},[184,581,582],{"class":198},"};\n",[184,584,585],{"class":186,"line":314},[184,586,324],{"emptyLinePlaceholder":323},[184,588,589],{"class":186,"line":320},[184,590,324],{"emptyLinePlaceholder":323},[184,592,593,595,597,600,603,606,608,611],{"class":186,"line":327},[184,594,468],{"class":194},[184,596,530],{"class":198},[184,598,599],{"class":194},"TestClass",[184,601,602],{"class":198},"::testCase, ",[184,604,605],{"class":267},"\"Use class's method as a test case\"",[184,607,36],{"class":198},[184,609,610],{"class":267},"\"[class]\"",[184,612,536],{"class":198},[13,614,615,616,619],{},"This type of fixture is similar to ",[45,617,167],{"href":618},"#1-test_case_method"," except in this\ncase it will directly use the provided class to create an object rather than a derived\nclass.",[162,621,152,623],{"id":622},"_3-test_case_persistent_fixture",[21,624,625],{},"TEST_CASE_PERSISTENT_FIXTURE",[10,627,628],{},[13,629,630,636],{},[45,631,635],{"href":632,"rel":633},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fpull\u002F2885",[634],"nofollow","Introduced"," in Catch2 3.7.0",[13,638,639,641,642,644],{},[21,640,625],{}," behaves in the same way as\n",[45,643,167],{"href":618}," except that there will only be\none instance created throughout the entire run of a test case. To\ndemonstrate this have a look at the following example:",[175,646,648],{"className":476,"code":647,"language":478,"meta":180,"style":180},"class ClassWithExpensiveSetup {\npublic:\n    ClassWithExpensiveSetup() {\n        \u002F\u002F expensive construction\n        std::this_thread::sleep_for( std::chrono::seconds( 2 ) );\n    }\n\n    ~ClassWithExpensiveSetup() noexcept {\n        \u002F\u002F expensive destruction\n        std::this_thread::sleep_for( std::chrono::seconds( 1 ) );\n    }\n\n    int getInt() const { return 42; }\n};\n\nstruct MyFixture {\n    mutable int myInt = 0;\n    ClassWithExpensiveSetup expensive;\n};\n\nTEST_CASE_PERSISTENT_FIXTURE( MyFixture, \"Tests with MyFixture\" ) {\n\n    const int val = myInt++;\n\n    SECTION( \"First partial run\" ) {\n        const auto otherValue = expensive.getInt();\n        REQUIRE( val == 0 );\n        REQUIRE( otherValue == 42 );\n    }\n\n    SECTION( \"Second partial run\" ) { REQUIRE( val == 1 ); }\n}\n",[21,649,650,659,663,670,676,714,718,722,735,740,771,775,779,804,808,812,822,838,845,849,853,866,870,891,896,909,932,946,960,965,970,995],{"__ignoreMap":180},[184,651,652,654,657],{"class":186,"line":187},[184,653,191],{"class":190},[184,655,656],{"class":194}," ClassWithExpensiveSetup",[184,658,199],{"class":198},[184,660,661],{"class":186,"line":202},[184,662,511],{"class":190},[184,664,665,668],{"class":186,"line":208},[184,666,667],{"class":194},"    ClassWithExpensiveSetup",[184,669,294],{"class":198},[184,671,672],{"class":186,"line":220},[184,673,675],{"class":674},"sAwPA","        \u002F\u002F expensive construction\n",[184,677,678,681,683,686,688,691,693,696,698,701,703,706,708,711],{"class":186,"line":226},[184,679,680],{"class":194},"        std",[184,682,259],{"class":198},[184,684,685],{"class":194},"this_thread",[184,687,259],{"class":198},[184,689,690],{"class":194},"sleep_for",[184,692,530],{"class":198},[184,694,695],{"class":194},"std",[184,697,259],{"class":198},[184,699,700],{"class":194},"chrono",[184,702,259],{"class":198},[184,704,705],{"class":194},"seconds",[184,707,530],{"class":198},[184,709,710],{"class":340},"2",[184,712,713],{"class":198}," ) );\n",[184,715,716],{"class":186,"line":235},[184,717,577],{"class":198},[184,719,720],{"class":186,"line":241},[184,721,324],{"emptyLinePlaceholder":323},[184,723,724,727,730,733],{"class":186,"line":274},[184,725,726],{"class":194},"    ~ClassWithExpensiveSetup",[184,728,729],{"class":198},"() ",[184,731,732],{"class":190},"noexcept",[184,734,199],{"class":198},[184,736,737],{"class":186,"line":280},[184,738,739],{"class":674},"        \u002F\u002F expensive destruction\n",[184,741,742,744,746,748,750,752,754,756,758,760,762,764,766,769],{"class":186,"line":285},[184,743,680],{"class":194},[184,745,259],{"class":198},[184,747,685],{"class":194},[184,749,259],{"class":198},[184,751,690],{"class":194},[184,753,530],{"class":198},[184,755,695],{"class":194},[184,757,259],{"class":198},[184,759,700],{"class":194},[184,761,259],{"class":198},[184,763,705],{"class":194},[184,765,530],{"class":198},[184,767,768],{"class":340},"1",[184,770,713],{"class":198},[184,772,773],{"class":186,"line":297},[184,774,577],{"class":198},[184,776,777],{"class":186,"line":309},[184,778,324],{"emptyLinePlaceholder":323},[184,780,781,784,787,789,792,795,798,801],{"class":186,"line":314},[184,782,783],{"class":190},"    int",[184,785,786],{"class":194}," getInt",[184,788,729],{"class":198},[184,790,791],{"class":190},"const",[184,793,794],{"class":198}," { ",[184,796,797],{"class":190},"return",[184,799,800],{"class":340}," 42",[184,802,803],{"class":198},"; }\n",[184,805,806],{"class":186,"line":320},[184,807,582],{"class":198},[184,809,810],{"class":186,"line":327},[184,811,324],{"emptyLinePlaceholder":323},[184,813,814,817,820],{"class":186,"line":347},[184,815,816],{"class":190},"struct",[184,818,819],{"class":194}," MyFixture",[184,821,199],{"class":198},[184,823,824,827,829,832,834,836],{"class":186,"line":352},[184,825,826],{"class":190},"    mutable",[184,828,214],{"class":190},[184,830,831],{"class":198}," myInt ",[184,833,337],{"class":190},[184,835,341],{"class":340},[184,837,344],{"class":198},[184,839,840,842],{"class":186,"line":372},[184,841,667],{"class":194},[184,843,844],{"class":198}," expensive;\n",[184,846,847],{"class":186,"line":403},[184,848,582],{"class":198},[184,850,851],{"class":186,"line":409},[184,852,324],{"emptyLinePlaceholder":323},[184,854,855,857,860,863],{"class":186,"line":425},[184,856,625],{"class":194},[184,858,859],{"class":198},"( MyFixture, ",[184,861,862],{"class":267},"\"Tests with MyFixture\"",[184,864,865],{"class":198}," ) {\n",[184,867,868],{"class":186,"line":450},[184,869,324],{"emptyLinePlaceholder":323},[184,871,873,876,878,881,883,886,889],{"class":186,"line":872},23,[184,874,875],{"class":190},"    const",[184,877,214],{"class":190},[184,879,880],{"class":198}," val ",[184,882,337],{"class":190},[184,884,885],{"class":198}," myInt",[184,887,888],{"class":190},"++",[184,890,344],{"class":198},[184,892,894],{"class":186,"line":893},24,[184,895,324],{"emptyLinePlaceholder":323},[184,897,899,902,904,907],{"class":186,"line":898},25,[184,900,901],{"class":194},"    SECTION",[184,903,530],{"class":198},[184,905,906],{"class":267},"\"First partial run\"",[184,908,865],{"class":198},[184,910,912,915,918,921,923,926,929],{"class":186,"line":911},26,[184,913,914],{"class":190},"        const",[184,916,917],{"class":190}," auto",[184,919,920],{"class":198}," otherValue ",[184,922,337],{"class":190},[184,924,925],{"class":198}," expensive.",[184,927,928],{"class":194},"getInt",[184,930,931],{"class":198},"();\n",[184,933,935,937,940,942,944],{"class":186,"line":934},27,[184,936,560],{"class":194},[184,938,939],{"class":198},"( val ",[184,941,566],{"class":190},[184,943,341],{"class":340},[184,945,572],{"class":198},[184,947,949,951,954,956,958],{"class":186,"line":948},28,[184,950,560],{"class":194},[184,952,953],{"class":198},"( otherValue ",[184,955,566],{"class":190},[184,957,800],{"class":340},[184,959,572],{"class":198},[184,961,963],{"class":186,"line":962},29,[184,964,577],{"class":198},[184,966,968],{"class":186,"line":967},30,[184,969,324],{"emptyLinePlaceholder":323},[184,971,973,975,977,980,983,985,987,989,992],{"class":186,"line":972},31,[184,974,901],{"class":194},[184,976,530],{"class":198},[184,978,979],{"class":267},"\"Second partial run\"",[184,981,982],{"class":198}," ) { ",[184,984,27],{"class":194},[184,986,939],{"class":198},[184,988,566],{"class":190},[184,990,991],{"class":340}," 1",[184,993,994],{"class":198}," ); }\n",[184,996,998],{"class":186,"line":997},32,[184,999,1000],{"class":198},"}\n",[13,1002,1003],{},"This example demonstrates two possible use-cases of this fixture type:",[1005,1006,1007,1011],"ol",{},[1008,1009,1010],"li",{},"Improve test run times by reducing the amount of expensive and\nredundant setup and tear-down required.",[1008,1012,1013],{},"Reusing results from the previous partial run, in the current\npartial run.",[13,1015,1016,1017,1020,1021,1024,1025,1027,1028,1030],{},"This test case will be executed twice as there are two leaf sections.\nOn the first run ",[21,1018,1019],{},"val"," will be ",[21,1022,1023],{},"0"," and on the second run ",[21,1026,1019],{}," will be\n",[21,1029,768],{},". This demonstrates that we were able to use the results of the\nprevious partial run in subsequent partial runs.",[13,1032,1033,1034,1037],{},"Additionally, we are simulating an expensive object using\n",[21,1035,1036],{},"std::this_thread::sleep_for",", but real world use-cases could be:",[1005,1039,1040,1043,1046],{},[1008,1041,1042],{},"Creating a D3D12\u002FVulkan device",[1008,1044,1045],{},"Connecting to a database",[1008,1047,1048],{},"Loading a file.",[13,1050,1051,1052,1055,1056,36,1058,1060],{},"The fixture object (",[21,1053,1054],{},"MyFixture",") will be constructed just before the\ntest case begins, and it will be destroyed just after the test case\nends. Therefore, this expensive object will only be created and\ndestroyed once during the execution of this test case. If we had used\n",[21,1057,167],{},[21,1059,1054],{}," would have been created and destroyed\ntwice during the execution of this test case.",[13,1062,1063,1064,1066,1067,1070],{},"NOTE: The member function which runs the test case is ",[21,1065,791],{},". Therefore\nif you want to mutate any member of the fixture it must be marked as\n",[21,1068,1069],{},"mutable"," as shown in this example. This is to make it clear that\nthe initial state of the fixture is intended to mutate during the\nexecution of the test case.",[87,1072,71],{"id":1073},"templated-test-fixtures",[13,1075,1076,1077,1080,1081,1084,1085,1087,1088,24,1090,1092],{},"Catch2 also provides ",[21,1078,1079],{},"TEMPLATE_TEST_CASE_METHOD"," and\n",[21,1082,1083],{},"TEMPLATE_PRODUCT_TEST_CASE_METHOD"," that can be used together\nwith templated fixtures and templated template fixtures to perform\ntests for multiple different types. Unlike ",[21,1086,167],{},",\n",[21,1089,1079],{},[21,1091,1083],{}," do\nrequire the tag specification to be non-empty, as it is followed by\nfurther macro arguments.",[13,1094,1095,1096,1099,1100,1103,1104,1106,1107,1080,1110,1113],{},"Also note that, because of limitations of the C++ preprocessor, if you\nwant to specify a type with multiple template parameters, you need to\nenclose it in parentheses, e.g. ",[21,1097,1098],{},"std::map\u003Cint, std::string>"," needs to be\npassed as ",[21,1101,1102],{},"(std::map\u003Cint, std::string>)",".\nIn the case of ",[21,1105,1083],{},", if a member of the\ntype list should consist of more than single type, it needs to be enclosed\nin another pair of parentheses, e.g. ",[21,1108,1109],{},"(std::map, std::pair)",[21,1111,1112],{},"((int, float), (char, double))",".",[13,1115,1116],{},"Example:",[175,1118,1120],{"className":476,"code":1119,"language":478,"meta":180,"style":180},"template\u003C typename T >\nstruct Template_Fixture {\n    Template_Fixture(): m_a(1) {}\n\n    T m_a;\n};\n\nTEMPLATE_TEST_CASE_METHOD(Template_Fixture,\n                          \"A TEMPLATE_TEST_CASE_METHOD based test run that succeeds\",\n                          \"[class][template]\",\n                          int, float, double) {\n    REQUIRE( Template_Fixture\u003CTestType>::m_a == 1 );\n}\n\ntemplate\u003Ctypename T>\nstruct Template_Template_Fixture {\n    Template_Template_Fixture() {}\n\n    T m_a;\n};\n\ntemplate\u003Ctypename T>\nstruct Foo_class {\n    size_t size() {\n        return 0;\n    }\n};\n\nTEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Template_Fixture,\n                                  \"A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test succeeds\",\n                                  \"[class][template]\",\n                                  (Foo_class, std::vector),\n                                  int) {\n    REQUIRE( Template_Template_Fixture\u003CTestType>::m_a.size() == 0 );\n}\n",[21,1121,1122,1139,1148,1166,1170,1178,1182,1186,1193,1200,1207,1224,1249,1253,1257,1270,1279,1287,1291,1297,1301,1305,1317,1326,1336,1345,1349,1353,1357,1364,1371,1378,1388,1396,1424],{"__ignoreMap":180},[184,1123,1124,1127,1130,1133,1136],{"class":186,"line":187},[184,1125,1126],{"class":190},"template",[184,1128,1129],{"class":198},"\u003C ",[184,1131,1132],{"class":190},"typename",[184,1134,1135],{"class":194}," T",[184,1137,1138],{"class":198}," >\n",[184,1140,1141,1143,1146],{"class":186,"line":202},[184,1142,816],{"class":190},[184,1144,1145],{"class":194}," Template_Fixture",[184,1147,199],{"class":198},[184,1149,1150,1153,1156,1159,1161,1163],{"class":186,"line":208},[184,1151,1152],{"class":194},"    Template_Fixture",[184,1154,1155],{"class":198},"(): ",[184,1157,1158],{"class":194},"m_a",[184,1160,253],{"class":198},[184,1162,768],{"class":340},[184,1164,1165],{"class":198},") {}\n",[184,1167,1168],{"class":186,"line":220},[184,1169,324],{"emptyLinePlaceholder":323},[184,1171,1172,1175],{"class":186,"line":226},[184,1173,1174],{"class":194},"    T",[184,1176,1177],{"class":198}," m_a;\n",[184,1179,1180],{"class":186,"line":235},[184,1181,582],{"class":198},[184,1183,1184],{"class":186,"line":241},[184,1185,324],{"emptyLinePlaceholder":323},[184,1187,1188,1190],{"class":186,"line":274},[184,1189,1079],{"class":194},[184,1191,1192],{"class":198},"(Template_Fixture,\n",[184,1194,1195,1198],{"class":186,"line":280},[184,1196,1197],{"class":267},"                          \"A TEMPLATE_TEST_CASE_METHOD based test run that succeeds\"",[184,1199,1087],{"class":198},[184,1201,1202,1205],{"class":186,"line":285},[184,1203,1204],{"class":267},"                          \"[class][template]\"",[184,1206,1087],{"class":198},[184,1208,1209,1212,1214,1217,1219,1222],{"class":186,"line":297},[184,1210,1211],{"class":190},"                          int",[184,1213,36],{"class":198},[184,1215,1216],{"class":190},"float",[184,1218,36],{"class":198},[184,1220,1221],{"class":190},"double",[184,1223,369],{"class":198},[184,1225,1226,1229,1231,1234,1237,1240,1243,1245,1247],{"class":186,"line":309},[184,1227,1228],{"class":194},"    REQUIRE",[184,1230,530],{"class":198},[184,1232,1233],{"class":194},"Template_Fixture",[184,1235,1236],{"class":198},"\u003C",[184,1238,1239],{"class":194},"TestType",[184,1241,1242],{"class":198},">::m_a ",[184,1244,566],{"class":190},[184,1246,991],{"class":340},[184,1248,572],{"class":198},[184,1250,1251],{"class":186,"line":314},[184,1252,1000],{"class":198},[184,1254,1255],{"class":186,"line":320},[184,1256,324],{"emptyLinePlaceholder":323},[184,1258,1259,1261,1263,1265,1267],{"class":186,"line":327},[184,1260,1126],{"class":190},[184,1262,1236],{"class":198},[184,1264,1132],{"class":190},[184,1266,1135],{"class":194},[184,1268,1269],{"class":198},">\n",[184,1271,1272,1274,1277],{"class":186,"line":347},[184,1273,816],{"class":190},[184,1275,1276],{"class":194}," Template_Template_Fixture",[184,1278,199],{"class":198},[184,1280,1281,1284],{"class":186,"line":352},[184,1282,1283],{"class":194},"    Template_Template_Fixture",[184,1285,1286],{"class":198},"() {}\n",[184,1288,1289],{"class":186,"line":372},[184,1290,324],{"emptyLinePlaceholder":323},[184,1292,1293,1295],{"class":186,"line":403},[184,1294,1174],{"class":194},[184,1296,1177],{"class":198},[184,1298,1299],{"class":186,"line":409},[184,1300,582],{"class":198},[184,1302,1303],{"class":186,"line":425},[184,1304,324],{"emptyLinePlaceholder":323},[184,1306,1307,1309,1311,1313,1315],{"class":186,"line":450},[184,1308,1126],{"class":190},[184,1310,1236],{"class":198},[184,1312,1132],{"class":190},[184,1314,1135],{"class":194},[184,1316,1269],{"class":198},[184,1318,1319,1321,1324],{"class":186,"line":872},[184,1320,816],{"class":190},[184,1322,1323],{"class":194}," Foo_class",[184,1325,199],{"class":198},[184,1327,1328,1331,1334],{"class":186,"line":893},[184,1329,1330],{"class":190},"    size_t",[184,1332,1333],{"class":194}," size",[184,1335,294],{"class":198},[184,1337,1338,1341,1343],{"class":186,"line":898},[184,1339,1340],{"class":190},"        return",[184,1342,341],{"class":340},[184,1344,344],{"class":198},[184,1346,1347],{"class":186,"line":911},[184,1348,577],{"class":198},[184,1350,1351],{"class":186,"line":934},[184,1352,582],{"class":198},[184,1354,1355],{"class":186,"line":948},[184,1356,324],{"emptyLinePlaceholder":323},[184,1358,1359,1361],{"class":186,"line":962},[184,1360,1083],{"class":194},[184,1362,1363],{"class":198},"(Template_Template_Fixture,\n",[184,1365,1366,1369],{"class":186,"line":967},[184,1367,1368],{"class":267},"                                  \"A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test succeeds\"",[184,1370,1087],{"class":198},[184,1372,1373,1376],{"class":186,"line":972},[184,1374,1375],{"class":267},"                                  \"[class][template]\"",[184,1377,1087],{"class":198},[184,1379,1380,1383,1385],{"class":186,"line":997},[184,1381,1382],{"class":198},"                                  (Foo_class, ",[184,1384,695],{"class":194},[184,1386,1387],{"class":198},"::vector),\n",[184,1389,1391,1394],{"class":186,"line":1390},33,[184,1392,1393],{"class":190},"                                  int",[184,1395,369],{"class":198},[184,1397,1399,1401,1403,1406,1408,1410,1413,1416,1418,1420,1422],{"class":186,"line":1398},34,[184,1400,1228],{"class":194},[184,1402,530],{"class":198},[184,1404,1405],{"class":194},"Template_Template_Fixture",[184,1407,1236],{"class":198},[184,1409,1239],{"class":194},[184,1411,1412],{"class":198},">::m_a.",[184,1414,1415],{"class":194},"size",[184,1417,729],{"class":198},[184,1419,566],{"class":190},[184,1421,341],{"class":340},[184,1423,572],{"class":198},[184,1425,1427],{"class":186,"line":1426},35,[184,1428,1000],{"class":198},[13,1430,1431],{},[1432,1433,1434,1435,1437,1438,1440],"em",{},"While there is an upper limit on the number of types you can specify\nin single ",[21,1436,1079],{}," or ",[21,1439,1083],{},",\nthe limit is very high and should not be encountered in practice.",[87,1442,77],{"id":1443},"signature-based-parameterised-test-fixtures",[10,1445,1446],{},[13,1447,1448,1452],{},[45,1449,635],{"href":1450,"rel":1451},"https:\u002F\u002Fgithub.com\u002Fcatchorg\u002FCatch2\u002Fissues\u002F1609",[634]," in Catch2 2.8.0.",[13,1454,1076,1455,24,1458,1461,1462,24,1464,1466,1467,1113],{},[21,1456,1457],{},"TEMPLATE_TEST_CASE_METHOD_SIG",[21,1459,1460],{},"TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG"," to support\nfixtures using non-type template parameters. These test cases work similar to ",[21,1463,1079],{},[21,1465,1083],{},",\nwith additional positional argument for ",[45,1468,1470],{"href":1469},"\u002Fdocs\u002Ftest-cases-and-sections\u002F#signature-based-parametrised-test-cases","signature",[13,1472,1116],{},[175,1474,1476],{"className":476,"code":1475,"language":478,"meta":180,"style":180},"template \u003Cint V>\nstruct Nttp_Fixture{\n    int value = V;\n};\n\nTEMPLATE_TEST_CASE_METHOD_SIG(\n    Nttp_Fixture,\n    \"A TEMPLATE_TEST_CASE_METHOD_SIG based test run that succeeds\",\n    \"[class][template][nttp]\",\n    ((int V), V),\n    1, 3, 6) {\n    REQUIRE(Nttp_Fixture\u003CV>::value > 0);\n}\n\ntemplate\u003Ctypename T>\nstruct Template_Fixture_2 {\n    Template_Fixture_2() {}\n\n    T m_a;\n};\n\ntemplate\u003C typename T, size_t V>\nstruct Template_Foo_2 {\n    size_t size() { return V; }\n};\n\nTEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG(\n    Template_Fixture_2,\n    \"A TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG based test run that succeeds\",\n    \"[class][template][product][nttp]\",\n    ((typename T, size_t S), T, S),\n    (std::array, Template_Foo_2),\n    ((int,2), (float,6))) {\n    REQUIRE(Template_Fixture_2\u003CTestType>{}.m_a.size() >= 2);\n}\n",[21,1477,1478,1493,1503,1515,1519,1523,1530,1535,1542,1549,1559,1576,1601,1605,1609,1621,1630,1637,1641,1647,1651,1655,1674,1683,1697,1701,1705,1711,1716,1723,1730,1745,1755,1778,1806],{"__ignoreMap":180},[184,1479,1480,1482,1485,1488,1491],{"class":186,"line":187},[184,1481,1126],{"class":190},[184,1483,1484],{"class":198}," \u003C",[184,1486,1487],{"class":190},"int",[184,1489,1490],{"class":194}," V",[184,1492,1269],{"class":198},[184,1494,1495,1497,1500],{"class":186,"line":202},[184,1496,816],{"class":190},[184,1498,1499],{"class":194}," Nttp_Fixture",[184,1501,1502],{"class":198},"{\n",[184,1504,1505,1507,1510,1512],{"class":186,"line":208},[184,1506,783],{"class":190},[184,1508,1509],{"class":198}," value ",[184,1511,337],{"class":190},[184,1513,1514],{"class":198}," V;\n",[184,1516,1517],{"class":186,"line":220},[184,1518,582],{"class":198},[184,1520,1521],{"class":186,"line":226},[184,1522,324],{"emptyLinePlaceholder":323},[184,1524,1525,1527],{"class":186,"line":235},[184,1526,1457],{"class":194},[184,1528,1529],{"class":198},"(\n",[184,1531,1532],{"class":186,"line":241},[184,1533,1534],{"class":198},"    Nttp_Fixture,\n",[184,1536,1537,1540],{"class":186,"line":274},[184,1538,1539],{"class":267},"    \"A TEMPLATE_TEST_CASE_METHOD_SIG based test run that succeeds\"",[184,1541,1087],{"class":198},[184,1543,1544,1547],{"class":186,"line":280},[184,1545,1546],{"class":267},"    \"[class][template][nttp]\"",[184,1548,1087],{"class":198},[184,1550,1551,1554,1556],{"class":186,"line":285},[184,1552,1553],{"class":198},"    ((",[184,1555,1487],{"class":190},[184,1557,1558],{"class":198}," V), V),\n",[184,1560,1561,1564,1566,1569,1571,1574],{"class":186,"line":297},[184,1562,1563],{"class":340},"    1",[184,1565,36],{"class":198},[184,1567,1568],{"class":340},"3",[184,1570,36],{"class":198},[184,1572,1573],{"class":340},"6",[184,1575,369],{"class":198},[184,1577,1578,1580,1582,1585,1587,1590,1593,1596,1598],{"class":186,"line":309},[184,1579,1228],{"class":194},[184,1581,253],{"class":198},[184,1583,1584],{"class":194},"Nttp_Fixture",[184,1586,1236],{"class":198},[184,1588,1589],{"class":194},"V",[184,1591,1592],{"class":198},">::value ",[184,1594,1595],{"class":190},">",[184,1597,341],{"class":340},[184,1599,1600],{"class":198},");\n",[184,1602,1603],{"class":186,"line":314},[184,1604,1000],{"class":198},[184,1606,1607],{"class":186,"line":320},[184,1608,324],{"emptyLinePlaceholder":323},[184,1610,1611,1613,1615,1617,1619],{"class":186,"line":327},[184,1612,1126],{"class":190},[184,1614,1236],{"class":198},[184,1616,1132],{"class":190},[184,1618,1135],{"class":194},[184,1620,1269],{"class":198},[184,1622,1623,1625,1628],{"class":186,"line":347},[184,1624,816],{"class":190},[184,1626,1627],{"class":194}," Template_Fixture_2",[184,1629,199],{"class":198},[184,1631,1632,1635],{"class":186,"line":352},[184,1633,1634],{"class":194},"    Template_Fixture_2",[184,1636,1286],{"class":198},[184,1638,1639],{"class":186,"line":372},[184,1640,324],{"emptyLinePlaceholder":323},[184,1642,1643,1645],{"class":186,"line":403},[184,1644,1174],{"class":194},[184,1646,1177],{"class":198},[184,1648,1649],{"class":186,"line":409},[184,1650,582],{"class":198},[184,1652,1653],{"class":186,"line":425},[184,1654,324],{"emptyLinePlaceholder":323},[184,1656,1657,1659,1661,1663,1665,1667,1670,1672],{"class":186,"line":450},[184,1658,1126],{"class":190},[184,1660,1129],{"class":198},[184,1662,1132],{"class":190},[184,1664,1135],{"class":194},[184,1666,36],{"class":198},[184,1668,1669],{"class":190},"size_t",[184,1671,1490],{"class":194},[184,1673,1269],{"class":198},[184,1675,1676,1678,1681],{"class":186,"line":872},[184,1677,816],{"class":190},[184,1679,1680],{"class":194}," Template_Foo_2",[184,1682,199],{"class":198},[184,1684,1685,1687,1689,1692,1694],{"class":186,"line":893},[184,1686,1330],{"class":190},[184,1688,1333],{"class":194},[184,1690,1691],{"class":198},"() { ",[184,1693,797],{"class":190},[184,1695,1696],{"class":198}," V; }\n",[184,1698,1699],{"class":186,"line":898},[184,1700,582],{"class":198},[184,1702,1703],{"class":186,"line":911},[184,1704,324],{"emptyLinePlaceholder":323},[184,1706,1707,1709],{"class":186,"line":934},[184,1708,1460],{"class":194},[184,1710,1529],{"class":198},[184,1712,1713],{"class":186,"line":948},[184,1714,1715],{"class":198},"    Template_Fixture_2,\n",[184,1717,1718,1721],{"class":186,"line":962},[184,1719,1720],{"class":267},"    \"A TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG based test run that succeeds\"",[184,1722,1087],{"class":198},[184,1724,1725,1728],{"class":186,"line":967},[184,1726,1727],{"class":267},"    \"[class][template][product][nttp]\"",[184,1729,1087],{"class":198},[184,1731,1732,1734,1736,1738,1740,1742],{"class":186,"line":972},[184,1733,1553],{"class":198},[184,1735,1132],{"class":190},[184,1737,1135],{"class":194},[184,1739,36],{"class":198},[184,1741,1669],{"class":190},[184,1743,1744],{"class":198}," S), T, S),\n",[184,1746,1747,1750,1752],{"class":186,"line":997},[184,1748,1749],{"class":198},"    (",[184,1751,695],{"class":194},[184,1753,1754],{"class":198},"::array, Template_Foo_2),\n",[184,1756,1757,1759,1761,1764,1766,1769,1771,1773,1775],{"class":186,"line":1390},[184,1758,1553],{"class":198},[184,1760,1487],{"class":190},[184,1762,1763],{"class":198},",",[184,1765,710],{"class":340},[184,1767,1768],{"class":198},"), (",[184,1770,1216],{"class":190},[184,1772,1763],{"class":198},[184,1774,1573],{"class":340},[184,1776,1777],{"class":198},"))) {\n",[184,1779,1780,1782,1785,1787,1789,1791,1794,1796,1798,1801,1804],{"class":186,"line":1398},[184,1781,1228],{"class":194},[184,1783,1784],{"class":198},"(Template_Fixture_2",[184,1786,1236],{"class":190},[184,1788,1239],{"class":198},[184,1790,1595],{"class":190},[184,1792,1793],{"class":198},"{}.m_a.",[184,1795,1415],{"class":194},[184,1797,729],{"class":198},[184,1799,1800],{"class":190},">=",[184,1802,1803],{"class":340}," 2",[184,1805,1600],{"class":198},[184,1807,1808],{"class":186,"line":1426},[184,1809,1000],{"class":198},[87,1811,83],{"id":1812},"template-fixtures-with-types-specified-in-template-type-lists",[13,1814,1076,1815,1818,1819,36,1822,1437,1825,1828,1829,1831],{},[21,1816,1817],{},"TEMPLATE_LIST_TEST_CASE_METHOD"," to support template fixtures with types specified in\ntemplate type lists like ",[21,1820,1821],{},"std::tuple",[21,1823,1824],{},"boost::mpl::list",[21,1826,1827],{},"boost::mp11::mp_list",". This test case works the same as ",[21,1830,1079],{},",\nonly difference is the source of types. This allows you to reuse the template type list in multiple test cases.",[13,1833,1116],{},[175,1835,1837],{"className":476,"code":1836,"language":478,"meta":180,"style":180},"using MyTypes = std::tuple\u003Cint, char, double>;\nTEMPLATE_LIST_TEST_CASE_METHOD(Template_Fixture,\n                               \"Template test case method with test types specified inside std::tuple\",\n                               \"[class][template][list]\",\n                               MyTypes) {\n    REQUIRE( Template_Fixture\u003CTestType>::m_a == 1 );\n}\n",[21,1838,1839,1874,1880,1887,1894,1899,1919],{"__ignoreMap":180},[184,1840,1841,1844,1847,1850,1853,1855,1858,1860,1862,1864,1867,1869,1871],{"class":186,"line":187},[184,1842,1843],{"class":190},"using",[184,1845,1846],{"class":194}," MyTypes",[184,1848,1849],{"class":190}," =",[184,1851,1852],{"class":194}," std",[184,1854,259],{"class":198},[184,1856,1857],{"class":194},"tuple",[184,1859,1236],{"class":198},[184,1861,1487],{"class":190},[184,1863,36],{"class":198},[184,1865,1866],{"class":190},"char",[184,1868,36],{"class":198},[184,1870,1221],{"class":190},[184,1872,1873],{"class":198},">;\n",[184,1875,1876,1878],{"class":186,"line":202},[184,1877,1817],{"class":194},[184,1879,1192],{"class":198},[184,1881,1882,1885],{"class":186,"line":208},[184,1883,1884],{"class":267},"                               \"Template test case method with test types specified inside std::tuple\"",[184,1886,1087],{"class":198},[184,1888,1889,1892],{"class":186,"line":220},[184,1890,1891],{"class":267},"                               \"[class][template][list]\"",[184,1893,1087],{"class":198},[184,1895,1896],{"class":186,"line":226},[184,1897,1898],{"class":198},"                               MyTypes) {\n",[184,1900,1901,1903,1905,1907,1909,1911,1913,1915,1917],{"class":186,"line":235},[184,1902,1228],{"class":194},[184,1904,530],{"class":198},[184,1906,1233],{"class":194},[184,1908,1236],{"class":198},[184,1910,1239],{"class":194},[184,1912,1242],{"class":198},[184,1914,566],{"class":190},[184,1916,991],{"class":340},[184,1918,572],{"class":198},[184,1920,1921],{"class":186,"line":241},[184,1922,1000],{"class":198},[1924,1925,1926],"style",{},"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 .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 .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":180,"searchDepth":202,"depth":202,"links":1928},[1929,1937,1938,1939],{"id":89,"depth":202,"text":65,"children":1930},[1931,1933,1935],{"id":164,"depth":208,"text":1932},"1. TEST_CASE_METHOD",{"id":465,"depth":208,"text":1934},"2. METHOD_AS_TEST_CASE",{"id":622,"depth":208,"text":1936},"3. TEST_CASE_PERSISTENT_FIXTURE",{"id":1073,"depth":202,"text":71},{"id":1443,"depth":202,"text":77},{"id":1812,"depth":202,"text":83},"md",{},"\u002Fdocs\u002Ftest-fixtures",{"title":5,"description":180},"docs\u002Ftest-fixtures.md","docs\u002Ftest-fixtures","bdGoJe0F06BiWKUpY3aBlPOktcZdmEuACF2gfG-SJZ8",1794961593842]