Micro template library A library for building device drivers
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

gtest.h 716 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103
  1. // Copyright 2005, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. //
  30. // The Google C++ Testing and Mocking Framework (Google Test)
  31. //
  32. // This header file defines the public API for Google Test. It should be
  33. // included by any test program that uses Google Test.
  34. //
  35. // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
  36. // leave some internal implementation details in this header file.
  37. // They are clearly marked by comments like this:
  38. //
  39. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  40. //
  41. // Such code is NOT meant to be used by a user directly, and is subject
  42. // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
  43. // program!
  44. //
  45. // Acknowledgment: Google Test borrowed the idea of automatic test
  46. // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
  47. // easyUnit framework.
  48. // GOOGLETEST_CM0001 DO NOT DELETE
  49. #ifndef GTEST_INCLUDE_GTEST_GTEST_H_
  50. #define GTEST_INCLUDE_GTEST_GTEST_H_
  51. #include <limits>
  52. #include <memory>
  53. #include <ostream>
  54. #include <vector>
  55. // Copyright 2005, Google Inc.
  56. // All rights reserved.
  57. //
  58. // Redistribution and use in source and binary forms, with or without
  59. // modification, are permitted provided that the following conditions are
  60. // met:
  61. //
  62. // * Redistributions of source code must retain the above copyright
  63. // notice, this list of conditions and the following disclaimer.
  64. // * Redistributions in binary form must reproduce the above
  65. // copyright notice, this list of conditions and the following disclaimer
  66. // in the documentation and/or other materials provided with the
  67. // distribution.
  68. // * Neither the name of Google Inc. nor the names of its
  69. // contributors may be used to endorse or promote products derived from
  70. // this software without specific prior written permission.
  71. //
  72. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  73. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  74. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  75. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  76. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  77. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  78. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  79. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  80. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  81. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  82. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  83. //
  84. // The Google C++ Testing and Mocking Framework (Google Test)
  85. //
  86. // This header file declares functions and macros used internally by
  87. // Google Test. They are subject to change without notice.
  88. // GOOGLETEST_CM0001 DO NOT DELETE
  89. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
  90. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
  91. // Copyright 2005, Google Inc.
  92. // All rights reserved.
  93. //
  94. // Redistribution and use in source and binary forms, with or without
  95. // modification, are permitted provided that the following conditions are
  96. // met:
  97. //
  98. // * Redistributions of source code must retain the above copyright
  99. // notice, this list of conditions and the following disclaimer.
  100. // * Redistributions in binary form must reproduce the above
  101. // copyright notice, this list of conditions and the following disclaimer
  102. // in the documentation and/or other materials provided with the
  103. // distribution.
  104. // * Neither the name of Google Inc. nor the names of its
  105. // contributors may be used to endorse or promote products derived from
  106. // this software without specific prior written permission.
  107. //
  108. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  109. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  110. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  111. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  112. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  113. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  114. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  115. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  116. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  117. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  118. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  119. //
  120. // Low-level types and utilities for porting Google Test to various
  121. // platforms. All macros ending with _ and symbols defined in an
  122. // internal namespace are subject to change without notice. Code
  123. // outside Google Test MUST NOT USE THEM DIRECTLY. Macros that don't
  124. // end with _ are part of Google Test's public API and can be used by
  125. // code outside Google Test.
  126. //
  127. // This file is fundamental to Google Test. All other Google Test source
  128. // files are expected to #include this. Therefore, it cannot #include
  129. // any other Google Test header.
  130. // GOOGLETEST_CM0001 DO NOT DELETE
  131. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
  132. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
  133. // Environment-describing macros
  134. // -----------------------------
  135. //
  136. // Google Test can be used in many different environments. Macros in
  137. // this section tell Google Test what kind of environment it is being
  138. // used in, such that Google Test can provide environment-specific
  139. // features and implementations.
  140. //
  141. // Google Test tries to automatically detect the properties of its
  142. // environment, so users usually don't need to worry about these
  143. // macros. However, the automatic detection is not perfect.
  144. // Sometimes it's necessary for a user to define some of the following
  145. // macros in the build script to override Google Test's decisions.
  146. //
  147. // If the user doesn't define a macro in the list, Google Test will
  148. // provide a default definition. After this header is #included, all
  149. // macros in this list will be defined to either 1 or 0.
  150. //
  151. // Notes to maintainers:
  152. // - Each macro here is a user-tweakable knob; do not grow the list
  153. // lightly.
  154. // - Use #if to key off these macros. Don't use #ifdef or "#if
  155. // defined(...)", which will not work as these macros are ALWAYS
  156. // defined.
  157. //
  158. // GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2)
  159. // is/isn't available.
  160. // GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
  161. // are enabled.
  162. // GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
  163. // is/isn't available
  164. // GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring
  165. // is/isn't available
  166. // GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular
  167. // expressions are/aren't available.
  168. // GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
  169. // is/isn't available.
  170. // GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
  171. // enabled.
  172. // GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
  173. // std::wstring does/doesn't work (Google Test can
  174. // be used where std::wstring is unavailable).
  175. // GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
  176. // compiler supports Microsoft's "Structured
  177. // Exception Handling".
  178. // GTEST_HAS_STREAM_REDIRECTION
  179. // - Define it to 1/0 to indicate whether the
  180. // platform supports I/O stream redirection using
  181. // dup() and dup2().
  182. // GTEST_LINKED_AS_SHARED_LIBRARY
  183. // - Define to 1 when compiling tests that use
  184. // Google Test as a shared library (known as
  185. // DLL on Windows).
  186. // GTEST_CREATE_SHARED_LIBRARY
  187. // - Define to 1 when compiling Google Test itself
  188. // as a shared library.
  189. // GTEST_DEFAULT_DEATH_TEST_STYLE
  190. // - The default value of --gtest_death_test_style.
  191. // The legacy default has been "fast" in the open
  192. // source version since 2008. The recommended value
  193. // is "threadsafe", and can be set in
  194. // custom/gtest-port.h.
  195. // Platform-indicating macros
  196. // --------------------------
  197. //
  198. // Macros indicating the platform on which Google Test is being used
  199. // (a macro is defined to 1 if compiled on the given platform;
  200. // otherwise UNDEFINED -- it's never defined to 0.). Google Test
  201. // defines these macros automatically. Code outside Google Test MUST
  202. // NOT define them.
  203. //
  204. // GTEST_OS_AIX - IBM AIX
  205. // GTEST_OS_CYGWIN - Cygwin
  206. // GTEST_OS_FREEBSD - FreeBSD
  207. // GTEST_OS_FUCHSIA - Fuchsia
  208. // GTEST_OS_HPUX - HP-UX
  209. // GTEST_OS_LINUX - Linux
  210. // GTEST_OS_LINUX_ANDROID - Google Android
  211. // GTEST_OS_MAC - Mac OS X
  212. // GTEST_OS_IOS - iOS
  213. // GTEST_OS_NACL - Google Native Client (NaCl)
  214. // GTEST_OS_NETBSD - NetBSD
  215. // GTEST_OS_OPENBSD - OpenBSD
  216. // GTEST_OS_OS2 - OS/2
  217. // GTEST_OS_QNX - QNX
  218. // GTEST_OS_SOLARIS - Sun Solaris
  219. // GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile)
  220. // GTEST_OS_WINDOWS_DESKTOP - Windows Desktop
  221. // GTEST_OS_WINDOWS_MINGW - MinGW
  222. // GTEST_OS_WINDOWS_MOBILE - Windows Mobile
  223. // GTEST_OS_WINDOWS_PHONE - Windows Phone
  224. // GTEST_OS_WINDOWS_RT - Windows Store App/WinRT
  225. // GTEST_OS_ZOS - z/OS
  226. //
  227. // Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
  228. // most stable support. Since core members of the Google Test project
  229. // don't have access to other platforms, support for them may be less
  230. // stable. If you notice any problems on your platform, please notify
  231. // googletestframework@googlegroups.com (patches for fixing them are
  232. // even more welcome!).
  233. //
  234. // It is possible that none of the GTEST_OS_* macros are defined.
  235. // Feature-indicating macros
  236. // -------------------------
  237. //
  238. // Macros indicating which Google Test features are available (a macro
  239. // is defined to 1 if the corresponding feature is supported;
  240. // otherwise UNDEFINED -- it's never defined to 0.). Google Test
  241. // defines these macros automatically. Code outside Google Test MUST
  242. // NOT define them.
  243. //
  244. // These macros are public so that portable tests can be written.
  245. // Such tests typically surround code using a feature with an #if
  246. // which controls that code. For example:
  247. //
  248. // #if GTEST_HAS_DEATH_TEST
  249. // EXPECT_DEATH(DoSomethingDeadly());
  250. // #endif
  251. //
  252. // GTEST_HAS_DEATH_TEST - death tests
  253. // GTEST_HAS_TYPED_TEST - typed tests
  254. // GTEST_HAS_TYPED_TEST_P - type-parameterized tests
  255. // GTEST_IS_THREADSAFE - Google Test is thread-safe.
  256. // GOOGLETEST_CM0007 DO NOT DELETE
  257. // GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
  258. // GTEST_HAS_POSIX_RE (see above) which users can
  259. // define themselves.
  260. // GTEST_USES_SIMPLE_RE - our own simple regex is used;
  261. // the above RE\b(s) are mutually exclusive.
  262. // Misc public macros
  263. // ------------------
  264. //
  265. // GTEST_FLAG(flag_name) - references the variable corresponding to
  266. // the given Google Test flag.
  267. // Internal utilities
  268. // ------------------
  269. //
  270. // The following macros and utilities are for Google Test's INTERNAL
  271. // use only. Code outside Google Test MUST NOT USE THEM DIRECTLY.
  272. //
  273. // Macros for basic C++ coding:
  274. // GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
  275. // GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
  276. // variable don't have to be used.
  277. // GTEST_DISALLOW_ASSIGN_ - disables operator=.
  278. // GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
  279. // GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
  280. // GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
  281. // suppressed (constant conditional).
  282. // GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
  283. // is suppressed.
  284. //
  285. // Synchronization:
  286. // Mutex, MutexLock, ThreadLocal, GetThreadCount()
  287. // - synchronization primitives.
  288. //
  289. // Template meta programming:
  290. // IteratorTraits - partial implementation of std::iterator_traits, which
  291. // is not available in libCstd when compiled with Sun C++.
  292. //
  293. //
  294. // Regular expressions:
  295. // RE - a simple regular expression class using the POSIX
  296. // Extended Regular Expression syntax on UNIX-like platforms
  297. // GOOGLETEST_CM0008 DO NOT DELETE
  298. // or a reduced regular exception syntax on other
  299. // platforms, including Windows.
  300. // Logging:
  301. // GTEST_LOG_() - logs messages at the specified severity level.
  302. // LogToStderr() - directs all log messages to stderr.
  303. // FlushInfoLog() - flushes informational log messages.
  304. //
  305. // Stdout and stderr capturing:
  306. // CaptureStdout() - starts capturing stdout.
  307. // GetCapturedStdout() - stops capturing stdout and returns the captured
  308. // string.
  309. // CaptureStderr() - starts capturing stderr.
  310. // GetCapturedStderr() - stops capturing stderr and returns the captured
  311. // string.
  312. //
  313. // Integer types:
  314. // TypeWithSize - maps an integer to a int type.
  315. // Int32, UInt32, Int64, UInt64, TimeInMillis
  316. // - integers of known sizes.
  317. // BiggestInt - the biggest signed integer type.
  318. //
  319. // Command-line utilities:
  320. // GTEST_DECLARE_*() - declares a flag.
  321. // GTEST_DEFINE_*() - defines a flag.
  322. // GetInjectableArgvs() - returns the command line as a vector of strings.
  323. //
  324. // Environment variable utilities:
  325. // GetEnv() - gets the value of an environment variable.
  326. // BoolFromGTestEnv() - parses a bool environment variable.
  327. // Int32FromGTestEnv() - parses an Int32 environment variable.
  328. // StringFromGTestEnv() - parses a string environment variable.
  329. #include <ctype.h> // for isspace, etc
  330. #include <stddef.h> // for ptrdiff_t
  331. #include <stdio.h>
  332. #include <stdlib.h>
  333. #include <string.h>
  334. #include <memory>
  335. #include <type_traits>
  336. #ifndef _WIN32_WCE
  337. # include <sys/types.h>
  338. # include <sys/stat.h>
  339. #endif // !_WIN32_WCE
  340. #if defined __APPLE__
  341. # include <AvailabilityMacros.h>
  342. # include <TargetConditionals.h>
  343. #endif
  344. // Brings in the definition of HAS_GLOBAL_STRING. This must be done
  345. // BEFORE we test HAS_GLOBAL_STRING.
  346. #include <string> // NOLINT
  347. #include <algorithm> // NOLINT
  348. #include <iostream> // NOLINT
  349. #include <sstream> // NOLINT
  350. #include <tuple>
  351. #include <utility>
  352. #include <vector> // NOLINT
  353. // Copyright 2015, Google Inc.
  354. // All rights reserved.
  355. //
  356. // Redistribution and use in source and binary forms, with or without
  357. // modification, are permitted provided that the following conditions are
  358. // met:
  359. //
  360. // * Redistributions of source code must retain the above copyright
  361. // notice, this list of conditions and the following disclaimer.
  362. // * Redistributions in binary form must reproduce the above
  363. // copyright notice, this list of conditions and the following disclaimer
  364. // in the documentation and/or other materials provided with the
  365. // distribution.
  366. // * Neither the name of Google Inc. nor the names of its
  367. // contributors may be used to endorse or promote products derived from
  368. // this software without specific prior written permission.
  369. //
  370. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  371. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  372. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  373. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  374. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  375. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  376. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  377. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  378. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  379. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  380. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  381. //
  382. // The Google C++ Testing and Mocking Framework (Google Test)
  383. //
  384. // This header file defines the GTEST_OS_* macro.
  385. // It is separate from gtest-port.h so that custom/gtest-port.h can include it.
  386. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
  387. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
  388. // Determines the platform on which Google Test is compiled.
  389. #ifdef __CYGWIN__
  390. # define GTEST_OS_CYGWIN 1
  391. # elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
  392. # define GTEST_OS_WINDOWS_MINGW 1
  393. # define GTEST_OS_WINDOWS 1
  394. #elif defined _WIN32
  395. # define GTEST_OS_WINDOWS 1
  396. # ifdef _WIN32_WCE
  397. # define GTEST_OS_WINDOWS_MOBILE 1
  398. # elif defined(WINAPI_FAMILY)
  399. # include <winapifamily.h>
  400. # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  401. # define GTEST_OS_WINDOWS_DESKTOP 1
  402. # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
  403. # define GTEST_OS_WINDOWS_PHONE 1
  404. # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
  405. # define GTEST_OS_WINDOWS_RT 1
  406. # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
  407. # define GTEST_OS_WINDOWS_PHONE 1
  408. # define GTEST_OS_WINDOWS_TV_TITLE 1
  409. # else
  410. // WINAPI_FAMILY defined but no known partition matched.
  411. // Default to desktop.
  412. # define GTEST_OS_WINDOWS_DESKTOP 1
  413. # endif
  414. # else
  415. # define GTEST_OS_WINDOWS_DESKTOP 1
  416. # endif // _WIN32_WCE
  417. #elif defined __OS2__
  418. # define GTEST_OS_OS2 1
  419. #elif defined __APPLE__
  420. # define GTEST_OS_MAC 1
  421. # if TARGET_OS_IPHONE
  422. # define GTEST_OS_IOS 1
  423. # endif
  424. #elif defined __FreeBSD__
  425. # define GTEST_OS_FREEBSD 1
  426. #elif defined __Fuchsia__
  427. # define GTEST_OS_FUCHSIA 1
  428. #elif defined __linux__
  429. # define GTEST_OS_LINUX 1
  430. # if defined __ANDROID__
  431. # define GTEST_OS_LINUX_ANDROID 1
  432. # endif
  433. #elif defined __MVS__
  434. # define GTEST_OS_ZOS 1
  435. #elif defined(__sun) && defined(__SVR4)
  436. # define GTEST_OS_SOLARIS 1
  437. #elif defined(_AIX)
  438. # define GTEST_OS_AIX 1
  439. #elif defined(__hpux)
  440. # define GTEST_OS_HPUX 1
  441. #elif defined __native_client__
  442. # define GTEST_OS_NACL 1
  443. #elif defined __NetBSD__
  444. # define GTEST_OS_NETBSD 1
  445. #elif defined __OpenBSD__
  446. # define GTEST_OS_OPENBSD 1
  447. #elif defined __QNX__
  448. # define GTEST_OS_QNX 1
  449. #endif // __CYGWIN__
  450. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
  451. // Copyright 2015, Google Inc.
  452. // All rights reserved.
  453. //
  454. // Redistribution and use in source and binary forms, with or without
  455. // modification, are permitted provided that the following conditions are
  456. // met:
  457. //
  458. // * Redistributions of source code must retain the above copyright
  459. // notice, this list of conditions and the following disclaimer.
  460. // * Redistributions in binary form must reproduce the above
  461. // copyright notice, this list of conditions and the following disclaimer
  462. // in the documentation and/or other materials provided with the
  463. // distribution.
  464. // * Neither the name of Google Inc. nor the names of its
  465. // contributors may be used to endorse or promote products derived from
  466. // this software without specific prior written permission.
  467. //
  468. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  469. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  470. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  471. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  472. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  473. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  474. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  475. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  476. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  477. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  478. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  479. //
  480. // Injection point for custom user configurations. See README for details
  481. //
  482. // ** Custom implementation starts here **
  483. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
  484. #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
  485. #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
  486. #if !defined(GTEST_DEV_EMAIL_)
  487. # define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
  488. # define GTEST_FLAG_PREFIX_ "gtest_"
  489. # define GTEST_FLAG_PREFIX_DASH_ "gtest-"
  490. # define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
  491. # define GTEST_NAME_ "Google Test"
  492. # define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
  493. #endif // !defined(GTEST_DEV_EMAIL_)
  494. #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
  495. # define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
  496. #endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
  497. // Determines the version of gcc that is used to compile this.
  498. #ifdef __GNUC__
  499. // 40302 means version 4.3.2.
  500. # define GTEST_GCC_VER_ \
  501. (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
  502. #endif // __GNUC__
  503. // Macros for disabling Microsoft Visual C++ warnings.
  504. //
  505. // GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
  506. // /* code that triggers warnings C4800 and C4385 */
  507. // GTEST_DISABLE_MSC_WARNINGS_POP_()
  508. #if defined(_MSC_VER)
  509. # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
  510. __pragma(warning(push)) \
  511. __pragma(warning(disable: warnings))
  512. # define GTEST_DISABLE_MSC_WARNINGS_POP_() \
  513. __pragma(warning(pop))
  514. #else
  515. // Not all compilers are MSVC
  516. # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
  517. # define GTEST_DISABLE_MSC_WARNINGS_POP_()
  518. #endif
  519. // Clang on Windows does not understand MSVC's pragma warning.
  520. // We need clang-specific way to disable function deprecation warning.
  521. #ifdef __clang__
  522. # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
  523. _Pragma("clang diagnostic push") \
  524. _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
  525. _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
  526. #define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
  527. _Pragma("clang diagnostic pop")
  528. #else
  529. # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
  530. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
  531. # define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
  532. GTEST_DISABLE_MSC_WARNINGS_POP_()
  533. #endif
  534. // Brings in definitions for functions used in the testing::internal::posix
  535. // namespace (read, write, close, chdir, isatty, stat). We do not currently
  536. // use them on Windows Mobile.
  537. #if GTEST_OS_WINDOWS
  538. # if !GTEST_OS_WINDOWS_MOBILE
  539. # include <direct.h>
  540. # include <io.h>
  541. # endif
  542. // In order to avoid having to include <windows.h>, use forward declaration
  543. #if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
  544. // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
  545. // separate (equivalent) structs, instead of using typedef
  546. typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
  547. #else
  548. // Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
  549. // This assumption is verified by
  550. // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
  551. typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
  552. #endif
  553. #else
  554. // This assumes that non-Windows OSes provide unistd.h. For OSes where this
  555. // is not the case, we need to include headers that provide the functions
  556. // mentioned above.
  557. # include <unistd.h>
  558. # include <strings.h>
  559. #endif // GTEST_OS_WINDOWS
  560. #if GTEST_OS_LINUX_ANDROID
  561. // Used to define __ANDROID_API__ matching the target NDK API level.
  562. # include <android/api-level.h> // NOLINT
  563. #endif
  564. // Defines this to true iff Google Test can use POSIX regular expressions.
  565. #ifndef GTEST_HAS_POSIX_RE
  566. # if GTEST_OS_LINUX_ANDROID
  567. // On Android, <regex.h> is only available starting with Gingerbread.
  568. # define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
  569. # else
  570. # define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
  571. # endif
  572. #endif
  573. #if GTEST_USES_PCRE
  574. // The appropriate headers have already been included.
  575. #elif GTEST_HAS_POSIX_RE
  576. // On some platforms, <regex.h> needs someone to define size_t, and
  577. // won't compile otherwise. We can #include it here as we already
  578. // included <stdlib.h>, which is guaranteed to define size_t through
  579. // <stddef.h>.
  580. # include <regex.h> // NOLINT
  581. # define GTEST_USES_POSIX_RE 1
  582. #elif GTEST_OS_WINDOWS
  583. // <regex.h> is not available on Windows. Use our own simple regex
  584. // implementation instead.
  585. # define GTEST_USES_SIMPLE_RE 1
  586. #else
  587. // <regex.h> may not be available on this platform. Use our own
  588. // simple regex implementation instead.
  589. # define GTEST_USES_SIMPLE_RE 1
  590. #endif // GTEST_USES_PCRE
  591. #ifndef GTEST_HAS_EXCEPTIONS
  592. // The user didn't tell us whether exceptions are enabled, so we need
  593. // to figure it out.
  594. # if defined(_MSC_VER) && defined(_CPPUNWIND)
  595. // MSVC defines _CPPUNWIND to 1 iff exceptions are enabled.
  596. # define GTEST_HAS_EXCEPTIONS 1
  597. # elif defined(__BORLANDC__)
  598. // C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
  599. // macro to enable exceptions, so we'll do the same.
  600. // Assumes that exceptions are enabled by default.
  601. # ifndef _HAS_EXCEPTIONS
  602. # define _HAS_EXCEPTIONS 1
  603. # endif // _HAS_EXCEPTIONS
  604. # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
  605. # elif defined(__clang__)
  606. // clang defines __EXCEPTIONS iff exceptions are enabled before clang 220714,
  607. // but iff cleanups are enabled after that. In Obj-C++ files, there can be
  608. // cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
  609. // are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
  610. // exceptions starting at clang r206352, but which checked for cleanups prior to
  611. // that. To reliably check for C++ exception availability with clang, check for
  612. // __EXCEPTIONS && __has_feature(cxx_exceptions).
  613. # define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
  614. # elif defined(__GNUC__) && __EXCEPTIONS
  615. // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
  616. # define GTEST_HAS_EXCEPTIONS 1
  617. # elif defined(__SUNPRO_CC)
  618. // Sun Pro CC supports exceptions. However, there is no compile-time way of
  619. // detecting whether they are enabled or not. Therefore, we assume that
  620. // they are enabled unless the user tells us otherwise.
  621. # define GTEST_HAS_EXCEPTIONS 1
  622. # elif defined(__IBMCPP__) && __EXCEPTIONS
  623. // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
  624. # define GTEST_HAS_EXCEPTIONS 1
  625. # elif defined(__HP_aCC)
  626. // Exception handling is in effect by default in HP aCC compiler. It has to
  627. // be turned of by +noeh compiler option if desired.
  628. # define GTEST_HAS_EXCEPTIONS 1
  629. # else
  630. // For other compilers, we assume exceptions are disabled to be
  631. // conservative.
  632. # define GTEST_HAS_EXCEPTIONS 0
  633. # endif // defined(_MSC_VER) || defined(__BORLANDC__)
  634. #endif // GTEST_HAS_EXCEPTIONS
  635. #if !defined(GTEST_HAS_STD_STRING)
  636. // Even though we don't use this macro any longer, we keep it in case
  637. // some clients still depend on it.
  638. # define GTEST_HAS_STD_STRING 1
  639. #elif !GTEST_HAS_STD_STRING
  640. // The user told us that ::std::string isn't available.
  641. # error "::std::string isn't available."
  642. #endif // !defined(GTEST_HAS_STD_STRING)
  643. #ifndef GTEST_HAS_GLOBAL_STRING
  644. # define GTEST_HAS_GLOBAL_STRING 0
  645. #endif // GTEST_HAS_GLOBAL_STRING
  646. #ifndef GTEST_HAS_STD_WSTRING
  647. // The user didn't tell us whether ::std::wstring is available, so we need
  648. // to figure it out.
  649. // Cygwin 1.7 and below doesn't support ::std::wstring.
  650. // Solaris' libc++ doesn't support it either. Android has
  651. // no support for it at least as recent as Froyo (2.2).
  652. # define GTEST_HAS_STD_WSTRING \
  653. (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
  654. #endif // GTEST_HAS_STD_WSTRING
  655. #ifndef GTEST_HAS_GLOBAL_WSTRING
  656. // The user didn't tell us whether ::wstring is available, so we need
  657. // to figure it out.
  658. # define GTEST_HAS_GLOBAL_WSTRING \
  659. (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
  660. #endif // GTEST_HAS_GLOBAL_WSTRING
  661. // Determines whether RTTI is available.
  662. #ifndef GTEST_HAS_RTTI
  663. // The user didn't tell us whether RTTI is enabled, so we need to
  664. // figure it out.
  665. # ifdef _MSC_VER
  666. # ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled.
  667. # define GTEST_HAS_RTTI 1
  668. # else
  669. # define GTEST_HAS_RTTI 0
  670. # endif
  671. // Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
  672. # elif defined(__GNUC__)
  673. # ifdef __GXX_RTTI
  674. // When building against STLport with the Android NDK and with
  675. // -frtti -fno-exceptions, the build fails at link time with undefined
  676. // references to __cxa_bad_typeid. Note sure if STL or toolchain bug,
  677. // so disable RTTI when detected.
  678. # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
  679. !defined(__EXCEPTIONS)
  680. # define GTEST_HAS_RTTI 0
  681. # else
  682. # define GTEST_HAS_RTTI 1
  683. # endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
  684. # else
  685. # define GTEST_HAS_RTTI 0
  686. # endif // __GXX_RTTI
  687. // Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends
  688. // using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the
  689. // first version with C++ support.
  690. # elif defined(__clang__)
  691. # define GTEST_HAS_RTTI __has_feature(cxx_rtti)
  692. // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
  693. // both the typeid and dynamic_cast features are present.
  694. # elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
  695. # ifdef __RTTI_ALL__
  696. # define GTEST_HAS_RTTI 1
  697. # else
  698. # define GTEST_HAS_RTTI 0
  699. # endif
  700. # else
  701. // For all other compilers, we assume RTTI is enabled.
  702. # define GTEST_HAS_RTTI 1
  703. # endif // _MSC_VER
  704. #endif // GTEST_HAS_RTTI
  705. // It's this header's responsibility to #include <typeinfo> when RTTI
  706. // is enabled.
  707. #if GTEST_HAS_RTTI
  708. # include <typeinfo>
  709. #endif
  710. // Determines whether Google Test can use the pthreads library.
  711. #ifndef GTEST_HAS_PTHREAD
  712. // The user didn't tell us explicitly, so we make reasonable assumptions about
  713. // which platforms have pthreads support.
  714. //
  715. // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
  716. // to your compiler flags.
  717. #define GTEST_HAS_PTHREAD \
  718. (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
  719. GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
  720. #endif // GTEST_HAS_PTHREAD
  721. #if GTEST_HAS_PTHREAD
  722. // gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
  723. // true.
  724. # include <pthread.h> // NOLINT
  725. // For timespec and nanosleep, used below.
  726. # include <time.h> // NOLINT
  727. #endif
  728. // Determines whether clone(2) is supported.
  729. // Usually it will only be available on Linux, excluding
  730. // Linux on the Itanium architecture.
  731. // Also see http://linux.die.net/man/2/clone.
  732. #ifndef GTEST_HAS_CLONE
  733. // The user didn't tell us, so we need to figure it out.
  734. # if GTEST_OS_LINUX && !defined(__ia64__)
  735. # if GTEST_OS_LINUX_ANDROID
  736. // On Android, clone() became available at different API levels for each 32-bit
  737. // architecture.
  738. # if defined(__LP64__) || \
  739. (defined(__arm__) && __ANDROID_API__ >= 9) || \
  740. (defined(__mips__) && __ANDROID_API__ >= 12) || \
  741. (defined(__i386__) && __ANDROID_API__ >= 17)
  742. # define GTEST_HAS_CLONE 1
  743. # else
  744. # define GTEST_HAS_CLONE 0
  745. # endif
  746. # else
  747. # define GTEST_HAS_CLONE 1
  748. # endif
  749. # else
  750. # define GTEST_HAS_CLONE 0
  751. # endif // GTEST_OS_LINUX && !defined(__ia64__)
  752. #endif // GTEST_HAS_CLONE
  753. // Determines whether to support stream redirection. This is used to test
  754. // output correctness and to implement death tests.
  755. #ifndef GTEST_HAS_STREAM_REDIRECTION
  756. // By default, we assume that stream redirection is supported on all
  757. // platforms except known mobile ones.
  758. # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
  759. # define GTEST_HAS_STREAM_REDIRECTION 0
  760. # else
  761. # define GTEST_HAS_STREAM_REDIRECTION 1
  762. # endif // !GTEST_OS_WINDOWS_MOBILE
  763. #endif // GTEST_HAS_STREAM_REDIRECTION
  764. // Determines whether to support death tests.
  765. // pops up a dialog window that cannot be suppressed programmatically.
  766. #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
  767. (GTEST_OS_MAC && !GTEST_OS_IOS) || \
  768. (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || \
  769. GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
  770. GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \
  771. GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
  772. # define GTEST_HAS_DEATH_TEST 1
  773. #endif
  774. // Determines whether to support type-driven tests.
  775. // Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
  776. // Sun Pro CC, IBM Visual Age, and HP aCC support.
  777. #if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
  778. defined(__IBMCPP__) || defined(__HP_aCC)
  779. # define GTEST_HAS_TYPED_TEST 1
  780. # define GTEST_HAS_TYPED_TEST_P 1
  781. #endif
  782. // Determines whether the system compiler uses UTF-16 for encoding wide strings.
  783. #define GTEST_WIDE_STRING_USES_UTF16_ \
  784. (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
  785. // Determines whether test results can be streamed to a socket.
  786. #if GTEST_OS_LINUX
  787. # define GTEST_CAN_STREAM_RESULTS_ 1
  788. #endif
  789. // Defines some utility macros.
  790. // The GNU compiler emits a warning if nested "if" statements are followed by
  791. // an "else" statement and braces are not used to explicitly disambiguate the
  792. // "else" binding. This leads to problems with code like:
  793. //
  794. // if (gate)
  795. // ASSERT_*(condition) << "Some message";
  796. //
  797. // The "switch (0) case 0:" idiom is used to suppress this.
  798. #ifdef __INTEL_COMPILER
  799. # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
  800. #else
  801. # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT
  802. #endif
  803. // Use this annotation at the end of a struct/class definition to
  804. // prevent the compiler from optimizing away instances that are never
  805. // used. This is useful when all interesting logic happens inside the
  806. // c'tor and / or d'tor. Example:
  807. //
  808. // struct Foo {
  809. // Foo() { ... }
  810. // } GTEST_ATTRIBUTE_UNUSED_;
  811. //
  812. // Also use it after a variable or parameter declaration to tell the
  813. // compiler the variable/parameter does not have to be used.
  814. #if defined(__GNUC__) && !defined(COMPILER_ICC)
  815. # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
  816. #elif defined(__clang__)
  817. # if __has_attribute(unused)
  818. # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
  819. # endif
  820. #endif
  821. #ifndef GTEST_ATTRIBUTE_UNUSED_
  822. # define GTEST_ATTRIBUTE_UNUSED_
  823. #endif
  824. // Use this annotation before a function that takes a printf format string.
  825. #if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)
  826. # if defined(__MINGW_PRINTF_FORMAT)
  827. // MinGW has two different printf implementations. Ensure the format macro
  828. // matches the selected implementation. See
  829. // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
  830. # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
  831. __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \
  832. first_to_check)))
  833. # else
  834. # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
  835. __attribute__((__format__(__printf__, string_index, first_to_check)))
  836. # endif
  837. #else
  838. # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
  839. #endif
  840. // A macro to disallow operator=
  841. // This should be used in the private: declarations for a class.
  842. #define GTEST_DISALLOW_ASSIGN_(type) \
  843. void operator=(type const &) = delete
  844. // A macro to disallow copy constructor and operator=
  845. // This should be used in the private: declarations for a class.
  846. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
  847. type(type const &) = delete; \
  848. GTEST_DISALLOW_ASSIGN_(type)
  849. // Tell the compiler to warn about unused return values for functions declared
  850. // with this macro. The macro should be used on function declarations
  851. // following the argument list:
  852. //
  853. // Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
  854. #if defined(__GNUC__) && !defined(COMPILER_ICC)
  855. # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
  856. #else
  857. # define GTEST_MUST_USE_RESULT_
  858. #endif // __GNUC__ && !COMPILER_ICC
  859. // MS C++ compiler emits warning when a conditional expression is compile time
  860. // constant. In some contexts this warning is false positive and needs to be
  861. // suppressed. Use the following two macros in such cases:
  862. //
  863. // GTEST_INTENTIONAL_CONST_COND_PUSH_()
  864. // while (true) {
  865. // GTEST_INTENTIONAL_CONST_COND_POP_()
  866. // }
  867. # define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
  868. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
  869. # define GTEST_INTENTIONAL_CONST_COND_POP_() \
  870. GTEST_DISABLE_MSC_WARNINGS_POP_()
  871. // Determine whether the compiler supports Microsoft's Structured Exception
  872. // Handling. This is supported by several Windows compilers but generally
  873. // does not exist on any other system.
  874. #ifndef GTEST_HAS_SEH
  875. // The user didn't tell us, so we need to figure it out.
  876. # if defined(_MSC_VER) || defined(__BORLANDC__)
  877. // These two compilers are known to support SEH.
  878. # define GTEST_HAS_SEH 1
  879. # else
  880. // Assume no SEH.
  881. # define GTEST_HAS_SEH 0
  882. # endif
  883. #endif // GTEST_HAS_SEH
  884. #ifndef GTEST_IS_THREADSAFE
  885. #define GTEST_IS_THREADSAFE \
  886. (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \
  887. (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \
  888. GTEST_HAS_PTHREAD)
  889. #endif // GTEST_IS_THREADSAFE
  890. // GTEST_API_ qualifies all symbols that must be exported. The definitions below
  891. // are guarded by #ifndef to give embedders a chance to define GTEST_API_ in
  892. // gtest/internal/custom/gtest-port.h
  893. #ifndef GTEST_API_
  894. #ifdef _MSC_VER
  895. # if GTEST_LINKED_AS_SHARED_LIBRARY
  896. # define GTEST_API_ __declspec(dllimport)
  897. # elif GTEST_CREATE_SHARED_LIBRARY
  898. # define GTEST_API_ __declspec(dllexport)
  899. # endif
  900. #elif __GNUC__ >= 4 || defined(__clang__)
  901. # define GTEST_API_ __attribute__((visibility ("default")))
  902. #endif // _MSC_VER
  903. #endif // GTEST_API_
  904. #ifndef GTEST_API_
  905. # define GTEST_API_
  906. #endif // GTEST_API_
  907. #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
  908. # define GTEST_DEFAULT_DEATH_TEST_STYLE "fast"
  909. #endif // GTEST_DEFAULT_DEATH_TEST_STYLE
  910. #ifdef __GNUC__
  911. // Ask the compiler to never inline a given function.
  912. # define GTEST_NO_INLINE_ __attribute__((noinline))
  913. #else
  914. # define GTEST_NO_INLINE_
  915. #endif
  916. // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.
  917. #if !defined(GTEST_HAS_CXXABI_H_)
  918. # if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
  919. # define GTEST_HAS_CXXABI_H_ 1
  920. # else
  921. # define GTEST_HAS_CXXABI_H_ 0
  922. # endif
  923. #endif
  924. // A function level attribute to disable checking for use of uninitialized
  925. // memory when built with MemorySanitizer.
  926. #if defined(__clang__)
  927. # if __has_feature(memory_sanitizer)
  928. # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
  929. __attribute__((no_sanitize_memory))
  930. # else
  931. # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
  932. # endif // __has_feature(memory_sanitizer)
  933. #else
  934. # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
  935. #endif // __clang__
  936. // A function level attribute to disable AddressSanitizer instrumentation.
  937. #if defined(__clang__)
  938. # if __has_feature(address_sanitizer)
  939. # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
  940. __attribute__((no_sanitize_address))
  941. # else
  942. # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
  943. # endif // __has_feature(address_sanitizer)
  944. #else
  945. # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
  946. #endif // __clang__
  947. // A function level attribute to disable ThreadSanitizer instrumentation.
  948. #if defined(__clang__)
  949. # if __has_feature(thread_sanitizer)
  950. # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \
  951. __attribute__((no_sanitize_thread))
  952. # else
  953. # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
  954. # endif // __has_feature(thread_sanitizer)
  955. #else
  956. # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
  957. #endif // __clang__
  958. namespace testing {
  959. class Message;
  960. // Legacy imports for backwards compatibility.
  961. // New code should use std:: names directly.
  962. using std::get;
  963. using std::make_tuple;
  964. using std::tuple;
  965. using std::tuple_element;
  966. using std::tuple_size;
  967. namespace internal {
  968. // A secret type that Google Test users don't know about. It has no
  969. // definition on purpose. Therefore it's impossible to create a
  970. // Secret object, which is what we want.
  971. class Secret;
  972. // The GTEST_COMPILE_ASSERT_ is a legacy macro used to verify that a compile
  973. // time expression is true (in new code, use static_assert instead). For
  974. // example, you could use it to verify the size of a static array:
  975. //
  976. // GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,
  977. // names_incorrect_size);
  978. //
  979. // The second argument to the macro must be a valid C++ identifier. If the
  980. // expression is false, compiler will issue an error containing this identifier.
  981. #define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
  982. // StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.
  983. //
  984. // This template is declared, but intentionally undefined.
  985. template <typename T1, typename T2>
  986. struct StaticAssertTypeEqHelper;
  987. template <typename T>
  988. struct StaticAssertTypeEqHelper<T, T> {
  989. enum { value = true };
  990. };
  991. // Same as std::is_same<>.
  992. template <typename T, typename U>
  993. struct IsSame {
  994. enum { value = false };
  995. };
  996. template <typename T>
  997. struct IsSame<T, T> {
  998. enum { value = true };
  999. };
  1000. // Evaluates to the number of elements in 'array'.
  1001. #define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
  1002. #if GTEST_HAS_GLOBAL_STRING
  1003. typedef ::string string;
  1004. #else
  1005. typedef ::std::string string;
  1006. #endif // GTEST_HAS_GLOBAL_STRING
  1007. #if GTEST_HAS_GLOBAL_WSTRING
  1008. typedef ::wstring wstring;
  1009. #elif GTEST_HAS_STD_WSTRING
  1010. typedef ::std::wstring wstring;
  1011. #endif // GTEST_HAS_GLOBAL_WSTRING
  1012. // A helper for suppressing warnings on constant condition. It just
  1013. // returns 'condition'.
  1014. GTEST_API_ bool IsTrue(bool condition);
  1015. // Defines RE.
  1016. #if GTEST_USES_PCRE
  1017. // if used, PCRE is injected by custom/gtest-port.h
  1018. #elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
  1019. // A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
  1020. // Regular Expression syntax.
  1021. class GTEST_API_ RE {
  1022. public:
  1023. // A copy constructor is required by the Standard to initialize object
  1024. // references from r-values.
  1025. RE(const RE& other) { Init(other.pattern()); }
  1026. // Constructs an RE from a string.
  1027. RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
  1028. # if GTEST_HAS_GLOBAL_STRING
  1029. RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
  1030. # endif // GTEST_HAS_GLOBAL_STRING
  1031. RE(const char* regex) { Init(regex); } // NOLINT
  1032. ~RE();
  1033. // Returns the string representation of the regex.
  1034. const char* pattern() const { return pattern_; }
  1035. // FullMatch(str, re) returns true iff regular expression re matches
  1036. // the entire str.
  1037. // PartialMatch(str, re) returns true iff regular expression re
  1038. // matches a substring of str (including str itself).
  1039. static bool FullMatch(const ::std::string& str, const RE& re) {
  1040. return FullMatch(str.c_str(), re);
  1041. }
  1042. static bool PartialMatch(const ::std::string& str, const RE& re) {
  1043. return PartialMatch(str.c_str(), re);
  1044. }
  1045. # if GTEST_HAS_GLOBAL_STRING
  1046. static bool FullMatch(const ::string& str, const RE& re) {
  1047. return FullMatch(str.c_str(), re);
  1048. }
  1049. static bool PartialMatch(const ::string& str, const RE& re) {
  1050. return PartialMatch(str.c_str(), re);
  1051. }
  1052. # endif // GTEST_HAS_GLOBAL_STRING
  1053. static bool FullMatch(const char* str, const RE& re);
  1054. static bool PartialMatch(const char* str, const RE& re);
  1055. private:
  1056. void Init(const char* regex);
  1057. const char* pattern_;
  1058. bool is_valid_;
  1059. # if GTEST_USES_POSIX_RE
  1060. regex_t full_regex_; // For FullMatch().
  1061. regex_t partial_regex_; // For PartialMatch().
  1062. # else // GTEST_USES_SIMPLE_RE
  1063. const char* full_pattern_; // For FullMatch();
  1064. # endif
  1065. GTEST_DISALLOW_ASSIGN_(RE);
  1066. };
  1067. #endif // GTEST_USES_PCRE
  1068. // Formats a source file path and a line number as they would appear
  1069. // in an error message from the compiler used to compile this code.
  1070. GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
  1071. // Formats a file location for compiler-independent XML output.
  1072. // Although this function is not platform dependent, we put it next to
  1073. // FormatFileLocation in order to contrast the two functions.
  1074. GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
  1075. int line);
  1076. // Defines logging utilities:
  1077. // GTEST_LOG_(severity) - logs messages at the specified severity level. The
  1078. // message itself is streamed into the macro.
  1079. // LogToStderr() - directs all log messages to stderr.
  1080. // FlushInfoLog() - flushes informational log messages.
  1081. enum GTestLogSeverity {
  1082. GTEST_INFO,
  1083. GTEST_WARNING,
  1084. GTEST_ERROR,
  1085. GTEST_FATAL
  1086. };
  1087. // Formats log entry severity, provides a stream object for streaming the
  1088. // log message, and terminates the message with a newline when going out of
  1089. // scope.
  1090. class GTEST_API_ GTestLog {
  1091. public:
  1092. GTestLog(GTestLogSeverity severity, const char* file, int line);
  1093. // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
  1094. ~GTestLog();
  1095. ::std::ostream& GetStream() { return ::std::cerr; }
  1096. private:
  1097. const GTestLogSeverity severity_;
  1098. GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
  1099. };
  1100. #if !defined(GTEST_LOG_)
  1101. # define GTEST_LOG_(severity) \
  1102. ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
  1103. __FILE__, __LINE__).GetStream()
  1104. inline void LogToStderr() {}
  1105. inline void FlushInfoLog() { fflush(nullptr); }
  1106. #endif // !defined(GTEST_LOG_)
  1107. #if !defined(GTEST_CHECK_)
  1108. // INTERNAL IMPLEMENTATION - DO NOT USE.
  1109. //
  1110. // GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
  1111. // is not satisfied.
  1112. // Synopsys:
  1113. // GTEST_CHECK_(boolean_condition);
  1114. // or
  1115. // GTEST_CHECK_(boolean_condition) << "Additional message";
  1116. //
  1117. // This checks the condition and if the condition is not satisfied
  1118. // it prints message about the condition violation, including the
  1119. // condition itself, plus additional message streamed into it, if any,
  1120. // and then it aborts the program. It aborts the program irrespective of
  1121. // whether it is built in the debug mode or not.
  1122. # define GTEST_CHECK_(condition) \
  1123. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  1124. if (::testing::internal::IsTrue(condition)) \
  1125. ; \
  1126. else \
  1127. GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
  1128. #endif // !defined(GTEST_CHECK_)
  1129. // An all-mode assert to verify that the given POSIX-style function
  1130. // call returns 0 (indicating success). Known limitation: this
  1131. // doesn't expand to a balanced 'if' statement, so enclose the macro
  1132. // in {} if you need to use it as the only statement in an 'if'
  1133. // branch.
  1134. #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
  1135. if (const int gtest_error = (posix_call)) \
  1136. GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
  1137. << gtest_error
  1138. // Adds reference to a type if it is not a reference type,
  1139. // otherwise leaves it unchanged. This is the same as
  1140. // tr1::add_reference, which is not widely available yet.
  1141. template <typename T>
  1142. struct AddReference { typedef T& type; }; // NOLINT
  1143. template <typename T>
  1144. struct AddReference<T&> { typedef T& type; }; // NOLINT
  1145. // A handy wrapper around AddReference that works when the argument T
  1146. // depends on template parameters.
  1147. #define GTEST_ADD_REFERENCE_(T) \
  1148. typename ::testing::internal::AddReference<T>::type
  1149. // Transforms "T" into "const T&" according to standard reference collapsing
  1150. // rules (this is only needed as a backport for C++98 compilers that do not
  1151. // support reference collapsing). Specifically, it transforms:
  1152. //
  1153. // char ==> const char&
  1154. // const char ==> const char&
  1155. // char& ==> char&
  1156. // const char& ==> const char&
  1157. //
  1158. // Note that the non-const reference will not have "const" added. This is
  1159. // standard, and necessary so that "T" can always bind to "const T&".
  1160. template <typename T>
  1161. struct ConstRef { typedef const T& type; };
  1162. template <typename T>
  1163. struct ConstRef<T&> { typedef T& type; };
  1164. // The argument T must depend on some template parameters.
  1165. #define GTEST_REFERENCE_TO_CONST_(T) \
  1166. typename ::testing::internal::ConstRef<T>::type
  1167. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  1168. //
  1169. // Use ImplicitCast_ as a safe version of static_cast for upcasting in
  1170. // the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
  1171. // const Foo*). When you use ImplicitCast_, the compiler checks that
  1172. // the cast is safe. Such explicit ImplicitCast_s are necessary in
  1173. // surprisingly many situations where C++ demands an exact type match
  1174. // instead of an argument type convertable to a target type.
  1175. //
  1176. // The syntax for using ImplicitCast_ is the same as for static_cast:
  1177. //
  1178. // ImplicitCast_<ToType>(expr)
  1179. //
  1180. // ImplicitCast_ would have been part of the C++ standard library,
  1181. // but the proposal was submitted too late. It will probably make
  1182. // its way into the language in the future.
  1183. //
  1184. // This relatively ugly name is intentional. It prevents clashes with
  1185. // similar functions users may have (e.g., implicit_cast). The internal
  1186. // namespace alone is not enough because the function can be found by ADL.
  1187. template<typename To>
  1188. inline To ImplicitCast_(To x) { return x; }
  1189. // When you upcast (that is, cast a pointer from type Foo to type
  1190. // SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
  1191. // always succeed. When you downcast (that is, cast a pointer from
  1192. // type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
  1193. // how do you know the pointer is really of type SubclassOfFoo? It
  1194. // could be a bare Foo, or of type DifferentSubclassOfFoo. Thus,
  1195. // when you downcast, you should use this macro. In debug mode, we
  1196. // use dynamic_cast<> to double-check the downcast is legal (we die
  1197. // if it's not). In normal mode, we do the efficient static_cast<>
  1198. // instead. Thus, it's important to test in debug mode to make sure
  1199. // the cast is legal!
  1200. // This is the only place in the code we should use dynamic_cast<>.
  1201. // In particular, you SHOULDN'T be using dynamic_cast<> in order to
  1202. // do RTTI (eg code like this:
  1203. // if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
  1204. // if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
  1205. // You should design the code some other way not to need this.
  1206. //
  1207. // This relatively ugly name is intentional. It prevents clashes with
  1208. // similar functions users may have (e.g., down_cast). The internal
  1209. // namespace alone is not enough because the function can be found by ADL.
  1210. template<typename To, typename From> // use like this: DownCast_<T*>(foo);
  1211. inline To DownCast_(From* f) { // so we only accept pointers
  1212. // Ensures that To is a sub-type of From *. This test is here only
  1213. // for compile-time type checking, and has no overhead in an
  1214. // optimized build at run-time, as it will be optimized away
  1215. // completely.
  1216. GTEST_INTENTIONAL_CONST_COND_PUSH_()
  1217. if (false) {
  1218. GTEST_INTENTIONAL_CONST_COND_POP_()
  1219. const To to = nullptr;
  1220. ::testing::internal::ImplicitCast_<From*>(to);
  1221. }
  1222. #if GTEST_HAS_RTTI
  1223. // RTTI: debug mode only!
  1224. GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);
  1225. #endif
  1226. return static_cast<To>(f);
  1227. }
  1228. // Downcasts the pointer of type Base to Derived.
  1229. // Derived must be a subclass of Base. The parameter MUST
  1230. // point to a class of type Derived, not any subclass of it.
  1231. // When RTTI is available, the function performs a runtime
  1232. // check to enforce this.
  1233. template <class Derived, class Base>
  1234. Derived* CheckedDowncastToActualType(Base* base) {
  1235. #if GTEST_HAS_RTTI
  1236. GTEST_CHECK_(typeid(*base) == typeid(Derived));
  1237. #endif
  1238. #if GTEST_HAS_DOWNCAST_
  1239. return ::down_cast<Derived*>(base);
  1240. #elif GTEST_HAS_RTTI
  1241. return dynamic_cast<Derived*>(base); // NOLINT
  1242. #else
  1243. return static_cast<Derived*>(base); // Poor man's downcast.
  1244. #endif
  1245. }
  1246. #if GTEST_HAS_STREAM_REDIRECTION
  1247. // Defines the stderr capturer:
  1248. // CaptureStdout - starts capturing stdout.
  1249. // GetCapturedStdout - stops capturing stdout and returns the captured string.
  1250. // CaptureStderr - starts capturing stderr.
  1251. // GetCapturedStderr - stops capturing stderr and returns the captured string.
  1252. //
  1253. GTEST_API_ void CaptureStdout();
  1254. GTEST_API_ std::string GetCapturedStdout();
  1255. GTEST_API_ void CaptureStderr();
  1256. GTEST_API_ std::string GetCapturedStderr();
  1257. #endif // GTEST_HAS_STREAM_REDIRECTION
  1258. // Returns the size (in bytes) of a file.
  1259. GTEST_API_ size_t GetFileSize(FILE* file);
  1260. // Reads the entire content of a file as a string.
  1261. GTEST_API_ std::string ReadEntireFile(FILE* file);
  1262. // All command line arguments.
  1263. GTEST_API_ std::vector<std::string> GetArgvs();
  1264. #if GTEST_HAS_DEATH_TEST
  1265. std::vector<std::string> GetInjectableArgvs();
  1266. // Deprecated: pass the args vector by value instead.
  1267. void SetInjectableArgvs(const std::vector<std::string>* new_argvs);
  1268. void SetInjectableArgvs(const std::vector<std::string>& new_argvs);
  1269. #if GTEST_HAS_GLOBAL_STRING
  1270. void SetInjectableArgvs(const std::vector< ::string>& new_argvs);
  1271. #endif // GTEST_HAS_GLOBAL_STRING
  1272. void ClearInjectableArgvs();
  1273. #endif // GTEST_HAS_DEATH_TEST
  1274. // Defines synchronization primitives.
  1275. #if GTEST_IS_THREADSAFE
  1276. # if GTEST_HAS_PTHREAD
  1277. // Sleeps for (roughly) n milliseconds. This function is only for testing
  1278. // Google Test's own constructs. Don't use it in user tests, either
  1279. // directly or indirectly.
  1280. inline void SleepMilliseconds(int n) {
  1281. const timespec time = {
  1282. 0, // 0 seconds.
  1283. n * 1000L * 1000L, // And n ms.
  1284. };
  1285. nanosleep(&time, nullptr);
  1286. }
  1287. # endif // GTEST_HAS_PTHREAD
  1288. # if GTEST_HAS_NOTIFICATION_
  1289. // Notification has already been imported into the namespace.
  1290. // Nothing to do here.
  1291. # elif GTEST_HAS_PTHREAD
  1292. // Allows a controller thread to pause execution of newly created
  1293. // threads until notified. Instances of this class must be created
  1294. // and destroyed in the controller thread.
  1295. //
  1296. // This class is only for testing Google Test's own constructs. Do not
  1297. // use it in user tests, either directly or indirectly.
  1298. class Notification {
  1299. public:
  1300. Notification() : notified_(false) {
  1301. GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
  1302. }
  1303. ~Notification() {
  1304. pthread_mutex_destroy(&mutex_);
  1305. }
  1306. // Notifies all threads created with this notification to start. Must
  1307. // be called from the controller thread.
  1308. void Notify() {
  1309. pthread_mutex_lock(&mutex_);
  1310. notified_ = true;
  1311. pthread_mutex_unlock(&mutex_);
  1312. }
  1313. // Blocks until the controller thread notifies. Must be called from a test
  1314. // thread.
  1315. void WaitForNotification() {
  1316. for (;;) {
  1317. pthread_mutex_lock(&mutex_);
  1318. const bool notified = notified_;
  1319. pthread_mutex_unlock(&mutex_);
  1320. if (notified)
  1321. break;
  1322. SleepMilliseconds(10);
  1323. }
  1324. }
  1325. private:
  1326. pthread_mutex_t mutex_;
  1327. bool notified_;
  1328. GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
  1329. };
  1330. # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
  1331. GTEST_API_ void SleepMilliseconds(int n);
  1332. // Provides leak-safe Windows kernel handle ownership.
  1333. // Used in death tests and in threading support.
  1334. class GTEST_API_ AutoHandle {
  1335. public:
  1336. // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to
  1337. // avoid including <windows.h> in this header file. Including <windows.h> is
  1338. // undesirable because it defines a lot of symbols and macros that tend to
  1339. // conflict with client code. This assumption is verified by
  1340. // WindowsTypesTest.HANDLEIsVoidStar.
  1341. typedef void* Handle;
  1342. AutoHandle();
  1343. explicit AutoHandle(Handle handle);
  1344. ~AutoHandle();
  1345. Handle Get() const;
  1346. void Reset();
  1347. void Reset(Handle handle);
  1348. private:
  1349. // Returns true iff the handle is a valid handle object that can be closed.
  1350. bool IsCloseable() const;
  1351. Handle handle_;
  1352. GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
  1353. };
  1354. // Allows a controller thread to pause execution of newly created
  1355. // threads until notified. Instances of this class must be created
  1356. // and destroyed in the controller thread.
  1357. //
  1358. // This class is only for testing Google Test's own constructs. Do not
  1359. // use it in user tests, either directly or indirectly.
  1360. class GTEST_API_ Notification {
  1361. public:
  1362. Notification();
  1363. void Notify();
  1364. void WaitForNotification();
  1365. private:
  1366. AutoHandle event_;
  1367. GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
  1368. };
  1369. # endif // GTEST_HAS_NOTIFICATION_
  1370. // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD
  1371. // defined, but we don't want to use MinGW's pthreads implementation, which
  1372. // has conformance problems with some versions of the POSIX standard.
  1373. # if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW
  1374. // As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
  1375. // Consequently, it cannot select a correct instantiation of ThreadWithParam
  1376. // in order to call its Run(). Introducing ThreadWithParamBase as a
  1377. // non-templated base class for ThreadWithParam allows us to bypass this
  1378. // problem.
  1379. class ThreadWithParamBase {
  1380. public:
  1381. virtual ~ThreadWithParamBase() {}
  1382. virtual void Run() = 0;
  1383. };
  1384. // pthread_create() accepts a pointer to a function type with the C linkage.
  1385. // According to the Standard (7.5/1), function types with different linkages
  1386. // are different even if they are otherwise identical. Some compilers (for
  1387. // example, SunStudio) treat them as different types. Since class methods
  1388. // cannot be defined with C-linkage we need to define a free C-function to
  1389. // pass into pthread_create().
  1390. extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
  1391. static_cast<ThreadWithParamBase*>(thread)->Run();
  1392. return nullptr;
  1393. }
  1394. // Helper class for testing Google Test's multi-threading constructs.
  1395. // To use it, write:
  1396. //
  1397. // void ThreadFunc(int param) { /* Do things with param */ }
  1398. // Notification thread_can_start;
  1399. // ...
  1400. // // The thread_can_start parameter is optional; you can supply NULL.
  1401. // ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
  1402. // thread_can_start.Notify();
  1403. //
  1404. // These classes are only for testing Google Test's own constructs. Do
  1405. // not use them in user tests, either directly or indirectly.
  1406. template <typename T>
  1407. class ThreadWithParam : public ThreadWithParamBase {
  1408. public:
  1409. typedef void UserThreadFunc(T);
  1410. ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
  1411. : func_(func),
  1412. param_(param),
  1413. thread_can_start_(thread_can_start),
  1414. finished_(false) {
  1415. ThreadWithParamBase* const base = this;
  1416. // The thread can be created only after all fields except thread_
  1417. // have been initialized.
  1418. GTEST_CHECK_POSIX_SUCCESS_(
  1419. pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));
  1420. }
  1421. ~ThreadWithParam() override { Join(); }
  1422. void Join() {
  1423. if (!finished_) {
  1424. GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr));
  1425. finished_ = true;
  1426. }
  1427. }
  1428. void Run() override {
  1429. if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();
  1430. func_(param_);
  1431. }
  1432. private:
  1433. UserThreadFunc* const func_; // User-supplied thread function.
  1434. const T param_; // User-supplied parameter to the thread function.
  1435. // When non-NULL, used to block execution until the controller thread
  1436. // notifies.
  1437. Notification* const thread_can_start_;
  1438. bool finished_; // true iff we know that the thread function has finished.
  1439. pthread_t thread_; // The native thread object.
  1440. GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
  1441. };
  1442. # endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||
  1443. // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
  1444. # if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
  1445. // Mutex and ThreadLocal have already been imported into the namespace.
  1446. // Nothing to do here.
  1447. # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
  1448. // Mutex implements mutex on Windows platforms. It is used in conjunction
  1449. // with class MutexLock:
  1450. //
  1451. // Mutex mutex;
  1452. // ...
  1453. // MutexLock lock(&mutex); // Acquires the mutex and releases it at the
  1454. // // end of the current scope.
  1455. //
  1456. // A static Mutex *must* be defined or declared using one of the following
  1457. // macros:
  1458. // GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
  1459. // GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
  1460. //
  1461. // (A non-static Mutex is defined/declared in the usual way).
  1462. class GTEST_API_ Mutex {
  1463. public:
  1464. enum MutexType { kStatic = 0, kDynamic = 1 };
  1465. // We rely on kStaticMutex being 0 as it is to what the linker initializes
  1466. // type_ in static mutexes. critical_section_ will be initialized lazily
  1467. // in ThreadSafeLazyInit().
  1468. enum StaticConstructorSelector { kStaticMutex = 0 };
  1469. // This constructor intentionally does nothing. It relies on type_ being
  1470. // statically initialized to 0 (effectively setting it to kStatic) and on
  1471. // ThreadSafeLazyInit() to lazily initialize the rest of the members.
  1472. explicit Mutex(StaticConstructorSelector /*dummy*/) {}
  1473. Mutex();
  1474. ~Mutex();
  1475. void Lock();
  1476. void Unlock();
  1477. // Does nothing if the current thread holds the mutex. Otherwise, crashes
  1478. // with high probability.
  1479. void AssertHeld();
  1480. private:
  1481. // Initializes owner_thread_id_ and critical_section_ in static mutexes.
  1482. void ThreadSafeLazyInit();
  1483. // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503,
  1484. // we assume that 0 is an invalid value for thread IDs.
  1485. unsigned int owner_thread_id_;
  1486. // For static mutexes, we rely on these members being initialized to zeros
  1487. // by the linker.
  1488. MutexType type_;
  1489. long critical_section_init_phase_; // NOLINT
  1490. GTEST_CRITICAL_SECTION* critical_section_;
  1491. GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
  1492. };
  1493. # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
  1494. extern ::testing::internal::Mutex mutex
  1495. # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
  1496. ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
  1497. // We cannot name this class MutexLock because the ctor declaration would
  1498. // conflict with a macro named MutexLock, which is defined on some
  1499. // platforms. That macro is used as a defensive measure to prevent against
  1500. // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
  1501. // "MutexLock l(&mu)". Hence the typedef trick below.
  1502. class GTestMutexLock {
  1503. public:
  1504. explicit GTestMutexLock(Mutex* mutex)
  1505. : mutex_(mutex) { mutex_->Lock(); }
  1506. ~GTestMutexLock() { mutex_->Unlock(); }
  1507. private:
  1508. Mutex* const mutex_;
  1509. GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
  1510. };
  1511. typedef GTestMutexLock MutexLock;
  1512. // Base class for ValueHolder<T>. Allows a caller to hold and delete a value
  1513. // without knowing its type.
  1514. class ThreadLocalValueHolderBase {
  1515. public:
  1516. virtual ~ThreadLocalValueHolderBase() {}
  1517. };
  1518. // Provides a way for a thread to send notifications to a ThreadLocal
  1519. // regardless of its parameter type.
  1520. class ThreadLocalBase {
  1521. public:
  1522. // Creates a new ValueHolder<T> object holding a default value passed to
  1523. // this ThreadLocal<T>'s constructor and returns it. It is the caller's
  1524. // responsibility not to call this when the ThreadLocal<T> instance already
  1525. // has a value on the current thread.
  1526. virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;
  1527. protected:
  1528. ThreadLocalBase() {}
  1529. virtual ~ThreadLocalBase() {}
  1530. private:
  1531. GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);
  1532. };
  1533. // Maps a thread to a set of ThreadLocals that have values instantiated on that
  1534. // thread and notifies them when the thread exits. A ThreadLocal instance is
  1535. // expected to persist until all threads it has values on have terminated.
  1536. class GTEST_API_ ThreadLocalRegistry {
  1537. public:
  1538. // Registers thread_local_instance as having value on the current thread.
  1539. // Returns a value that can be used to identify the thread from other threads.
  1540. static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
  1541. const ThreadLocalBase* thread_local_instance);
  1542. // Invoked when a ThreadLocal instance is destroyed.
  1543. static void OnThreadLocalDestroyed(
  1544. const ThreadLocalBase* thread_local_instance);
  1545. };
  1546. class GTEST_API_ ThreadWithParamBase {
  1547. public:
  1548. void Join();
  1549. protected:
  1550. class Runnable {
  1551. public:
  1552. virtual ~Runnable() {}
  1553. virtual void Run() = 0;
  1554. };
  1555. ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);
  1556. virtual ~ThreadWithParamBase();
  1557. private:
  1558. AutoHandle thread_;
  1559. };
  1560. // Helper class for testing Google Test's multi-threading constructs.
  1561. template <typename T>
  1562. class ThreadWithParam : public ThreadWithParamBase {
  1563. public:
  1564. typedef void UserThreadFunc(T);
  1565. ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
  1566. : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {
  1567. }
  1568. virtual ~ThreadWithParam() {}
  1569. private:
  1570. class RunnableImpl : public Runnable {
  1571. public:
  1572. RunnableImpl(UserThreadFunc* func, T param)
  1573. : func_(func),
  1574. param_(param) {
  1575. }
  1576. virtual ~RunnableImpl() {}
  1577. virtual void Run() {
  1578. func_(param_);
  1579. }
  1580. private:
  1581. UserThreadFunc* const func_;
  1582. const T param_;
  1583. GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);
  1584. };
  1585. GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
  1586. };
  1587. // Implements thread-local storage on Windows systems.
  1588. //
  1589. // // Thread 1
  1590. // ThreadLocal<int> tl(100); // 100 is the default value for each thread.
  1591. //
  1592. // // Thread 2
  1593. // tl.set(150); // Changes the value for thread 2 only.
  1594. // EXPECT_EQ(150, tl.get());
  1595. //
  1596. // // Thread 1
  1597. // EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value.
  1598. // tl.set(200);
  1599. // EXPECT_EQ(200, tl.get());
  1600. //
  1601. // The template type argument T must have a public copy constructor.
  1602. // In addition, the default ThreadLocal constructor requires T to have
  1603. // a public default constructor.
  1604. //
  1605. // The users of a TheadLocal instance have to make sure that all but one
  1606. // threads (including the main one) using that instance have exited before
  1607. // destroying it. Otherwise, the per-thread objects managed for them by the
  1608. // ThreadLocal instance are not guaranteed to be destroyed on all platforms.
  1609. //
  1610. // Google Test only uses global ThreadLocal objects. That means they
  1611. // will die after main() has returned. Therefore, no per-thread
  1612. // object managed by Google Test will be leaked as long as all threads
  1613. // using Google Test have exited when main() returns.
  1614. template <typename T>
  1615. class ThreadLocal : public ThreadLocalBase {
  1616. public:
  1617. ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
  1618. explicit ThreadLocal(const T& value)
  1619. : default_factory_(new InstanceValueHolderFactory(value)) {}
  1620. ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }
  1621. T* pointer() { return GetOrCreateValue(); }
  1622. const T* pointer() const { return GetOrCreateValue(); }
  1623. const T& get() const { return *pointer(); }
  1624. void set(const T& value) { *pointer() = value; }
  1625. private:
  1626. // Holds a value of T. Can be deleted via its base class without the caller
  1627. // knowing the type of T.
  1628. class ValueHolder : public ThreadLocalValueHolderBase {
  1629. public:
  1630. ValueHolder() : value_() {}
  1631. explicit ValueHolder(const T& value) : value_(value) {}
  1632. T* pointer() { return &value_; }
  1633. private:
  1634. T value_;
  1635. GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
  1636. };
  1637. T* GetOrCreateValue() const {
  1638. return static_cast<ValueHolder*>(
  1639. ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();
  1640. }
  1641. virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {
  1642. return default_factory_->MakeNewHolder();
  1643. }
  1644. class ValueHolderFactory {
  1645. public:
  1646. ValueHolderFactory() {}
  1647. virtual ~ValueHolderFactory() {}
  1648. virtual ValueHolder* MakeNewHolder() const = 0;
  1649. private:
  1650. GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
  1651. };
  1652. class DefaultValueHolderFactory : public ValueHolderFactory {
  1653. public:
  1654. DefaultValueHolderFactory() {}
  1655. virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
  1656. private:
  1657. GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
  1658. };
  1659. class InstanceValueHolderFactory : public ValueHolderFactory {
  1660. public:
  1661. explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
  1662. virtual ValueHolder* MakeNewHolder() const {
  1663. return new ValueHolder(value_);
  1664. }
  1665. private:
  1666. const T value_; // The value for each thread.
  1667. GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
  1668. };
  1669. std::unique_ptr<ValueHolderFactory> default_factory_;
  1670. GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
  1671. };
  1672. # elif GTEST_HAS_PTHREAD
  1673. // MutexBase and Mutex implement mutex on pthreads-based platforms.
  1674. class MutexBase {
  1675. public:
  1676. // Acquires this mutex.
  1677. void Lock() {
  1678. GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
  1679. owner_ = pthread_self();
  1680. has_owner_ = true;
  1681. }
  1682. // Releases this mutex.
  1683. void Unlock() {
  1684. // Since the lock is being released the owner_ field should no longer be
  1685. // considered valid. We don't protect writing to has_owner_ here, as it's
  1686. // the caller's responsibility to ensure that the current thread holds the
  1687. // mutex when this is called.
  1688. has_owner_ = false;
  1689. GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
  1690. }
  1691. // Does nothing if the current thread holds the mutex. Otherwise, crashes
  1692. // with high probability.
  1693. void AssertHeld() const {
  1694. GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
  1695. << "The current thread is not holding the mutex @" << this;
  1696. }
  1697. // A static mutex may be used before main() is entered. It may even
  1698. // be used before the dynamic initialization stage. Therefore we
  1699. // must be able to initialize a static mutex object at link time.
  1700. // This means MutexBase has to be a POD and its member variables
  1701. // have to be public.
  1702. public:
  1703. pthread_mutex_t mutex_; // The underlying pthread mutex.
  1704. // has_owner_ indicates whether the owner_ field below contains a valid thread
  1705. // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All
  1706. // accesses to the owner_ field should be protected by a check of this field.
  1707. // An alternative might be to memset() owner_ to all zeros, but there's no
  1708. // guarantee that a zero'd pthread_t is necessarily invalid or even different
  1709. // from pthread_self().
  1710. bool has_owner_;
  1711. pthread_t owner_; // The thread holding the mutex.
  1712. };
  1713. // Forward-declares a static mutex.
  1714. # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
  1715. extern ::testing::internal::MutexBase mutex
  1716. // Defines and statically (i.e. at link time) initializes a static mutex.
  1717. // The initialization list here does not explicitly initialize each field,
  1718. // instead relying on default initialization for the unspecified fields. In
  1719. // particular, the owner_ field (a pthread_t) is not explicitly initialized.
  1720. // This allows initialization to work whether pthread_t is a scalar or struct.
  1721. // The flag -Wmissing-field-initializers must not be specified for this to work.
  1722. #define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
  1723. ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
  1724. // The Mutex class can only be used for mutexes created at runtime. It
  1725. // shares its API with MutexBase otherwise.
  1726. class Mutex : public MutexBase {
  1727. public:
  1728. Mutex() {
  1729. GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
  1730. has_owner_ = false;
  1731. }
  1732. ~Mutex() {
  1733. GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
  1734. }
  1735. private:
  1736. GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
  1737. };
  1738. // We cannot name this class MutexLock because the ctor declaration would
  1739. // conflict with a macro named MutexLock, which is defined on some
  1740. // platforms. That macro is used as a defensive measure to prevent against
  1741. // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
  1742. // "MutexLock l(&mu)". Hence the typedef trick below.
  1743. class GTestMutexLock {
  1744. public:
  1745. explicit GTestMutexLock(MutexBase* mutex)
  1746. : mutex_(mutex) { mutex_->Lock(); }
  1747. ~GTestMutexLock() { mutex_->Unlock(); }
  1748. private:
  1749. MutexBase* const mutex_;
  1750. GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
  1751. };
  1752. typedef GTestMutexLock MutexLock;
  1753. // Helpers for ThreadLocal.
  1754. // pthread_key_create() requires DeleteThreadLocalValue() to have
  1755. // C-linkage. Therefore it cannot be templatized to access
  1756. // ThreadLocal<T>. Hence the need for class
  1757. // ThreadLocalValueHolderBase.
  1758. class ThreadLocalValueHolderBase {
  1759. public:
  1760. virtual ~ThreadLocalValueHolderBase() {}
  1761. };
  1762. // Called by pthread to delete thread-local data stored by
  1763. // pthread_setspecific().
  1764. extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
  1765. delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
  1766. }
  1767. // Implements thread-local storage on pthreads-based systems.
  1768. template <typename T>
  1769. class GTEST_API_ ThreadLocal {
  1770. public:
  1771. ThreadLocal()
  1772. : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
  1773. explicit ThreadLocal(const T& value)
  1774. : key_(CreateKey()),
  1775. default_factory_(new InstanceValueHolderFactory(value)) {}
  1776. ~ThreadLocal() {
  1777. // Destroys the managed object for the current thread, if any.
  1778. DeleteThreadLocalValue(pthread_getspecific(key_));
  1779. // Releases resources associated with the key. This will *not*
  1780. // delete managed objects for other threads.
  1781. GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
  1782. }
  1783. T* pointer() { return GetOrCreateValue(); }
  1784. const T* pointer() const { return GetOrCreateValue(); }
  1785. const T& get() const { return *pointer(); }
  1786. void set(const T& value) { *pointer() = value; }
  1787. private:
  1788. // Holds a value of type T.
  1789. class ValueHolder : public ThreadLocalValueHolderBase {
  1790. public:
  1791. ValueHolder() : value_() {}
  1792. explicit ValueHolder(const T& value) : value_(value) {}
  1793. T* pointer() { return &value_; }
  1794. private:
  1795. T value_;
  1796. GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
  1797. };
  1798. static pthread_key_t CreateKey() {
  1799. pthread_key_t key;
  1800. // When a thread exits, DeleteThreadLocalValue() will be called on
  1801. // the object managed for that thread.
  1802. GTEST_CHECK_POSIX_SUCCESS_(
  1803. pthread_key_create(&key, &DeleteThreadLocalValue));
  1804. return key;
  1805. }
  1806. T* GetOrCreateValue() const {
  1807. ThreadLocalValueHolderBase* const holder =
  1808. static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
  1809. if (holder != nullptr) {
  1810. return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
  1811. }
  1812. ValueHolder* const new_holder = default_factory_->MakeNewHolder();
  1813. ThreadLocalValueHolderBase* const holder_base = new_holder;
  1814. GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
  1815. return new_holder->pointer();
  1816. }
  1817. class ValueHolderFactory {
  1818. public:
  1819. ValueHolderFactory() {}
  1820. virtual ~ValueHolderFactory() {}
  1821. virtual ValueHolder* MakeNewHolder() const = 0;
  1822. private:
  1823. GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
  1824. };
  1825. class DefaultValueHolderFactory : public ValueHolderFactory {
  1826. public:
  1827. DefaultValueHolderFactory() {}
  1828. virtual ValueHolder* MakeNewHolder() const { return new ValueHolder(); }
  1829. private:
  1830. GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
  1831. };
  1832. class InstanceValueHolderFactory : public ValueHolderFactory {
  1833. public:
  1834. explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
  1835. virtual ValueHolder* MakeNewHolder() const {
  1836. return new ValueHolder(value_);
  1837. }
  1838. private:
  1839. const T value_; // The value for each thread.
  1840. GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
  1841. };
  1842. // A key pthreads uses for looking up per-thread values.
  1843. const pthread_key_t key_;
  1844. std::unique_ptr<ValueHolderFactory> default_factory_;
  1845. GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
  1846. };
  1847. # endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
  1848. #else // GTEST_IS_THREADSAFE
  1849. // A dummy implementation of synchronization primitives (mutex, lock,
  1850. // and thread-local variable). Necessary for compiling Google Test where
  1851. // mutex is not supported - using Google Test in multiple threads is not
  1852. // supported on such platforms.
  1853. class Mutex {
  1854. public:
  1855. Mutex() {}
  1856. void Lock() {}
  1857. void Unlock() {}
  1858. void AssertHeld() const {}
  1859. };
  1860. # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
  1861. extern ::testing::internal::Mutex mutex
  1862. # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
  1863. // We cannot name this class MutexLock because the ctor declaration would
  1864. // conflict with a macro named MutexLock, which is defined on some
  1865. // platforms. That macro is used as a defensive measure to prevent against
  1866. // inadvertent misuses of MutexLock like "MutexLock(&mu)" rather than
  1867. // "MutexLock l(&mu)". Hence the typedef trick below.
  1868. class GTestMutexLock {
  1869. public:
  1870. explicit GTestMutexLock(Mutex*) {} // NOLINT
  1871. };
  1872. typedef GTestMutexLock MutexLock;
  1873. template <typename T>
  1874. class GTEST_API_ ThreadLocal {
  1875. public:
  1876. ThreadLocal() : value_() {}
  1877. explicit ThreadLocal(const T& value) : value_(value) {}
  1878. T* pointer() { return &value_; }
  1879. const T* pointer() const { return &value_; }
  1880. const T& get() const { return value_; }
  1881. void set(const T& value) { value_ = value; }
  1882. private:
  1883. T value_;
  1884. };
  1885. #endif // GTEST_IS_THREADSAFE
  1886. // Returns the number of threads running in the process, or 0 to indicate that
  1887. // we cannot detect it.
  1888. GTEST_API_ size_t GetThreadCount();
  1889. template <bool bool_value>
  1890. struct bool_constant {
  1891. typedef bool_constant<bool_value> type;
  1892. static const bool value = bool_value;
  1893. };
  1894. template <bool bool_value> const bool bool_constant<bool_value>::value;
  1895. typedef bool_constant<false> false_type;
  1896. typedef bool_constant<true> true_type;
  1897. template <typename T, typename U>
  1898. struct is_same : public false_type {};
  1899. template <typename T>
  1900. struct is_same<T, T> : public true_type {};
  1901. template <typename Iterator>
  1902. struct IteratorTraits {
  1903. typedef typename Iterator::value_type value_type;
  1904. };
  1905. template <typename T>
  1906. struct IteratorTraits<T*> {
  1907. typedef T value_type;
  1908. };
  1909. template <typename T>
  1910. struct IteratorTraits<const T*> {
  1911. typedef T value_type;
  1912. };
  1913. #if GTEST_OS_WINDOWS
  1914. # define GTEST_PATH_SEP_ "\\"
  1915. # define GTEST_HAS_ALT_PATH_SEP_ 1
  1916. // The biggest signed integer type the compiler supports.
  1917. typedef __int64 BiggestInt;
  1918. #else
  1919. # define GTEST_PATH_SEP_ "/"
  1920. # define GTEST_HAS_ALT_PATH_SEP_ 0
  1921. typedef long long BiggestInt; // NOLINT
  1922. #endif // GTEST_OS_WINDOWS
  1923. // Utilities for char.
  1924. // isspace(int ch) and friends accept an unsigned char or EOF. char
  1925. // may be signed, depending on the compiler (or compiler flags).
  1926. // Therefore we need to cast a char to unsigned char before calling
  1927. // isspace(), etc.
  1928. inline bool IsAlpha(char ch) {
  1929. return isalpha(static_cast<unsigned char>(ch)) != 0;
  1930. }
  1931. inline bool IsAlNum(char ch) {
  1932. return isalnum(static_cast<unsigned char>(ch)) != 0;
  1933. }
  1934. inline bool IsDigit(char ch) {
  1935. return isdigit(static_cast<unsigned char>(ch)) != 0;
  1936. }
  1937. inline bool IsLower(char ch) {
  1938. return islower(static_cast<unsigned char>(ch)) != 0;
  1939. }
  1940. inline bool IsSpace(char ch) {
  1941. return isspace(static_cast<unsigned char>(ch)) != 0;
  1942. }
  1943. inline bool IsUpper(char ch) {
  1944. return isupper(static_cast<unsigned char>(ch)) != 0;
  1945. }
  1946. inline bool IsXDigit(char ch) {
  1947. return isxdigit(static_cast<unsigned char>(ch)) != 0;
  1948. }
  1949. inline bool IsXDigit(wchar_t ch) {
  1950. const unsigned char low_byte = static_cast<unsigned char>(ch);
  1951. return ch == low_byte && isxdigit(low_byte) != 0;
  1952. }
  1953. inline char ToLower(char ch) {
  1954. return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
  1955. }
  1956. inline char ToUpper(char ch) {
  1957. return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
  1958. }
  1959. inline std::string StripTrailingSpaces(std::string str) {
  1960. std::string::iterator it = str.end();
  1961. while (it != str.begin() && IsSpace(*--it))
  1962. it = str.erase(it);
  1963. return str;
  1964. }
  1965. // The testing::internal::posix namespace holds wrappers for common
  1966. // POSIX functions. These wrappers hide the differences between
  1967. // Windows/MSVC and POSIX systems. Since some compilers define these
  1968. // standard functions as macros, the wrapper cannot have the same name
  1969. // as the wrapped function.
  1970. namespace posix {
  1971. // Functions with a different name on Windows.
  1972. #if GTEST_OS_WINDOWS
  1973. typedef struct _stat StatStruct;
  1974. # ifdef __BORLANDC__
  1975. inline int IsATTY(int fd) { return isatty(fd); }
  1976. inline int StrCaseCmp(const char* s1, const char* s2) {
  1977. return stricmp(s1, s2);
  1978. }
  1979. inline char* StrDup(const char* src) { return strdup(src); }
  1980. # else // !__BORLANDC__
  1981. # if GTEST_OS_WINDOWS_MOBILE
  1982. inline int IsATTY(int /* fd */) { return 0; }
  1983. # else
  1984. inline int IsATTY(int fd) { return _isatty(fd); }
  1985. # endif // GTEST_OS_WINDOWS_MOBILE
  1986. inline int StrCaseCmp(const char* s1, const char* s2) {
  1987. return _stricmp(s1, s2);
  1988. }
  1989. inline char* StrDup(const char* src) { return _strdup(src); }
  1990. # endif // __BORLANDC__
  1991. # if GTEST_OS_WINDOWS_MOBILE
  1992. inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
  1993. // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
  1994. // time and thus not defined there.
  1995. # else
  1996. inline int FileNo(FILE* file) { return _fileno(file); }
  1997. inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
  1998. inline int RmDir(const char* dir) { return _rmdir(dir); }
  1999. inline bool IsDir(const StatStruct& st) {
  2000. return (_S_IFDIR & st.st_mode) != 0;
  2001. }
  2002. # endif // GTEST_OS_WINDOWS_MOBILE
  2003. #else
  2004. typedef struct stat StatStruct;
  2005. inline int FileNo(FILE* file) { return fileno(file); }
  2006. inline int IsATTY(int fd) { return isatty(fd); }
  2007. inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
  2008. inline int StrCaseCmp(const char* s1, const char* s2) {
  2009. return strcasecmp(s1, s2);
  2010. }
  2011. inline char* StrDup(const char* src) { return strdup(src); }
  2012. inline int RmDir(const char* dir) { return rmdir(dir); }
  2013. inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
  2014. #endif // GTEST_OS_WINDOWS
  2015. // Functions deprecated by MSVC 8.0.
  2016. GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
  2017. inline const char* StrNCpy(char* dest, const char* src, size_t n) {
  2018. return strncpy(dest, src, n);
  2019. }
  2020. // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
  2021. // StrError() aren't needed on Windows CE at this time and thus not
  2022. // defined there.
  2023. #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
  2024. inline int ChDir(const char* dir) { return chdir(dir); }
  2025. #endif
  2026. inline FILE* FOpen(const char* path, const char* mode) {
  2027. return fopen(path, mode);
  2028. }
  2029. #if !GTEST_OS_WINDOWS_MOBILE
  2030. inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
  2031. return freopen(path, mode, stream);
  2032. }
  2033. inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
  2034. #endif
  2035. inline int FClose(FILE* fp) { return fclose(fp); }
  2036. #if !GTEST_OS_WINDOWS_MOBILE
  2037. inline int Read(int fd, void* buf, unsigned int count) {
  2038. return static_cast<int>(read(fd, buf, count));
  2039. }
  2040. inline int Write(int fd, const void* buf, unsigned int count) {
  2041. return static_cast<int>(write(fd, buf, count));
  2042. }
  2043. inline int Close(int fd) { return close(fd); }
  2044. inline const char* StrError(int errnum) { return strerror(errnum); }
  2045. #endif
  2046. inline const char* GetEnv(const char* name) {
  2047. #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
  2048. // We are on Windows CE, which has no environment variables.
  2049. static_cast<void>(name); // To prevent 'unused argument' warning.
  2050. return nullptr;
  2051. #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
  2052. // Environment variables which we programmatically clear will be set to the
  2053. // empty string rather than unset (NULL). Handle that case.
  2054. const char* const env = getenv(name);
  2055. return (env != nullptr && env[0] != '\0') ? env : nullptr;
  2056. #else
  2057. return getenv(name);
  2058. #endif
  2059. }
  2060. GTEST_DISABLE_MSC_DEPRECATED_POP_()
  2061. #if GTEST_OS_WINDOWS_MOBILE
  2062. // Windows CE has no C library. The abort() function is used in
  2063. // several places in Google Test. This implementation provides a reasonable
  2064. // imitation of standard behaviour.
  2065. [[noreturn]] void Abort();
  2066. #else
  2067. [[noreturn]] inline void Abort() { abort(); }
  2068. #endif // GTEST_OS_WINDOWS_MOBILE
  2069. } // namespace posix
  2070. // MSVC "deprecates" snprintf and issues warnings wherever it is used. In
  2071. // order to avoid these warnings, we need to use _snprintf or _snprintf_s on
  2072. // MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate
  2073. // function in order to achieve that. We use macro definition here because
  2074. // snprintf is a variadic function.
  2075. #if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE
  2076. // MSVC 2005 and above support variadic macros.
  2077. # define GTEST_SNPRINTF_(buffer, size, format, ...) \
  2078. _snprintf_s(buffer, size, size, format, __VA_ARGS__)
  2079. #elif defined(_MSC_VER)
  2080. // Windows CE does not define _snprintf_s
  2081. # define GTEST_SNPRINTF_ _snprintf
  2082. #else
  2083. # define GTEST_SNPRINTF_ snprintf
  2084. #endif
  2085. // The maximum number a BiggestInt can represent. This definition
  2086. // works no matter BiggestInt is represented in one's complement or
  2087. // two's complement.
  2088. //
  2089. // We cannot rely on numeric_limits in STL, as __int64 and long long
  2090. // are not part of standard C++ and numeric_limits doesn't need to be
  2091. // defined for them.
  2092. const BiggestInt kMaxBiggestInt =
  2093. ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
  2094. // This template class serves as a compile-time function from size to
  2095. // type. It maps a size in bytes to a primitive type with that
  2096. // size. e.g.
  2097. //
  2098. // TypeWithSize<4>::UInt
  2099. //
  2100. // is typedef-ed to be unsigned int (unsigned integer made up of 4
  2101. // bytes).
  2102. //
  2103. // Such functionality should belong to STL, but I cannot find it
  2104. // there.
  2105. //
  2106. // Google Test uses this class in the implementation of floating-point
  2107. // comparison.
  2108. //
  2109. // For now it only handles UInt (unsigned int) as that's all Google Test
  2110. // needs. Other types can be easily added in the future if need
  2111. // arises.
  2112. template <size_t size>
  2113. class TypeWithSize {
  2114. public:
  2115. // This prevents the user from using TypeWithSize<N> with incorrect
  2116. // values of N.
  2117. typedef void UInt;
  2118. };
  2119. // The specialization for size 4.
  2120. template <>
  2121. class TypeWithSize<4> {
  2122. public:
  2123. // unsigned int has size 4 in both gcc and MSVC.
  2124. //
  2125. // As base/basictypes.h doesn't compile on Windows, we cannot use
  2126. // uint32, uint64, and etc here.
  2127. typedef int Int;
  2128. typedef unsigned int UInt;
  2129. };
  2130. // The specialization for size 8.
  2131. template <>
  2132. class TypeWithSize<8> {
  2133. public:
  2134. #if GTEST_OS_WINDOWS
  2135. typedef __int64 Int;
  2136. typedef unsigned __int64 UInt;
  2137. #else
  2138. typedef long long Int; // NOLINT
  2139. typedef unsigned long long UInt; // NOLINT
  2140. #endif // GTEST_OS_WINDOWS
  2141. };
  2142. // Integer types of known sizes.
  2143. typedef TypeWithSize<4>::Int Int32;
  2144. typedef TypeWithSize<4>::UInt UInt32;
  2145. typedef TypeWithSize<8>::Int Int64;
  2146. typedef TypeWithSize<8>::UInt UInt64;
  2147. typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
  2148. // Utilities for command line flags and environment variables.
  2149. // Macro for referencing flags.
  2150. #if !defined(GTEST_FLAG)
  2151. # define GTEST_FLAG(name) FLAGS_gtest_##name
  2152. #endif // !defined(GTEST_FLAG)
  2153. #if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
  2154. # define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
  2155. #endif // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
  2156. #if !defined(GTEST_DECLARE_bool_)
  2157. # define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
  2158. // Macros for declaring flags.
  2159. # define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
  2160. # define GTEST_DECLARE_int32_(name) \
  2161. GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
  2162. # define GTEST_DECLARE_string_(name) \
  2163. GTEST_API_ extern ::std::string GTEST_FLAG(name)
  2164. // Macros for defining flags.
  2165. # define GTEST_DEFINE_bool_(name, default_val, doc) \
  2166. GTEST_API_ bool GTEST_FLAG(name) = (default_val)
  2167. # define GTEST_DEFINE_int32_(name, default_val, doc) \
  2168. GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
  2169. # define GTEST_DEFINE_string_(name, default_val, doc) \
  2170. GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
  2171. #endif // !defined(GTEST_DECLARE_bool_)
  2172. // Thread annotations
  2173. #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
  2174. # define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
  2175. # define GTEST_LOCK_EXCLUDED_(locks)
  2176. #endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
  2177. // Parses 'str' for a 32-bit signed integer. If successful, writes the result
  2178. // to *value and returns true; otherwise leaves *value unchanged and returns
  2179. // false.
  2180. bool ParseInt32(const Message& src_text, const char* str, Int32* value);
  2181. // Parses a bool/Int32/string from the environment variable
  2182. // corresponding to the given Google Test flag.
  2183. bool BoolFromGTestEnv(const char* flag, bool default_val);
  2184. GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
  2185. std::string OutputFlagAlsoCheckEnvVar();
  2186. const char* StringFromGTestEnv(const char* flag, const char* default_val);
  2187. } // namespace internal
  2188. } // namespace testing
  2189. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
  2190. #if GTEST_OS_LINUX
  2191. # include <stdlib.h>
  2192. # include <sys/types.h>
  2193. # include <sys/wait.h>
  2194. # include <unistd.h>
  2195. #endif // GTEST_OS_LINUX
  2196. #if GTEST_HAS_EXCEPTIONS
  2197. # include <stdexcept>
  2198. #endif
  2199. #include <ctype.h>
  2200. #include <float.h>
  2201. #include <string.h>
  2202. #include <iomanip>
  2203. #include <limits>
  2204. #include <map>
  2205. #include <set>
  2206. #include <string>
  2207. #include <vector>
  2208. // Copyright 2005, Google Inc.
  2209. // All rights reserved.
  2210. //
  2211. // Redistribution and use in source and binary forms, with or without
  2212. // modification, are permitted provided that the following conditions are
  2213. // met:
  2214. //
  2215. // * Redistributions of source code must retain the above copyright
  2216. // notice, this list of conditions and the following disclaimer.
  2217. // * Redistributions in binary form must reproduce the above
  2218. // copyright notice, this list of conditions and the following disclaimer
  2219. // in the documentation and/or other materials provided with the
  2220. // distribution.
  2221. // * Neither the name of Google Inc. nor the names of its
  2222. // contributors may be used to endorse or promote products derived from
  2223. // this software without specific prior written permission.
  2224. //
  2225. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2226. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2227. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2228. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2229. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2230. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2231. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2232. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2233. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2234. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2235. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2236. //
  2237. // The Google C++ Testing and Mocking Framework (Google Test)
  2238. //
  2239. // This header file defines the Message class.
  2240. //
  2241. // IMPORTANT NOTE: Due to limitation of the C++ language, we have to
  2242. // leave some internal implementation details in this header file.
  2243. // They are clearly marked by comments like this:
  2244. //
  2245. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  2246. //
  2247. // Such code is NOT meant to be used by a user directly, and is subject
  2248. // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
  2249. // program!
  2250. // GOOGLETEST_CM0001 DO NOT DELETE
  2251. #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
  2252. #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
  2253. #include <limits>
  2254. #include <memory>
  2255. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  2256. /* class A needs to have dll-interface to be used by clients of class B */)
  2257. // Ensures that there is at least one operator<< in the global namespace.
  2258. // See Message& operator<<(...) below for why.
  2259. void operator<<(const testing::internal::Secret&, int);
  2260. namespace testing {
  2261. // The Message class works like an ostream repeater.
  2262. //
  2263. // Typical usage:
  2264. //
  2265. // 1. You stream a bunch of values to a Message object.
  2266. // It will remember the text in a stringstream.
  2267. // 2. Then you stream the Message object to an ostream.
  2268. // This causes the text in the Message to be streamed
  2269. // to the ostream.
  2270. //
  2271. // For example;
  2272. //
  2273. // testing::Message foo;
  2274. // foo << 1 << " != " << 2;
  2275. // std::cout << foo;
  2276. //
  2277. // will print "1 != 2".
  2278. //
  2279. // Message is not intended to be inherited from. In particular, its
  2280. // destructor is not virtual.
  2281. //
  2282. // Note that stringstream behaves differently in gcc and in MSVC. You
  2283. // can stream a NULL char pointer to it in the former, but not in the
  2284. // latter (it causes an access violation if you do). The Message
  2285. // class hides this difference by treating a NULL char pointer as
  2286. // "(null)".
  2287. class GTEST_API_ Message {
  2288. private:
  2289. // The type of basic IO manipulators (endl, ends, and flush) for
  2290. // narrow streams.
  2291. typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
  2292. public:
  2293. // Constructs an empty Message.
  2294. Message();
  2295. // Copy constructor.
  2296. Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
  2297. *ss_ << msg.GetString();
  2298. }
  2299. // Constructs a Message from a C-string.
  2300. explicit Message(const char* str) : ss_(new ::std::stringstream) {
  2301. *ss_ << str;
  2302. }
  2303. // Streams a non-pointer value to this object.
  2304. template <typename T>
  2305. inline Message& operator <<(const T& val) {
  2306. // Some libraries overload << for STL containers. These
  2307. // overloads are defined in the global namespace instead of ::std.
  2308. //
  2309. // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
  2310. // overloads are visible in either the std namespace or the global
  2311. // namespace, but not other namespaces, including the testing
  2312. // namespace which Google Test's Message class is in.
  2313. //
  2314. // To allow STL containers (and other types that has a << operator
  2315. // defined in the global namespace) to be used in Google Test
  2316. // assertions, testing::Message must access the custom << operator
  2317. // from the global namespace. With this using declaration,
  2318. // overloads of << defined in the global namespace and those
  2319. // visible via Koenig lookup are both exposed in this function.
  2320. using ::operator <<;
  2321. *ss_ << val;
  2322. return *this;
  2323. }
  2324. // Streams a pointer value to this object.
  2325. //
  2326. // This function is an overload of the previous one. When you
  2327. // stream a pointer to a Message, this definition will be used as it
  2328. // is more specialized. (The C++ Standard, section
  2329. // [temp.func.order].) If you stream a non-pointer, then the
  2330. // previous definition will be used.
  2331. //
  2332. // The reason for this overload is that streaming a NULL pointer to
  2333. // ostream is undefined behavior. Depending on the compiler, you
  2334. // may get "0", "(nil)", "(null)", or an access violation. To
  2335. // ensure consistent result across compilers, we always treat NULL
  2336. // as "(null)".
  2337. template <typename T>
  2338. inline Message& operator <<(T* const& pointer) { // NOLINT
  2339. if (pointer == nullptr) {
  2340. *ss_ << "(null)";
  2341. } else {
  2342. *ss_ << pointer;
  2343. }
  2344. return *this;
  2345. }
  2346. // Since the basic IO manipulators are overloaded for both narrow
  2347. // and wide streams, we have to provide this specialized definition
  2348. // of operator <<, even though its body is the same as the
  2349. // templatized version above. Without this definition, streaming
  2350. // endl or other basic IO manipulators to Message will confuse the
  2351. // compiler.
  2352. Message& operator <<(BasicNarrowIoManip val) {
  2353. *ss_ << val;
  2354. return *this;
  2355. }
  2356. // Instead of 1/0, we want to see true/false for bool values.
  2357. Message& operator <<(bool b) {
  2358. return *this << (b ? "true" : "false");
  2359. }
  2360. // These two overloads allow streaming a wide C string to a Message
  2361. // using the UTF-8 encoding.
  2362. Message& operator <<(const wchar_t* wide_c_str);
  2363. Message& operator <<(wchar_t* wide_c_str);
  2364. #if GTEST_HAS_STD_WSTRING
  2365. // Converts the given wide string to a narrow string using the UTF-8
  2366. // encoding, and streams the result to this Message object.
  2367. Message& operator <<(const ::std::wstring& wstr);
  2368. #endif // GTEST_HAS_STD_WSTRING
  2369. #if GTEST_HAS_GLOBAL_WSTRING
  2370. // Converts the given wide string to a narrow string using the UTF-8
  2371. // encoding, and streams the result to this Message object.
  2372. Message& operator <<(const ::wstring& wstr);
  2373. #endif // GTEST_HAS_GLOBAL_WSTRING
  2374. // Gets the text streamed to this object so far as an std::string.
  2375. // Each '\0' character in the buffer is replaced with "\\0".
  2376. //
  2377. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  2378. std::string GetString() const;
  2379. private:
  2380. // We'll hold the text streamed to this object here.
  2381. const std::unique_ptr< ::std::stringstream> ss_;
  2382. // We declare (but don't implement) this to prevent the compiler
  2383. // from implementing the assignment operator.
  2384. void operator=(const Message&);
  2385. };
  2386. // Streams a Message to an ostream.
  2387. inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
  2388. return os << sb.GetString();
  2389. }
  2390. namespace internal {
  2391. // Converts a streamable value to an std::string. A NULL pointer is
  2392. // converted to "(null)". When the input value is a ::string,
  2393. // ::std::string, ::wstring, or ::std::wstring object, each NUL
  2394. // character in it is replaced with "\\0".
  2395. template <typename T>
  2396. std::string StreamableToString(const T& streamable) {
  2397. return (Message() << streamable).GetString();
  2398. }
  2399. } // namespace internal
  2400. } // namespace testing
  2401. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  2402. #endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
  2403. // Copyright 2008, Google Inc.
  2404. // All rights reserved.
  2405. //
  2406. // Redistribution and use in source and binary forms, with or without
  2407. // modification, are permitted provided that the following conditions are
  2408. // met:
  2409. //
  2410. // * Redistributions of source code must retain the above copyright
  2411. // notice, this list of conditions and the following disclaimer.
  2412. // * Redistributions in binary form must reproduce the above
  2413. // copyright notice, this list of conditions and the following disclaimer
  2414. // in the documentation and/or other materials provided with the
  2415. // distribution.
  2416. // * Neither the name of Google Inc. nor the names of its
  2417. // contributors may be used to endorse or promote products derived from
  2418. // this software without specific prior written permission.
  2419. //
  2420. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2421. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2422. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2423. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2424. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2425. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2426. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2427. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2428. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2429. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2430. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2431. //
  2432. // Google Test filepath utilities
  2433. //
  2434. // This header file declares classes and functions used internally by
  2435. // Google Test. They are subject to change without notice.
  2436. //
  2437. // This file is #included in gtest/internal/gtest-internal.h.
  2438. // Do not include this header file separately!
  2439. // GOOGLETEST_CM0001 DO NOT DELETE
  2440. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
  2441. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
  2442. // Copyright 2005, Google Inc.
  2443. // All rights reserved.
  2444. //
  2445. // Redistribution and use in source and binary forms, with or without
  2446. // modification, are permitted provided that the following conditions are
  2447. // met:
  2448. //
  2449. // * Redistributions of source code must retain the above copyright
  2450. // notice, this list of conditions and the following disclaimer.
  2451. // * Redistributions in binary form must reproduce the above
  2452. // copyright notice, this list of conditions and the following disclaimer
  2453. // in the documentation and/or other materials provided with the
  2454. // distribution.
  2455. // * Neither the name of Google Inc. nor the names of its
  2456. // contributors may be used to endorse or promote products derived from
  2457. // this software without specific prior written permission.
  2458. //
  2459. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2460. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2461. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2462. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2463. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2464. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2465. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2466. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2467. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2468. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2469. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2470. //
  2471. // The Google C++ Testing and Mocking Framework (Google Test)
  2472. //
  2473. // This header file declares the String class and functions used internally by
  2474. // Google Test. They are subject to change without notice. They should not used
  2475. // by code external to Google Test.
  2476. //
  2477. // This header file is #included by gtest-internal.h.
  2478. // It should not be #included by other files.
  2479. // GOOGLETEST_CM0001 DO NOT DELETE
  2480. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
  2481. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
  2482. #ifdef __BORLANDC__
  2483. // string.h is not guaranteed to provide strcpy on C++ Builder.
  2484. # include <mem.h>
  2485. #endif
  2486. #include <string.h>
  2487. #include <string>
  2488. namespace testing {
  2489. namespace internal {
  2490. // String - an abstract class holding static string utilities.
  2491. class GTEST_API_ String {
  2492. public:
  2493. // Static utility methods
  2494. // Clones a 0-terminated C string, allocating memory using new. The
  2495. // caller is responsible for deleting the return value using
  2496. // delete[]. Returns the cloned string, or NULL if the input is
  2497. // NULL.
  2498. //
  2499. // This is different from strdup() in string.h, which allocates
  2500. // memory using malloc().
  2501. static const char* CloneCString(const char* c_str);
  2502. #if GTEST_OS_WINDOWS_MOBILE
  2503. // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
  2504. // able to pass strings to Win32 APIs on CE we need to convert them
  2505. // to 'Unicode', UTF-16.
  2506. // Creates a UTF-16 wide string from the given ANSI string, allocating
  2507. // memory using new. The caller is responsible for deleting the return
  2508. // value using delete[]. Returns the wide string, or NULL if the
  2509. // input is NULL.
  2510. //
  2511. // The wide string is created using the ANSI codepage (CP_ACP) to
  2512. // match the behaviour of the ANSI versions of Win32 calls and the
  2513. // C runtime.
  2514. static LPCWSTR AnsiToUtf16(const char* c_str);
  2515. // Creates an ANSI string from the given wide string, allocating
  2516. // memory using new. The caller is responsible for deleting the return
  2517. // value using delete[]. Returns the ANSI string, or NULL if the
  2518. // input is NULL.
  2519. //
  2520. // The returned string is created using the ANSI codepage (CP_ACP) to
  2521. // match the behaviour of the ANSI versions of Win32 calls and the
  2522. // C runtime.
  2523. static const char* Utf16ToAnsi(LPCWSTR utf16_str);
  2524. #endif
  2525. // Compares two C strings. Returns true iff they have the same content.
  2526. //
  2527. // Unlike strcmp(), this function can handle NULL argument(s). A
  2528. // NULL C string is considered different to any non-NULL C string,
  2529. // including the empty string.
  2530. static bool CStringEquals(const char* lhs, const char* rhs);
  2531. // Converts a wide C string to a String using the UTF-8 encoding.
  2532. // NULL will be converted to "(null)". If an error occurred during
  2533. // the conversion, "(failed to convert from wide string)" is
  2534. // returned.
  2535. static std::string ShowWideCString(const wchar_t* wide_c_str);
  2536. // Compares two wide C strings. Returns true iff they have the same
  2537. // content.
  2538. //
  2539. // Unlike wcscmp(), this function can handle NULL argument(s). A
  2540. // NULL C string is considered different to any non-NULL C string,
  2541. // including the empty string.
  2542. static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
  2543. // Compares two C strings, ignoring case. Returns true iff they
  2544. // have the same content.
  2545. //
  2546. // Unlike strcasecmp(), this function can handle NULL argument(s).
  2547. // A NULL C string is considered different to any non-NULL C string,
  2548. // including the empty string.
  2549. static bool CaseInsensitiveCStringEquals(const char* lhs,
  2550. const char* rhs);
  2551. // Compares two wide C strings, ignoring case. Returns true iff they
  2552. // have the same content.
  2553. //
  2554. // Unlike wcscasecmp(), this function can handle NULL argument(s).
  2555. // A NULL C string is considered different to any non-NULL wide C string,
  2556. // including the empty string.
  2557. // NB: The implementations on different platforms slightly differ.
  2558. // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
  2559. // environment variable. On GNU platform this method uses wcscasecmp
  2560. // which compares according to LC_CTYPE category of the current locale.
  2561. // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
  2562. // current locale.
  2563. static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
  2564. const wchar_t* rhs);
  2565. // Returns true iff the given string ends with the given suffix, ignoring
  2566. // case. Any string is considered to end with an empty suffix.
  2567. static bool EndsWithCaseInsensitive(
  2568. const std::string& str, const std::string& suffix);
  2569. // Formats an int value as "%02d".
  2570. static std::string FormatIntWidth2(int value); // "%02d" for width == 2
  2571. // Formats an int value as "%X".
  2572. static std::string FormatHexInt(int value);
  2573. // Formats a byte as "%02X".
  2574. static std::string FormatByte(unsigned char value);
  2575. private:
  2576. String(); // Not meant to be instantiated.
  2577. }; // class String
  2578. // Gets the content of the stringstream's buffer as an std::string. Each '\0'
  2579. // character in the buffer is replaced with "\\0".
  2580. GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
  2581. } // namespace internal
  2582. } // namespace testing
  2583. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
  2584. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  2585. /* class A needs to have dll-interface to be used by clients of class B */)
  2586. namespace testing {
  2587. namespace internal {
  2588. // FilePath - a class for file and directory pathname manipulation which
  2589. // handles platform-specific conventions (like the pathname separator).
  2590. // Used for helper functions for naming files in a directory for xml output.
  2591. // Except for Set methods, all methods are const or static, which provides an
  2592. // "immutable value object" -- useful for peace of mind.
  2593. // A FilePath with a value ending in a path separator ("like/this/") represents
  2594. // a directory, otherwise it is assumed to represent a file. In either case,
  2595. // it may or may not represent an actual file or directory in the file system.
  2596. // Names are NOT checked for syntax correctness -- no checking for illegal
  2597. // characters, malformed paths, etc.
  2598. class GTEST_API_ FilePath {
  2599. public:
  2600. FilePath() : pathname_("") { }
  2601. FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
  2602. explicit FilePath(const std::string& pathname) : pathname_(pathname) {
  2603. Normalize();
  2604. }
  2605. FilePath& operator=(const FilePath& rhs) {
  2606. Set(rhs);
  2607. return *this;
  2608. }
  2609. void Set(const FilePath& rhs) {
  2610. pathname_ = rhs.pathname_;
  2611. }
  2612. const std::string& string() const { return pathname_; }
  2613. const char* c_str() const { return pathname_.c_str(); }
  2614. // Returns the current working directory, or "" if unsuccessful.
  2615. static FilePath GetCurrentDir();
  2616. // Given directory = "dir", base_name = "test", number = 0,
  2617. // extension = "xml", returns "dir/test.xml". If number is greater
  2618. // than zero (e.g., 12), returns "dir/test_12.xml".
  2619. // On Windows platform, uses \ as the separator rather than /.
  2620. static FilePath MakeFileName(const FilePath& directory,
  2621. const FilePath& base_name,
  2622. int number,
  2623. const char* extension);
  2624. // Given directory = "dir", relative_path = "test.xml",
  2625. // returns "dir/test.xml".
  2626. // On Windows, uses \ as the separator rather than /.
  2627. static FilePath ConcatPaths(const FilePath& directory,
  2628. const FilePath& relative_path);
  2629. // Returns a pathname for a file that does not currently exist. The pathname
  2630. // will be directory/base_name.extension or
  2631. // directory/base_name_<number>.extension if directory/base_name.extension
  2632. // already exists. The number will be incremented until a pathname is found
  2633. // that does not already exist.
  2634. // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
  2635. // There could be a race condition if two or more processes are calling this
  2636. // function at the same time -- they could both pick the same filename.
  2637. static FilePath GenerateUniqueFileName(const FilePath& directory,
  2638. const FilePath& base_name,
  2639. const char* extension);
  2640. // Returns true iff the path is "".
  2641. bool IsEmpty() const { return pathname_.empty(); }
  2642. // If input name has a trailing separator character, removes it and returns
  2643. // the name, otherwise return the name string unmodified.
  2644. // On Windows platform, uses \ as the separator, other platforms use /.
  2645. FilePath RemoveTrailingPathSeparator() const;
  2646. // Returns a copy of the FilePath with the directory part removed.
  2647. // Example: FilePath("path/to/file").RemoveDirectoryName() returns
  2648. // FilePath("file"). If there is no directory part ("just_a_file"), it returns
  2649. // the FilePath unmodified. If there is no file part ("just_a_dir/") it
  2650. // returns an empty FilePath ("").
  2651. // On Windows platform, '\' is the path separator, otherwise it is '/'.
  2652. FilePath RemoveDirectoryName() const;
  2653. // RemoveFileName returns the directory path with the filename removed.
  2654. // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
  2655. // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
  2656. // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
  2657. // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
  2658. // On Windows platform, '\' is the path separator, otherwise it is '/'.
  2659. FilePath RemoveFileName() const;
  2660. // Returns a copy of the FilePath with the case-insensitive extension removed.
  2661. // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
  2662. // FilePath("dir/file"). If a case-insensitive extension is not
  2663. // found, returns a copy of the original FilePath.
  2664. FilePath RemoveExtension(const char* extension) const;
  2665. // Creates directories so that path exists. Returns true if successful or if
  2666. // the directories already exist; returns false if unable to create
  2667. // directories for any reason. Will also return false if the FilePath does
  2668. // not represent a directory (that is, it doesn't end with a path separator).
  2669. bool CreateDirectoriesRecursively() const;
  2670. // Create the directory so that path exists. Returns true if successful or
  2671. // if the directory already exists; returns false if unable to create the
  2672. // directory for any reason, including if the parent directory does not
  2673. // exist. Not named "CreateDirectory" because that's a macro on Windows.
  2674. bool CreateFolder() const;
  2675. // Returns true if FilePath describes something in the file-system,
  2676. // either a file, directory, or whatever, and that something exists.
  2677. bool FileOrDirectoryExists() const;
  2678. // Returns true if pathname describes a directory in the file-system
  2679. // that exists.
  2680. bool DirectoryExists() const;
  2681. // Returns true if FilePath ends with a path separator, which indicates that
  2682. // it is intended to represent a directory. Returns false otherwise.
  2683. // This does NOT check that a directory (or file) actually exists.
  2684. bool IsDirectory() const;
  2685. // Returns true if pathname describes a root directory. (Windows has one
  2686. // root directory per disk drive.)
  2687. bool IsRootDirectory() const;
  2688. // Returns true if pathname describes an absolute path.
  2689. bool IsAbsolutePath() const;
  2690. private:
  2691. // Replaces multiple consecutive separators with a single separator.
  2692. // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
  2693. // redundancies that might be in a pathname involving "." or "..".
  2694. //
  2695. // A pathname with multiple consecutive separators may occur either through
  2696. // user error or as a result of some scripts or APIs that generate a pathname
  2697. // with a trailing separator. On other platforms the same API or script
  2698. // may NOT generate a pathname with a trailing "/". Then elsewhere that
  2699. // pathname may have another "/" and pathname components added to it,
  2700. // without checking for the separator already being there.
  2701. // The script language and operating system may allow paths like "foo//bar"
  2702. // but some of the functions in FilePath will not handle that correctly. In
  2703. // particular, RemoveTrailingPathSeparator() only removes one separator, and
  2704. // it is called in CreateDirectoriesRecursively() assuming that it will change
  2705. // a pathname from directory syntax (trailing separator) to filename syntax.
  2706. //
  2707. // On Windows this method also replaces the alternate path separator '/' with
  2708. // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
  2709. // "bar\\foo".
  2710. void Normalize();
  2711. // Returns a pointer to the last occurence of a valid path separator in
  2712. // the FilePath. On Windows, for example, both '/' and '\' are valid path
  2713. // separators. Returns NULL if no path separator was found.
  2714. const char* FindLastPathSeparator() const;
  2715. std::string pathname_;
  2716. }; // class FilePath
  2717. } // namespace internal
  2718. } // namespace testing
  2719. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  2720. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
  2721. // This file was GENERATED by command:
  2722. // pump.py gtest-type-util.h.pump
  2723. // DO NOT EDIT BY HAND!!!
  2724. // Copyright 2008 Google Inc.
  2725. // All Rights Reserved.
  2726. //
  2727. // Redistribution and use in source and binary forms, with or without
  2728. // modification, are permitted provided that the following conditions are
  2729. // met:
  2730. //
  2731. // * Redistributions of source code must retain the above copyright
  2732. // notice, this list of conditions and the following disclaimer.
  2733. // * Redistributions in binary form must reproduce the above
  2734. // copyright notice, this list of conditions and the following disclaimer
  2735. // in the documentation and/or other materials provided with the
  2736. // distribution.
  2737. // * Neither the name of Google Inc. nor the names of its
  2738. // contributors may be used to endorse or promote products derived from
  2739. // this software without specific prior written permission.
  2740. //
  2741. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  2742. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  2743. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  2744. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  2745. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  2746. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  2747. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  2748. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  2749. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2750. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  2751. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2752. // Type utilities needed for implementing typed and type-parameterized
  2753. // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
  2754. //
  2755. // Currently we support at most 50 types in a list, and at most 50
  2756. // type-parameterized tests in one type-parameterized test suite.
  2757. // Please contact googletestframework@googlegroups.com if you need
  2758. // more.
  2759. // GOOGLETEST_CM0001 DO NOT DELETE
  2760. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
  2761. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
  2762. // #ifdef __GNUC__ is too general here. It is possible to use gcc without using
  2763. // libstdc++ (which is where cxxabi.h comes from).
  2764. # if GTEST_HAS_CXXABI_H_
  2765. # include <cxxabi.h>
  2766. # elif defined(__HP_aCC)
  2767. # include <acxx_demangle.h>
  2768. # endif // GTEST_HASH_CXXABI_H_
  2769. namespace testing {
  2770. namespace internal {
  2771. // Canonicalizes a given name with respect to the Standard C++ Library.
  2772. // This handles removing the inline namespace within `std` that is
  2773. // used by various standard libraries (e.g., `std::__1`). Names outside
  2774. // of namespace std are returned unmodified.
  2775. inline std::string CanonicalizeForStdLibVersioning(std::string s) {
  2776. static const char prefix[] = "std::__";
  2777. if (s.compare(0, strlen(prefix), prefix) == 0) {
  2778. std::string::size_type end = s.find("::", strlen(prefix));
  2779. if (end != s.npos) {
  2780. // Erase everything between the initial `std` and the second `::`.
  2781. s.erase(strlen("std"), end - strlen("std"));
  2782. }
  2783. }
  2784. return s;
  2785. }
  2786. // GetTypeName<T>() returns a human-readable name of type T.
  2787. // NB: This function is also used in Google Mock, so don't move it inside of
  2788. // the typed-test-only section below.
  2789. template <typename T>
  2790. std::string GetTypeName() {
  2791. # if GTEST_HAS_RTTI
  2792. const char* const name = typeid(T).name();
  2793. # if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
  2794. int status = 0;
  2795. // gcc's implementation of typeid(T).name() mangles the type name,
  2796. // so we have to demangle it.
  2797. # if GTEST_HAS_CXXABI_H_
  2798. using abi::__cxa_demangle;
  2799. # endif // GTEST_HAS_CXXABI_H_
  2800. char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status);
  2801. const std::string name_str(status == 0 ? readable_name : name);
  2802. free(readable_name);
  2803. return CanonicalizeForStdLibVersioning(name_str);
  2804. # else
  2805. return name;
  2806. # endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
  2807. # else
  2808. return "<type>";
  2809. # endif // GTEST_HAS_RTTI
  2810. }
  2811. #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
  2812. // AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
  2813. // type. This can be used as a compile-time assertion to ensure that
  2814. // two types are equal.
  2815. template <typename T1, typename T2>
  2816. struct AssertTypeEq;
  2817. template <typename T>
  2818. struct AssertTypeEq<T, T> {
  2819. typedef bool type;
  2820. };
  2821. // A unique type used as the default value for the arguments of class
  2822. // template Types. This allows us to simulate variadic templates
  2823. // (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
  2824. // support directly.
  2825. struct None {};
  2826. // The following family of struct and struct templates are used to
  2827. // represent type lists. In particular, TypesN<T1, T2, ..., TN>
  2828. // represents a type list with N types (T1, T2, ..., and TN) in it.
  2829. // Except for Types0, every struct in the family has two member types:
  2830. // Head for the first type in the list, and Tail for the rest of the
  2831. // list.
  2832. // The empty type list.
  2833. struct Types0 {};
  2834. // Type lists of length 1, 2, 3, and so on.
  2835. template <typename T1>
  2836. struct Types1 {
  2837. typedef T1 Head;
  2838. typedef Types0 Tail;
  2839. };
  2840. template <typename T1, typename T2>
  2841. struct Types2 {
  2842. typedef T1 Head;
  2843. typedef Types1<T2> Tail;
  2844. };
  2845. template <typename T1, typename T2, typename T3>
  2846. struct Types3 {
  2847. typedef T1 Head;
  2848. typedef Types2<T2, T3> Tail;
  2849. };
  2850. template <typename T1, typename T2, typename T3, typename T4>
  2851. struct Types4 {
  2852. typedef T1 Head;
  2853. typedef Types3<T2, T3, T4> Tail;
  2854. };
  2855. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  2856. struct Types5 {
  2857. typedef T1 Head;
  2858. typedef Types4<T2, T3, T4, T5> Tail;
  2859. };
  2860. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2861. typename T6>
  2862. struct Types6 {
  2863. typedef T1 Head;
  2864. typedef Types5<T2, T3, T4, T5, T6> Tail;
  2865. };
  2866. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2867. typename T6, typename T7>
  2868. struct Types7 {
  2869. typedef T1 Head;
  2870. typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
  2871. };
  2872. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2873. typename T6, typename T7, typename T8>
  2874. struct Types8 {
  2875. typedef T1 Head;
  2876. typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
  2877. };
  2878. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2879. typename T6, typename T7, typename T8, typename T9>
  2880. struct Types9 {
  2881. typedef T1 Head;
  2882. typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
  2883. };
  2884. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2885. typename T6, typename T7, typename T8, typename T9, typename T10>
  2886. struct Types10 {
  2887. typedef T1 Head;
  2888. typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
  2889. };
  2890. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2891. typename T6, typename T7, typename T8, typename T9, typename T10,
  2892. typename T11>
  2893. struct Types11 {
  2894. typedef T1 Head;
  2895. typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
  2896. };
  2897. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2898. typename T6, typename T7, typename T8, typename T9, typename T10,
  2899. typename T11, typename T12>
  2900. struct Types12 {
  2901. typedef T1 Head;
  2902. typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
  2903. };
  2904. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2905. typename T6, typename T7, typename T8, typename T9, typename T10,
  2906. typename T11, typename T12, typename T13>
  2907. struct Types13 {
  2908. typedef T1 Head;
  2909. typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
  2910. };
  2911. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2912. typename T6, typename T7, typename T8, typename T9, typename T10,
  2913. typename T11, typename T12, typename T13, typename T14>
  2914. struct Types14 {
  2915. typedef T1 Head;
  2916. typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
  2917. };
  2918. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2919. typename T6, typename T7, typename T8, typename T9, typename T10,
  2920. typename T11, typename T12, typename T13, typename T14, typename T15>
  2921. struct Types15 {
  2922. typedef T1 Head;
  2923. typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  2924. T15> Tail;
  2925. };
  2926. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2927. typename T6, typename T7, typename T8, typename T9, typename T10,
  2928. typename T11, typename T12, typename T13, typename T14, typename T15,
  2929. typename T16>
  2930. struct Types16 {
  2931. typedef T1 Head;
  2932. typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2933. T16> Tail;
  2934. };
  2935. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2936. typename T6, typename T7, typename T8, typename T9, typename T10,
  2937. typename T11, typename T12, typename T13, typename T14, typename T15,
  2938. typename T16, typename T17>
  2939. struct Types17 {
  2940. typedef T1 Head;
  2941. typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2942. T16, T17> Tail;
  2943. };
  2944. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2945. typename T6, typename T7, typename T8, typename T9, typename T10,
  2946. typename T11, typename T12, typename T13, typename T14, typename T15,
  2947. typename T16, typename T17, typename T18>
  2948. struct Types18 {
  2949. typedef T1 Head;
  2950. typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2951. T16, T17, T18> Tail;
  2952. };
  2953. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2954. typename T6, typename T7, typename T8, typename T9, typename T10,
  2955. typename T11, typename T12, typename T13, typename T14, typename T15,
  2956. typename T16, typename T17, typename T18, typename T19>
  2957. struct Types19 {
  2958. typedef T1 Head;
  2959. typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2960. T16, T17, T18, T19> Tail;
  2961. };
  2962. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2963. typename T6, typename T7, typename T8, typename T9, typename T10,
  2964. typename T11, typename T12, typename T13, typename T14, typename T15,
  2965. typename T16, typename T17, typename T18, typename T19, typename T20>
  2966. struct Types20 {
  2967. typedef T1 Head;
  2968. typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2969. T16, T17, T18, T19, T20> Tail;
  2970. };
  2971. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2972. typename T6, typename T7, typename T8, typename T9, typename T10,
  2973. typename T11, typename T12, typename T13, typename T14, typename T15,
  2974. typename T16, typename T17, typename T18, typename T19, typename T20,
  2975. typename T21>
  2976. struct Types21 {
  2977. typedef T1 Head;
  2978. typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2979. T16, T17, T18, T19, T20, T21> Tail;
  2980. };
  2981. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2982. typename T6, typename T7, typename T8, typename T9, typename T10,
  2983. typename T11, typename T12, typename T13, typename T14, typename T15,
  2984. typename T16, typename T17, typename T18, typename T19, typename T20,
  2985. typename T21, typename T22>
  2986. struct Types22 {
  2987. typedef T1 Head;
  2988. typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2989. T16, T17, T18, T19, T20, T21, T22> Tail;
  2990. };
  2991. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  2992. typename T6, typename T7, typename T8, typename T9, typename T10,
  2993. typename T11, typename T12, typename T13, typename T14, typename T15,
  2994. typename T16, typename T17, typename T18, typename T19, typename T20,
  2995. typename T21, typename T22, typename T23>
  2996. struct Types23 {
  2997. typedef T1 Head;
  2998. typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  2999. T16, T17, T18, T19, T20, T21, T22, T23> Tail;
  3000. };
  3001. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3002. typename T6, typename T7, typename T8, typename T9, typename T10,
  3003. typename T11, typename T12, typename T13, typename T14, typename T15,
  3004. typename T16, typename T17, typename T18, typename T19, typename T20,
  3005. typename T21, typename T22, typename T23, typename T24>
  3006. struct Types24 {
  3007. typedef T1 Head;
  3008. typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3009. T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
  3010. };
  3011. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3012. typename T6, typename T7, typename T8, typename T9, typename T10,
  3013. typename T11, typename T12, typename T13, typename T14, typename T15,
  3014. typename T16, typename T17, typename T18, typename T19, typename T20,
  3015. typename T21, typename T22, typename T23, typename T24, typename T25>
  3016. struct Types25 {
  3017. typedef T1 Head;
  3018. typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3019. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
  3020. };
  3021. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3022. typename T6, typename T7, typename T8, typename T9, typename T10,
  3023. typename T11, typename T12, typename T13, typename T14, typename T15,
  3024. typename T16, typename T17, typename T18, typename T19, typename T20,
  3025. typename T21, typename T22, typename T23, typename T24, typename T25,
  3026. typename T26>
  3027. struct Types26 {
  3028. typedef T1 Head;
  3029. typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3030. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
  3031. };
  3032. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3033. typename T6, typename T7, typename T8, typename T9, typename T10,
  3034. typename T11, typename T12, typename T13, typename T14, typename T15,
  3035. typename T16, typename T17, typename T18, typename T19, typename T20,
  3036. typename T21, typename T22, typename T23, typename T24, typename T25,
  3037. typename T26, typename T27>
  3038. struct Types27 {
  3039. typedef T1 Head;
  3040. typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3041. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
  3042. };
  3043. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3044. typename T6, typename T7, typename T8, typename T9, typename T10,
  3045. typename T11, typename T12, typename T13, typename T14, typename T15,
  3046. typename T16, typename T17, typename T18, typename T19, typename T20,
  3047. typename T21, typename T22, typename T23, typename T24, typename T25,
  3048. typename T26, typename T27, typename T28>
  3049. struct Types28 {
  3050. typedef T1 Head;
  3051. typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3052. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
  3053. };
  3054. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3055. typename T6, typename T7, typename T8, typename T9, typename T10,
  3056. typename T11, typename T12, typename T13, typename T14, typename T15,
  3057. typename T16, typename T17, typename T18, typename T19, typename T20,
  3058. typename T21, typename T22, typename T23, typename T24, typename T25,
  3059. typename T26, typename T27, typename T28, typename T29>
  3060. struct Types29 {
  3061. typedef T1 Head;
  3062. typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3063. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  3064. T29> Tail;
  3065. };
  3066. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3067. typename T6, typename T7, typename T8, typename T9, typename T10,
  3068. typename T11, typename T12, typename T13, typename T14, typename T15,
  3069. typename T16, typename T17, typename T18, typename T19, typename T20,
  3070. typename T21, typename T22, typename T23, typename T24, typename T25,
  3071. typename T26, typename T27, typename T28, typename T29, typename T30>
  3072. struct Types30 {
  3073. typedef T1 Head;
  3074. typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3075. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3076. T30> Tail;
  3077. };
  3078. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3079. typename T6, typename T7, typename T8, typename T9, typename T10,
  3080. typename T11, typename T12, typename T13, typename T14, typename T15,
  3081. typename T16, typename T17, typename T18, typename T19, typename T20,
  3082. typename T21, typename T22, typename T23, typename T24, typename T25,
  3083. typename T26, typename T27, typename T28, typename T29, typename T30,
  3084. typename T31>
  3085. struct Types31 {
  3086. typedef T1 Head;
  3087. typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3088. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3089. T30, T31> Tail;
  3090. };
  3091. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3092. typename T6, typename T7, typename T8, typename T9, typename T10,
  3093. typename T11, typename T12, typename T13, typename T14, typename T15,
  3094. typename T16, typename T17, typename T18, typename T19, typename T20,
  3095. typename T21, typename T22, typename T23, typename T24, typename T25,
  3096. typename T26, typename T27, typename T28, typename T29, typename T30,
  3097. typename T31, typename T32>
  3098. struct Types32 {
  3099. typedef T1 Head;
  3100. typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3101. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3102. T30, T31, T32> Tail;
  3103. };
  3104. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3105. typename T6, typename T7, typename T8, typename T9, typename T10,
  3106. typename T11, typename T12, typename T13, typename T14, typename T15,
  3107. typename T16, typename T17, typename T18, typename T19, typename T20,
  3108. typename T21, typename T22, typename T23, typename T24, typename T25,
  3109. typename T26, typename T27, typename T28, typename T29, typename T30,
  3110. typename T31, typename T32, typename T33>
  3111. struct Types33 {
  3112. typedef T1 Head;
  3113. typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3114. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3115. T30, T31, T32, T33> Tail;
  3116. };
  3117. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3118. typename T6, typename T7, typename T8, typename T9, typename T10,
  3119. typename T11, typename T12, typename T13, typename T14, typename T15,
  3120. typename T16, typename T17, typename T18, typename T19, typename T20,
  3121. typename T21, typename T22, typename T23, typename T24, typename T25,
  3122. typename T26, typename T27, typename T28, typename T29, typename T30,
  3123. typename T31, typename T32, typename T33, typename T34>
  3124. struct Types34 {
  3125. typedef T1 Head;
  3126. typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3127. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3128. T30, T31, T32, T33, T34> Tail;
  3129. };
  3130. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3131. typename T6, typename T7, typename T8, typename T9, typename T10,
  3132. typename T11, typename T12, typename T13, typename T14, typename T15,
  3133. typename T16, typename T17, typename T18, typename T19, typename T20,
  3134. typename T21, typename T22, typename T23, typename T24, typename T25,
  3135. typename T26, typename T27, typename T28, typename T29, typename T30,
  3136. typename T31, typename T32, typename T33, typename T34, typename T35>
  3137. struct Types35 {
  3138. typedef T1 Head;
  3139. typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3140. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3141. T30, T31, T32, T33, T34, T35> Tail;
  3142. };
  3143. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3144. typename T6, typename T7, typename T8, typename T9, typename T10,
  3145. typename T11, typename T12, typename T13, typename T14, typename T15,
  3146. typename T16, typename T17, typename T18, typename T19, typename T20,
  3147. typename T21, typename T22, typename T23, typename T24, typename T25,
  3148. typename T26, typename T27, typename T28, typename T29, typename T30,
  3149. typename T31, typename T32, typename T33, typename T34, typename T35,
  3150. typename T36>
  3151. struct Types36 {
  3152. typedef T1 Head;
  3153. typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3154. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3155. T30, T31, T32, T33, T34, T35, T36> Tail;
  3156. };
  3157. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3158. typename T6, typename T7, typename T8, typename T9, typename T10,
  3159. typename T11, typename T12, typename T13, typename T14, typename T15,
  3160. typename T16, typename T17, typename T18, typename T19, typename T20,
  3161. typename T21, typename T22, typename T23, typename T24, typename T25,
  3162. typename T26, typename T27, typename T28, typename T29, typename T30,
  3163. typename T31, typename T32, typename T33, typename T34, typename T35,
  3164. typename T36, typename T37>
  3165. struct Types37 {
  3166. typedef T1 Head;
  3167. typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3168. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3169. T30, T31, T32, T33, T34, T35, T36, T37> Tail;
  3170. };
  3171. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3172. typename T6, typename T7, typename T8, typename T9, typename T10,
  3173. typename T11, typename T12, typename T13, typename T14, typename T15,
  3174. typename T16, typename T17, typename T18, typename T19, typename T20,
  3175. typename T21, typename T22, typename T23, typename T24, typename T25,
  3176. typename T26, typename T27, typename T28, typename T29, typename T30,
  3177. typename T31, typename T32, typename T33, typename T34, typename T35,
  3178. typename T36, typename T37, typename T38>
  3179. struct Types38 {
  3180. typedef T1 Head;
  3181. typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3182. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3183. T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
  3184. };
  3185. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3186. typename T6, typename T7, typename T8, typename T9, typename T10,
  3187. typename T11, typename T12, typename T13, typename T14, typename T15,
  3188. typename T16, typename T17, typename T18, typename T19, typename T20,
  3189. typename T21, typename T22, typename T23, typename T24, typename T25,
  3190. typename T26, typename T27, typename T28, typename T29, typename T30,
  3191. typename T31, typename T32, typename T33, typename T34, typename T35,
  3192. typename T36, typename T37, typename T38, typename T39>
  3193. struct Types39 {
  3194. typedef T1 Head;
  3195. typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3196. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3197. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
  3198. };
  3199. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3200. typename T6, typename T7, typename T8, typename T9, typename T10,
  3201. typename T11, typename T12, typename T13, typename T14, typename T15,
  3202. typename T16, typename T17, typename T18, typename T19, typename T20,
  3203. typename T21, typename T22, typename T23, typename T24, typename T25,
  3204. typename T26, typename T27, typename T28, typename T29, typename T30,
  3205. typename T31, typename T32, typename T33, typename T34, typename T35,
  3206. typename T36, typename T37, typename T38, typename T39, typename T40>
  3207. struct Types40 {
  3208. typedef T1 Head;
  3209. typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3210. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3211. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
  3212. };
  3213. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3214. typename T6, typename T7, typename T8, typename T9, typename T10,
  3215. typename T11, typename T12, typename T13, typename T14, typename T15,
  3216. typename T16, typename T17, typename T18, typename T19, typename T20,
  3217. typename T21, typename T22, typename T23, typename T24, typename T25,
  3218. typename T26, typename T27, typename T28, typename T29, typename T30,
  3219. typename T31, typename T32, typename T33, typename T34, typename T35,
  3220. typename T36, typename T37, typename T38, typename T39, typename T40,
  3221. typename T41>
  3222. struct Types41 {
  3223. typedef T1 Head;
  3224. typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3225. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3226. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
  3227. };
  3228. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3229. typename T6, typename T7, typename T8, typename T9, typename T10,
  3230. typename T11, typename T12, typename T13, typename T14, typename T15,
  3231. typename T16, typename T17, typename T18, typename T19, typename T20,
  3232. typename T21, typename T22, typename T23, typename T24, typename T25,
  3233. typename T26, typename T27, typename T28, typename T29, typename T30,
  3234. typename T31, typename T32, typename T33, typename T34, typename T35,
  3235. typename T36, typename T37, typename T38, typename T39, typename T40,
  3236. typename T41, typename T42>
  3237. struct Types42 {
  3238. typedef T1 Head;
  3239. typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3240. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3241. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
  3242. };
  3243. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3244. typename T6, typename T7, typename T8, typename T9, typename T10,
  3245. typename T11, typename T12, typename T13, typename T14, typename T15,
  3246. typename T16, typename T17, typename T18, typename T19, typename T20,
  3247. typename T21, typename T22, typename T23, typename T24, typename T25,
  3248. typename T26, typename T27, typename T28, typename T29, typename T30,
  3249. typename T31, typename T32, typename T33, typename T34, typename T35,
  3250. typename T36, typename T37, typename T38, typename T39, typename T40,
  3251. typename T41, typename T42, typename T43>
  3252. struct Types43 {
  3253. typedef T1 Head;
  3254. typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3255. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3256. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  3257. T43> Tail;
  3258. };
  3259. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3260. typename T6, typename T7, typename T8, typename T9, typename T10,
  3261. typename T11, typename T12, typename T13, typename T14, typename T15,
  3262. typename T16, typename T17, typename T18, typename T19, typename T20,
  3263. typename T21, typename T22, typename T23, typename T24, typename T25,
  3264. typename T26, typename T27, typename T28, typename T29, typename T30,
  3265. typename T31, typename T32, typename T33, typename T34, typename T35,
  3266. typename T36, typename T37, typename T38, typename T39, typename T40,
  3267. typename T41, typename T42, typename T43, typename T44>
  3268. struct Types44 {
  3269. typedef T1 Head;
  3270. typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3271. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3272. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3273. T44> Tail;
  3274. };
  3275. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3276. typename T6, typename T7, typename T8, typename T9, typename T10,
  3277. typename T11, typename T12, typename T13, typename T14, typename T15,
  3278. typename T16, typename T17, typename T18, typename T19, typename T20,
  3279. typename T21, typename T22, typename T23, typename T24, typename T25,
  3280. typename T26, typename T27, typename T28, typename T29, typename T30,
  3281. typename T31, typename T32, typename T33, typename T34, typename T35,
  3282. typename T36, typename T37, typename T38, typename T39, typename T40,
  3283. typename T41, typename T42, typename T43, typename T44, typename T45>
  3284. struct Types45 {
  3285. typedef T1 Head;
  3286. typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3287. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3288. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3289. T44, T45> Tail;
  3290. };
  3291. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3292. typename T6, typename T7, typename T8, typename T9, typename T10,
  3293. typename T11, typename T12, typename T13, typename T14, typename T15,
  3294. typename T16, typename T17, typename T18, typename T19, typename T20,
  3295. typename T21, typename T22, typename T23, typename T24, typename T25,
  3296. typename T26, typename T27, typename T28, typename T29, typename T30,
  3297. typename T31, typename T32, typename T33, typename T34, typename T35,
  3298. typename T36, typename T37, typename T38, typename T39, typename T40,
  3299. typename T41, typename T42, typename T43, typename T44, typename T45,
  3300. typename T46>
  3301. struct Types46 {
  3302. typedef T1 Head;
  3303. typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3304. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3305. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3306. T44, T45, T46> Tail;
  3307. };
  3308. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3309. typename T6, typename T7, typename T8, typename T9, typename T10,
  3310. typename T11, typename T12, typename T13, typename T14, typename T15,
  3311. typename T16, typename T17, typename T18, typename T19, typename T20,
  3312. typename T21, typename T22, typename T23, typename T24, typename T25,
  3313. typename T26, typename T27, typename T28, typename T29, typename T30,
  3314. typename T31, typename T32, typename T33, typename T34, typename T35,
  3315. typename T36, typename T37, typename T38, typename T39, typename T40,
  3316. typename T41, typename T42, typename T43, typename T44, typename T45,
  3317. typename T46, typename T47>
  3318. struct Types47 {
  3319. typedef T1 Head;
  3320. typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3321. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3322. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3323. T44, T45, T46, T47> Tail;
  3324. };
  3325. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3326. typename T6, typename T7, typename T8, typename T9, typename T10,
  3327. typename T11, typename T12, typename T13, typename T14, typename T15,
  3328. typename T16, typename T17, typename T18, typename T19, typename T20,
  3329. typename T21, typename T22, typename T23, typename T24, typename T25,
  3330. typename T26, typename T27, typename T28, typename T29, typename T30,
  3331. typename T31, typename T32, typename T33, typename T34, typename T35,
  3332. typename T36, typename T37, typename T38, typename T39, typename T40,
  3333. typename T41, typename T42, typename T43, typename T44, typename T45,
  3334. typename T46, typename T47, typename T48>
  3335. struct Types48 {
  3336. typedef T1 Head;
  3337. typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3338. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3339. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3340. T44, T45, T46, T47, T48> Tail;
  3341. };
  3342. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3343. typename T6, typename T7, typename T8, typename T9, typename T10,
  3344. typename T11, typename T12, typename T13, typename T14, typename T15,
  3345. typename T16, typename T17, typename T18, typename T19, typename T20,
  3346. typename T21, typename T22, typename T23, typename T24, typename T25,
  3347. typename T26, typename T27, typename T28, typename T29, typename T30,
  3348. typename T31, typename T32, typename T33, typename T34, typename T35,
  3349. typename T36, typename T37, typename T38, typename T39, typename T40,
  3350. typename T41, typename T42, typename T43, typename T44, typename T45,
  3351. typename T46, typename T47, typename T48, typename T49>
  3352. struct Types49 {
  3353. typedef T1 Head;
  3354. typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3355. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3356. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3357. T44, T45, T46, T47, T48, T49> Tail;
  3358. };
  3359. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3360. typename T6, typename T7, typename T8, typename T9, typename T10,
  3361. typename T11, typename T12, typename T13, typename T14, typename T15,
  3362. typename T16, typename T17, typename T18, typename T19, typename T20,
  3363. typename T21, typename T22, typename T23, typename T24, typename T25,
  3364. typename T26, typename T27, typename T28, typename T29, typename T30,
  3365. typename T31, typename T32, typename T33, typename T34, typename T35,
  3366. typename T36, typename T37, typename T38, typename T39, typename T40,
  3367. typename T41, typename T42, typename T43, typename T44, typename T45,
  3368. typename T46, typename T47, typename T48, typename T49, typename T50>
  3369. struct Types50 {
  3370. typedef T1 Head;
  3371. typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3372. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3373. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  3374. T44, T45, T46, T47, T48, T49, T50> Tail;
  3375. };
  3376. } // namespace internal
  3377. // We don't want to require the users to write TypesN<...> directly,
  3378. // as that would require them to count the length. Types<...> is much
  3379. // easier to write, but generates horrible messages when there is a
  3380. // compiler error, as gcc insists on printing out each template
  3381. // argument, even if it has the default value (this means Types<int>
  3382. // will appear as Types<int, None, None, ..., None> in the compiler
  3383. // errors).
  3384. //
  3385. // Our solution is to combine the best part of the two approaches: a
  3386. // user would write Types<T1, ..., TN>, and Google Test will translate
  3387. // that to TypesN<T1, ..., TN> internally to make error messages
  3388. // readable. The translation is done by the 'type' member of the
  3389. // Types template.
  3390. template <typename T1 = internal::None, typename T2 = internal::None,
  3391. typename T3 = internal::None, typename T4 = internal::None,
  3392. typename T5 = internal::None, typename T6 = internal::None,
  3393. typename T7 = internal::None, typename T8 = internal::None,
  3394. typename T9 = internal::None, typename T10 = internal::None,
  3395. typename T11 = internal::None, typename T12 = internal::None,
  3396. typename T13 = internal::None, typename T14 = internal::None,
  3397. typename T15 = internal::None, typename T16 = internal::None,
  3398. typename T17 = internal::None, typename T18 = internal::None,
  3399. typename T19 = internal::None, typename T20 = internal::None,
  3400. typename T21 = internal::None, typename T22 = internal::None,
  3401. typename T23 = internal::None, typename T24 = internal::None,
  3402. typename T25 = internal::None, typename T26 = internal::None,
  3403. typename T27 = internal::None, typename T28 = internal::None,
  3404. typename T29 = internal::None, typename T30 = internal::None,
  3405. typename T31 = internal::None, typename T32 = internal::None,
  3406. typename T33 = internal::None, typename T34 = internal::None,
  3407. typename T35 = internal::None, typename T36 = internal::None,
  3408. typename T37 = internal::None, typename T38 = internal::None,
  3409. typename T39 = internal::None, typename T40 = internal::None,
  3410. typename T41 = internal::None, typename T42 = internal::None,
  3411. typename T43 = internal::None, typename T44 = internal::None,
  3412. typename T45 = internal::None, typename T46 = internal::None,
  3413. typename T47 = internal::None, typename T48 = internal::None,
  3414. typename T49 = internal::None, typename T50 = internal::None>
  3415. struct Types {
  3416. typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3417. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3418. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  3419. T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
  3420. };
  3421. template <>
  3422. struct Types<internal::None, internal::None, internal::None, internal::None,
  3423. internal::None, internal::None, internal::None, internal::None,
  3424. internal::None, internal::None, internal::None, internal::None,
  3425. internal::None, internal::None, internal::None, internal::None,
  3426. internal::None, internal::None, internal::None, internal::None,
  3427. internal::None, internal::None, internal::None, internal::None,
  3428. internal::None, internal::None, internal::None, internal::None,
  3429. internal::None, internal::None, internal::None, internal::None,
  3430. internal::None, internal::None, internal::None, internal::None,
  3431. internal::None, internal::None, internal::None, internal::None,
  3432. internal::None, internal::None, internal::None, internal::None,
  3433. internal::None, internal::None, internal::None, internal::None,
  3434. internal::None, internal::None> {
  3435. typedef internal::Types0 type;
  3436. };
  3437. template <typename T1>
  3438. struct Types<T1, internal::None, internal::None, internal::None,
  3439. internal::None, internal::None, internal::None, internal::None,
  3440. internal::None, internal::None, internal::None, internal::None,
  3441. internal::None, internal::None, internal::None, internal::None,
  3442. internal::None, internal::None, internal::None, internal::None,
  3443. internal::None, internal::None, internal::None, internal::None,
  3444. internal::None, internal::None, internal::None, internal::None,
  3445. internal::None, internal::None, internal::None, internal::None,
  3446. internal::None, internal::None, internal::None, internal::None,
  3447. internal::None, internal::None, internal::None, internal::None,
  3448. internal::None, internal::None, internal::None, internal::None,
  3449. internal::None, internal::None, internal::None, internal::None,
  3450. internal::None, internal::None> {
  3451. typedef internal::Types1<T1> type;
  3452. };
  3453. template <typename T1, typename T2>
  3454. struct Types<T1, T2, internal::None, internal::None, internal::None,
  3455. internal::None, internal::None, internal::None, internal::None,
  3456. internal::None, internal::None, internal::None, internal::None,
  3457. internal::None, internal::None, internal::None, internal::None,
  3458. internal::None, internal::None, internal::None, internal::None,
  3459. internal::None, internal::None, internal::None, internal::None,
  3460. internal::None, internal::None, internal::None, internal::None,
  3461. internal::None, internal::None, internal::None, internal::None,
  3462. internal::None, internal::None, internal::None, internal::None,
  3463. internal::None, internal::None, internal::None, internal::None,
  3464. internal::None, internal::None, internal::None, internal::None,
  3465. internal::None, internal::None, internal::None, internal::None,
  3466. internal::None> {
  3467. typedef internal::Types2<T1, T2> type;
  3468. };
  3469. template <typename T1, typename T2, typename T3>
  3470. struct Types<T1, T2, T3, internal::None, internal::None, internal::None,
  3471. internal::None, internal::None, internal::None, internal::None,
  3472. internal::None, internal::None, internal::None, internal::None,
  3473. internal::None, internal::None, internal::None, internal::None,
  3474. internal::None, internal::None, internal::None, internal::None,
  3475. internal::None, internal::None, internal::None, internal::None,
  3476. internal::None, internal::None, internal::None, internal::None,
  3477. internal::None, internal::None, internal::None, internal::None,
  3478. internal::None, internal::None, internal::None, internal::None,
  3479. internal::None, internal::None, internal::None, internal::None,
  3480. internal::None, internal::None, internal::None, internal::None,
  3481. internal::None, internal::None, internal::None, internal::None> {
  3482. typedef internal::Types3<T1, T2, T3> type;
  3483. };
  3484. template <typename T1, typename T2, typename T3, typename T4>
  3485. struct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,
  3486. internal::None, internal::None, internal::None, internal::None,
  3487. internal::None, internal::None, internal::None, internal::None,
  3488. internal::None, internal::None, internal::None, internal::None,
  3489. internal::None, internal::None, internal::None, internal::None,
  3490. internal::None, internal::None, internal::None, internal::None,
  3491. internal::None, internal::None, internal::None, internal::None,
  3492. internal::None, internal::None, internal::None, internal::None,
  3493. internal::None, internal::None, internal::None, internal::None,
  3494. internal::None, internal::None, internal::None, internal::None,
  3495. internal::None, internal::None, internal::None, internal::None,
  3496. internal::None, internal::None, internal::None> {
  3497. typedef internal::Types4<T1, T2, T3, T4> type;
  3498. };
  3499. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  3500. struct Types<T1, T2, T3, T4, T5, internal::None, internal::None,
  3501. internal::None, internal::None, internal::None, internal::None,
  3502. internal::None, internal::None, internal::None, internal::None,
  3503. internal::None, internal::None, internal::None, internal::None,
  3504. internal::None, internal::None, internal::None, internal::None,
  3505. internal::None, internal::None, internal::None, internal::None,
  3506. internal::None, internal::None, internal::None, internal::None,
  3507. internal::None, internal::None, internal::None, internal::None,
  3508. internal::None, internal::None, internal::None, internal::None,
  3509. internal::None, internal::None, internal::None, internal::None,
  3510. internal::None, internal::None, internal::None, internal::None,
  3511. internal::None, internal::None, internal::None> {
  3512. typedef internal::Types5<T1, T2, T3, T4, T5> type;
  3513. };
  3514. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3515. typename T6>
  3516. struct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,
  3517. internal::None, internal::None, internal::None, internal::None,
  3518. internal::None, internal::None, internal::None, internal::None,
  3519. internal::None, internal::None, internal::None, internal::None,
  3520. internal::None, internal::None, internal::None, internal::None,
  3521. internal::None, internal::None, internal::None, internal::None,
  3522. internal::None, internal::None, internal::None, internal::None,
  3523. internal::None, internal::None, internal::None, internal::None,
  3524. internal::None, internal::None, internal::None, internal::None,
  3525. internal::None, internal::None, internal::None, internal::None,
  3526. internal::None, internal::None, internal::None, internal::None,
  3527. internal::None, internal::None> {
  3528. typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
  3529. };
  3530. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3531. typename T6, typename T7>
  3532. struct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,
  3533. internal::None, internal::None, internal::None, internal::None,
  3534. internal::None, internal::None, internal::None, internal::None,
  3535. internal::None, internal::None, internal::None, internal::None,
  3536. internal::None, internal::None, internal::None, internal::None,
  3537. internal::None, internal::None, internal::None, internal::None,
  3538. internal::None, internal::None, internal::None, internal::None,
  3539. internal::None, internal::None, internal::None, internal::None,
  3540. internal::None, internal::None, internal::None, internal::None,
  3541. internal::None, internal::None, internal::None, internal::None,
  3542. internal::None, internal::None, internal::None, internal::None,
  3543. internal::None> {
  3544. typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
  3545. };
  3546. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3547. typename T6, typename T7, typename T8>
  3548. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,
  3549. internal::None, internal::None, internal::None, internal::None,
  3550. internal::None, internal::None, internal::None, internal::None,
  3551. internal::None, internal::None, internal::None, internal::None,
  3552. internal::None, internal::None, internal::None, internal::None,
  3553. internal::None, internal::None, internal::None, internal::None,
  3554. internal::None, internal::None, internal::None, internal::None,
  3555. internal::None, internal::None, internal::None, internal::None,
  3556. internal::None, internal::None, internal::None, internal::None,
  3557. internal::None, internal::None, internal::None, internal::None,
  3558. internal::None, internal::None, internal::None, internal::None> {
  3559. typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
  3560. };
  3561. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3562. typename T6, typename T7, typename T8, typename T9>
  3563. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,
  3564. internal::None, internal::None, internal::None, internal::None,
  3565. internal::None, internal::None, internal::None, internal::None,
  3566. internal::None, internal::None, internal::None, internal::None,
  3567. internal::None, internal::None, internal::None, internal::None,
  3568. internal::None, internal::None, internal::None, internal::None,
  3569. internal::None, internal::None, internal::None, internal::None,
  3570. internal::None, internal::None, internal::None, internal::None,
  3571. internal::None, internal::None, internal::None, internal::None,
  3572. internal::None, internal::None, internal::None, internal::None,
  3573. internal::None, internal::None, internal::None, internal::None> {
  3574. typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
  3575. };
  3576. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3577. typename T6, typename T7, typename T8, typename T9, typename T10>
  3578. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,
  3579. internal::None, internal::None, internal::None, internal::None,
  3580. internal::None, internal::None, internal::None, internal::None,
  3581. internal::None, internal::None, internal::None, internal::None,
  3582. internal::None, internal::None, internal::None, internal::None,
  3583. internal::None, internal::None, internal::None, internal::None,
  3584. internal::None, internal::None, internal::None, internal::None,
  3585. internal::None, internal::None, internal::None, internal::None,
  3586. internal::None, internal::None, internal::None, internal::None,
  3587. internal::None, internal::None, internal::None, internal::None,
  3588. internal::None, internal::None, internal::None> {
  3589. typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
  3590. };
  3591. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3592. typename T6, typename T7, typename T8, typename T9, typename T10,
  3593. typename T11>
  3594. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,
  3595. internal::None, internal::None, internal::None, internal::None,
  3596. internal::None, internal::None, internal::None, internal::None,
  3597. internal::None, internal::None, internal::None, internal::None,
  3598. internal::None, internal::None, internal::None, internal::None,
  3599. internal::None, internal::None, internal::None, internal::None,
  3600. internal::None, internal::None, internal::None, internal::None,
  3601. internal::None, internal::None, internal::None, internal::None,
  3602. internal::None, internal::None, internal::None, internal::None,
  3603. internal::None, internal::None, internal::None, internal::None,
  3604. internal::None, internal::None> {
  3605. typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
  3606. };
  3607. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3608. typename T6, typename T7, typename T8, typename T9, typename T10,
  3609. typename T11, typename T12>
  3610. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,
  3611. internal::None, internal::None, internal::None, internal::None,
  3612. internal::None, internal::None, internal::None, internal::None,
  3613. internal::None, internal::None, internal::None, internal::None,
  3614. internal::None, internal::None, internal::None, internal::None,
  3615. internal::None, internal::None, internal::None, internal::None,
  3616. internal::None, internal::None, internal::None, internal::None,
  3617. internal::None, internal::None, internal::None, internal::None,
  3618. internal::None, internal::None, internal::None, internal::None,
  3619. internal::None, internal::None, internal::None, internal::None,
  3620. internal::None> {
  3621. typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
  3622. T12> type;
  3623. };
  3624. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3625. typename T6, typename T7, typename T8, typename T9, typename T10,
  3626. typename T11, typename T12, typename T13>
  3627. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  3628. internal::None, internal::None, internal::None, internal::None,
  3629. internal::None, internal::None, internal::None, internal::None,
  3630. internal::None, internal::None, internal::None, internal::None,
  3631. internal::None, internal::None, internal::None, internal::None,
  3632. internal::None, internal::None, internal::None, internal::None,
  3633. internal::None, internal::None, internal::None, internal::None,
  3634. internal::None, internal::None, internal::None, internal::None,
  3635. internal::None, internal::None, internal::None, internal::None,
  3636. internal::None, internal::None, internal::None, internal::None,
  3637. internal::None> {
  3638. typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3639. T13> type;
  3640. };
  3641. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3642. typename T6, typename T7, typename T8, typename T9, typename T10,
  3643. typename T11, typename T12, typename T13, typename T14>
  3644. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  3645. internal::None, internal::None, internal::None, internal::None,
  3646. internal::None, internal::None, internal::None, internal::None,
  3647. internal::None, internal::None, internal::None, internal::None,
  3648. internal::None, internal::None, internal::None, internal::None,
  3649. internal::None, internal::None, internal::None, internal::None,
  3650. internal::None, internal::None, internal::None, internal::None,
  3651. internal::None, internal::None, internal::None, internal::None,
  3652. internal::None, internal::None, internal::None, internal::None,
  3653. internal::None, internal::None, internal::None, internal::None> {
  3654. typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3655. T13, T14> type;
  3656. };
  3657. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3658. typename T6, typename T7, typename T8, typename T9, typename T10,
  3659. typename T11, typename T12, typename T13, typename T14, typename T15>
  3660. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3661. internal::None, internal::None, internal::None, internal::None,
  3662. internal::None, internal::None, internal::None, internal::None,
  3663. internal::None, internal::None, internal::None, internal::None,
  3664. internal::None, internal::None, internal::None, internal::None,
  3665. internal::None, internal::None, internal::None, internal::None,
  3666. internal::None, internal::None, internal::None, internal::None,
  3667. internal::None, internal::None, internal::None, internal::None,
  3668. internal::None, internal::None, internal::None, internal::None,
  3669. internal::None, internal::None, internal::None> {
  3670. typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3671. T13, T14, T15> type;
  3672. };
  3673. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3674. typename T6, typename T7, typename T8, typename T9, typename T10,
  3675. typename T11, typename T12, typename T13, typename T14, typename T15,
  3676. typename T16>
  3677. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3678. T16, internal::None, internal::None, internal::None, internal::None,
  3679. internal::None, internal::None, internal::None, internal::None,
  3680. internal::None, internal::None, internal::None, internal::None,
  3681. internal::None, internal::None, internal::None, internal::None,
  3682. internal::None, internal::None, internal::None, internal::None,
  3683. internal::None, internal::None, internal::None, internal::None,
  3684. internal::None, internal::None, internal::None, internal::None,
  3685. internal::None, internal::None, internal::None, internal::None,
  3686. internal::None, internal::None> {
  3687. typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3688. T13, T14, T15, T16> type;
  3689. };
  3690. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3691. typename T6, typename T7, typename T8, typename T9, typename T10,
  3692. typename T11, typename T12, typename T13, typename T14, typename T15,
  3693. typename T16, typename T17>
  3694. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3695. T16, T17, internal::None, internal::None, internal::None, internal::None,
  3696. internal::None, internal::None, internal::None, internal::None,
  3697. internal::None, internal::None, internal::None, internal::None,
  3698. internal::None, internal::None, internal::None, internal::None,
  3699. internal::None, internal::None, internal::None, internal::None,
  3700. internal::None, internal::None, internal::None, internal::None,
  3701. internal::None, internal::None, internal::None, internal::None,
  3702. internal::None, internal::None, internal::None, internal::None,
  3703. internal::None> {
  3704. typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3705. T13, T14, T15, T16, T17> type;
  3706. };
  3707. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3708. typename T6, typename T7, typename T8, typename T9, typename T10,
  3709. typename T11, typename T12, typename T13, typename T14, typename T15,
  3710. typename T16, typename T17, typename T18>
  3711. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3712. T16, T17, T18, internal::None, internal::None, internal::None,
  3713. internal::None, internal::None, internal::None, internal::None,
  3714. internal::None, internal::None, internal::None, internal::None,
  3715. internal::None, internal::None, internal::None, internal::None,
  3716. internal::None, internal::None, internal::None, internal::None,
  3717. internal::None, internal::None, internal::None, internal::None,
  3718. internal::None, internal::None, internal::None, internal::None,
  3719. internal::None, internal::None, internal::None, internal::None,
  3720. internal::None> {
  3721. typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3722. T13, T14, T15, T16, T17, T18> type;
  3723. };
  3724. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3725. typename T6, typename T7, typename T8, typename T9, typename T10,
  3726. typename T11, typename T12, typename T13, typename T14, typename T15,
  3727. typename T16, typename T17, typename T18, typename T19>
  3728. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3729. T16, T17, T18, T19, internal::None, internal::None, internal::None,
  3730. internal::None, internal::None, internal::None, internal::None,
  3731. internal::None, internal::None, internal::None, internal::None,
  3732. internal::None, internal::None, internal::None, internal::None,
  3733. internal::None, internal::None, internal::None, internal::None,
  3734. internal::None, internal::None, internal::None, internal::None,
  3735. internal::None, internal::None, internal::None, internal::None,
  3736. internal::None, internal::None, internal::None, internal::None> {
  3737. typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3738. T13, T14, T15, T16, T17, T18, T19> type;
  3739. };
  3740. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3741. typename T6, typename T7, typename T8, typename T9, typename T10,
  3742. typename T11, typename T12, typename T13, typename T14, typename T15,
  3743. typename T16, typename T17, typename T18, typename T19, typename T20>
  3744. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3745. T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,
  3746. internal::None, internal::None, internal::None, internal::None,
  3747. internal::None, internal::None, internal::None, internal::None,
  3748. internal::None, internal::None, internal::None, internal::None,
  3749. internal::None, internal::None, internal::None, internal::None,
  3750. internal::None, internal::None, internal::None, internal::None,
  3751. internal::None, internal::None, internal::None, internal::None,
  3752. internal::None, internal::None, internal::None> {
  3753. typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3754. T13, T14, T15, T16, T17, T18, T19, T20> type;
  3755. };
  3756. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3757. typename T6, typename T7, typename T8, typename T9, typename T10,
  3758. typename T11, typename T12, typename T13, typename T14, typename T15,
  3759. typename T16, typename T17, typename T18, typename T19, typename T20,
  3760. typename T21>
  3761. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3762. T16, T17, T18, T19, T20, T21, internal::None, internal::None,
  3763. internal::None, internal::None, internal::None, internal::None,
  3764. internal::None, internal::None, internal::None, internal::None,
  3765. internal::None, internal::None, internal::None, internal::None,
  3766. internal::None, internal::None, internal::None, internal::None,
  3767. internal::None, internal::None, internal::None, internal::None,
  3768. internal::None, internal::None, internal::None, internal::None,
  3769. internal::None, internal::None, internal::None> {
  3770. typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3771. T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
  3772. };
  3773. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3774. typename T6, typename T7, typename T8, typename T9, typename T10,
  3775. typename T11, typename T12, typename T13, typename T14, typename T15,
  3776. typename T16, typename T17, typename T18, typename T19, typename T20,
  3777. typename T21, typename T22>
  3778. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3779. T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,
  3780. internal::None, internal::None, internal::None, internal::None,
  3781. internal::None, internal::None, internal::None, internal::None,
  3782. internal::None, internal::None, internal::None, internal::None,
  3783. internal::None, internal::None, internal::None, internal::None,
  3784. internal::None, internal::None, internal::None, internal::None,
  3785. internal::None, internal::None, internal::None, internal::None,
  3786. internal::None, internal::None> {
  3787. typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3788. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
  3789. };
  3790. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3791. typename T6, typename T7, typename T8, typename T9, typename T10,
  3792. typename T11, typename T12, typename T13, typename T14, typename T15,
  3793. typename T16, typename T17, typename T18, typename T19, typename T20,
  3794. typename T21, typename T22, typename T23>
  3795. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3796. T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,
  3797. internal::None, internal::None, internal::None, internal::None,
  3798. internal::None, internal::None, internal::None, internal::None,
  3799. internal::None, internal::None, internal::None, internal::None,
  3800. internal::None, internal::None, internal::None, internal::None,
  3801. internal::None, internal::None, internal::None, internal::None,
  3802. internal::None, internal::None, internal::None, internal::None,
  3803. internal::None> {
  3804. typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3805. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
  3806. };
  3807. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3808. typename T6, typename T7, typename T8, typename T9, typename T10,
  3809. typename T11, typename T12, typename T13, typename T14, typename T15,
  3810. typename T16, typename T17, typename T18, typename T19, typename T20,
  3811. typename T21, typename T22, typename T23, typename T24>
  3812. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3813. T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,
  3814. internal::None, internal::None, internal::None, internal::None,
  3815. internal::None, internal::None, internal::None, internal::None,
  3816. internal::None, internal::None, internal::None, internal::None,
  3817. internal::None, internal::None, internal::None, internal::None,
  3818. internal::None, internal::None, internal::None, internal::None,
  3819. internal::None, internal::None, internal::None, internal::None,
  3820. internal::None> {
  3821. typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3822. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
  3823. };
  3824. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3825. typename T6, typename T7, typename T8, typename T9, typename T10,
  3826. typename T11, typename T12, typename T13, typename T14, typename T15,
  3827. typename T16, typename T17, typename T18, typename T19, typename T20,
  3828. typename T21, typename T22, typename T23, typename T24, typename T25>
  3829. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3830. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,
  3831. internal::None, internal::None, internal::None, internal::None,
  3832. internal::None, internal::None, internal::None, internal::None,
  3833. internal::None, internal::None, internal::None, internal::None,
  3834. internal::None, internal::None, internal::None, internal::None,
  3835. internal::None, internal::None, internal::None, internal::None,
  3836. internal::None, internal::None, internal::None, internal::None> {
  3837. typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3838. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
  3839. };
  3840. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3841. typename T6, typename T7, typename T8, typename T9, typename T10,
  3842. typename T11, typename T12, typename T13, typename T14, typename T15,
  3843. typename T16, typename T17, typename T18, typename T19, typename T20,
  3844. typename T21, typename T22, typename T23, typename T24, typename T25,
  3845. typename T26>
  3846. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3847. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,
  3848. internal::None, internal::None, internal::None, internal::None,
  3849. internal::None, internal::None, internal::None, internal::None,
  3850. internal::None, internal::None, internal::None, internal::None,
  3851. internal::None, internal::None, internal::None, internal::None,
  3852. internal::None, internal::None, internal::None, internal::None,
  3853. internal::None, internal::None, internal::None> {
  3854. typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3855. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,
  3856. T26> type;
  3857. };
  3858. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3859. typename T6, typename T7, typename T8, typename T9, typename T10,
  3860. typename T11, typename T12, typename T13, typename T14, typename T15,
  3861. typename T16, typename T17, typename T18, typename T19, typename T20,
  3862. typename T21, typename T22, typename T23, typename T24, typename T25,
  3863. typename T26, typename T27>
  3864. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3865. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,
  3866. internal::None, internal::None, internal::None, internal::None,
  3867. internal::None, internal::None, internal::None, internal::None,
  3868. internal::None, internal::None, internal::None, internal::None,
  3869. internal::None, internal::None, internal::None, internal::None,
  3870. internal::None, internal::None, internal::None, internal::None,
  3871. internal::None, internal::None> {
  3872. typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3873. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3874. T27> type;
  3875. };
  3876. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3877. typename T6, typename T7, typename T8, typename T9, typename T10,
  3878. typename T11, typename T12, typename T13, typename T14, typename T15,
  3879. typename T16, typename T17, typename T18, typename T19, typename T20,
  3880. typename T21, typename T22, typename T23, typename T24, typename T25,
  3881. typename T26, typename T27, typename T28>
  3882. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3883. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  3884. internal::None, internal::None, internal::None, internal::None,
  3885. internal::None, internal::None, internal::None, internal::None,
  3886. internal::None, internal::None, internal::None, internal::None,
  3887. internal::None, internal::None, internal::None, internal::None,
  3888. internal::None, internal::None, internal::None, internal::None,
  3889. internal::None, internal::None> {
  3890. typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3891. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3892. T27, T28> type;
  3893. };
  3894. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3895. typename T6, typename T7, typename T8, typename T9, typename T10,
  3896. typename T11, typename T12, typename T13, typename T14, typename T15,
  3897. typename T16, typename T17, typename T18, typename T19, typename T20,
  3898. typename T21, typename T22, typename T23, typename T24, typename T25,
  3899. typename T26, typename T27, typename T28, typename T29>
  3900. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3901. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  3902. internal::None, internal::None, internal::None, internal::None,
  3903. internal::None, internal::None, internal::None, internal::None,
  3904. internal::None, internal::None, internal::None, internal::None,
  3905. internal::None, internal::None, internal::None, internal::None,
  3906. internal::None, internal::None, internal::None, internal::None,
  3907. internal::None> {
  3908. typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3909. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3910. T27, T28, T29> type;
  3911. };
  3912. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3913. typename T6, typename T7, typename T8, typename T9, typename T10,
  3914. typename T11, typename T12, typename T13, typename T14, typename T15,
  3915. typename T16, typename T17, typename T18, typename T19, typename T20,
  3916. typename T21, typename T22, typename T23, typename T24, typename T25,
  3917. typename T26, typename T27, typename T28, typename T29, typename T30>
  3918. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3919. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  3920. internal::None, internal::None, internal::None, internal::None,
  3921. internal::None, internal::None, internal::None, internal::None,
  3922. internal::None, internal::None, internal::None, internal::None,
  3923. internal::None, internal::None, internal::None, internal::None,
  3924. internal::None, internal::None, internal::None, internal::None> {
  3925. typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3926. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3927. T27, T28, T29, T30> type;
  3928. };
  3929. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3930. typename T6, typename T7, typename T8, typename T9, typename T10,
  3931. typename T11, typename T12, typename T13, typename T14, typename T15,
  3932. typename T16, typename T17, typename T18, typename T19, typename T20,
  3933. typename T21, typename T22, typename T23, typename T24, typename T25,
  3934. typename T26, typename T27, typename T28, typename T29, typename T30,
  3935. typename T31>
  3936. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3937. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  3938. T31, internal::None, internal::None, internal::None, internal::None,
  3939. internal::None, internal::None, internal::None, internal::None,
  3940. internal::None, internal::None, internal::None, internal::None,
  3941. internal::None, internal::None, internal::None, internal::None,
  3942. internal::None, internal::None, internal::None> {
  3943. typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3944. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3945. T27, T28, T29, T30, T31> type;
  3946. };
  3947. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3948. typename T6, typename T7, typename T8, typename T9, typename T10,
  3949. typename T11, typename T12, typename T13, typename T14, typename T15,
  3950. typename T16, typename T17, typename T18, typename T19, typename T20,
  3951. typename T21, typename T22, typename T23, typename T24, typename T25,
  3952. typename T26, typename T27, typename T28, typename T29, typename T30,
  3953. typename T31, typename T32>
  3954. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3955. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  3956. T31, T32, internal::None, internal::None, internal::None, internal::None,
  3957. internal::None, internal::None, internal::None, internal::None,
  3958. internal::None, internal::None, internal::None, internal::None,
  3959. internal::None, internal::None, internal::None, internal::None,
  3960. internal::None, internal::None> {
  3961. typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3962. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3963. T27, T28, T29, T30, T31, T32> type;
  3964. };
  3965. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3966. typename T6, typename T7, typename T8, typename T9, typename T10,
  3967. typename T11, typename T12, typename T13, typename T14, typename T15,
  3968. typename T16, typename T17, typename T18, typename T19, typename T20,
  3969. typename T21, typename T22, typename T23, typename T24, typename T25,
  3970. typename T26, typename T27, typename T28, typename T29, typename T30,
  3971. typename T31, typename T32, typename T33>
  3972. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3973. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  3974. T31, T32, T33, internal::None, internal::None, internal::None,
  3975. internal::None, internal::None, internal::None, internal::None,
  3976. internal::None, internal::None, internal::None, internal::None,
  3977. internal::None, internal::None, internal::None, internal::None,
  3978. internal::None, internal::None> {
  3979. typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3980. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3981. T27, T28, T29, T30, T31, T32, T33> type;
  3982. };
  3983. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  3984. typename T6, typename T7, typename T8, typename T9, typename T10,
  3985. typename T11, typename T12, typename T13, typename T14, typename T15,
  3986. typename T16, typename T17, typename T18, typename T19, typename T20,
  3987. typename T21, typename T22, typename T23, typename T24, typename T25,
  3988. typename T26, typename T27, typename T28, typename T29, typename T30,
  3989. typename T31, typename T32, typename T33, typename T34>
  3990. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  3991. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  3992. T31, T32, T33, T34, internal::None, internal::None, internal::None,
  3993. internal::None, internal::None, internal::None, internal::None,
  3994. internal::None, internal::None, internal::None, internal::None,
  3995. internal::None, internal::None, internal::None, internal::None,
  3996. internal::None> {
  3997. typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  3998. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  3999. T27, T28, T29, T30, T31, T32, T33, T34> type;
  4000. };
  4001. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4002. typename T6, typename T7, typename T8, typename T9, typename T10,
  4003. typename T11, typename T12, typename T13, typename T14, typename T15,
  4004. typename T16, typename T17, typename T18, typename T19, typename T20,
  4005. typename T21, typename T22, typename T23, typename T24, typename T25,
  4006. typename T26, typename T27, typename T28, typename T29, typename T30,
  4007. typename T31, typename T32, typename T33, typename T34, typename T35>
  4008. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4009. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4010. T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,
  4011. internal::None, internal::None, internal::None, internal::None,
  4012. internal::None, internal::None, internal::None, internal::None,
  4013. internal::None, internal::None, internal::None, internal::None> {
  4014. typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4015. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4016. T27, T28, T29, T30, T31, T32, T33, T34, T35> type;
  4017. };
  4018. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4019. typename T6, typename T7, typename T8, typename T9, typename T10,
  4020. typename T11, typename T12, typename T13, typename T14, typename T15,
  4021. typename T16, typename T17, typename T18, typename T19, typename T20,
  4022. typename T21, typename T22, typename T23, typename T24, typename T25,
  4023. typename T26, typename T27, typename T28, typename T29, typename T30,
  4024. typename T31, typename T32, typename T33, typename T34, typename T35,
  4025. typename T36>
  4026. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4027. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4028. T31, T32, T33, T34, T35, T36, internal::None, internal::None,
  4029. internal::None, internal::None, internal::None, internal::None,
  4030. internal::None, internal::None, internal::None, internal::None,
  4031. internal::None, internal::None, internal::None, internal::None> {
  4032. typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4033. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4034. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
  4035. };
  4036. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4037. typename T6, typename T7, typename T8, typename T9, typename T10,
  4038. typename T11, typename T12, typename T13, typename T14, typename T15,
  4039. typename T16, typename T17, typename T18, typename T19, typename T20,
  4040. typename T21, typename T22, typename T23, typename T24, typename T25,
  4041. typename T26, typename T27, typename T28, typename T29, typename T30,
  4042. typename T31, typename T32, typename T33, typename T34, typename T35,
  4043. typename T36, typename T37>
  4044. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4045. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4046. T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,
  4047. internal::None, internal::None, internal::None, internal::None,
  4048. internal::None, internal::None, internal::None, internal::None,
  4049. internal::None, internal::None, internal::None> {
  4050. typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4051. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4052. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
  4053. };
  4054. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4055. typename T6, typename T7, typename T8, typename T9, typename T10,
  4056. typename T11, typename T12, typename T13, typename T14, typename T15,
  4057. typename T16, typename T17, typename T18, typename T19, typename T20,
  4058. typename T21, typename T22, typename T23, typename T24, typename T25,
  4059. typename T26, typename T27, typename T28, typename T29, typename T30,
  4060. typename T31, typename T32, typename T33, typename T34, typename T35,
  4061. typename T36, typename T37, typename T38>
  4062. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4063. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4064. T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,
  4065. internal::None, internal::None, internal::None, internal::None,
  4066. internal::None, internal::None, internal::None, internal::None,
  4067. internal::None, internal::None> {
  4068. typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4069. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4070. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
  4071. };
  4072. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4073. typename T6, typename T7, typename T8, typename T9, typename T10,
  4074. typename T11, typename T12, typename T13, typename T14, typename T15,
  4075. typename T16, typename T17, typename T18, typename T19, typename T20,
  4076. typename T21, typename T22, typename T23, typename T24, typename T25,
  4077. typename T26, typename T27, typename T28, typename T29, typename T30,
  4078. typename T31, typename T32, typename T33, typename T34, typename T35,
  4079. typename T36, typename T37, typename T38, typename T39>
  4080. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4081. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4082. T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,
  4083. internal::None, internal::None, internal::None, internal::None,
  4084. internal::None, internal::None, internal::None, internal::None,
  4085. internal::None, internal::None> {
  4086. typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4087. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4088. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
  4089. };
  4090. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4091. typename T6, typename T7, typename T8, typename T9, typename T10,
  4092. typename T11, typename T12, typename T13, typename T14, typename T15,
  4093. typename T16, typename T17, typename T18, typename T19, typename T20,
  4094. typename T21, typename T22, typename T23, typename T24, typename T25,
  4095. typename T26, typename T27, typename T28, typename T29, typename T30,
  4096. typename T31, typename T32, typename T33, typename T34, typename T35,
  4097. typename T36, typename T37, typename T38, typename T39, typename T40>
  4098. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4099. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4100. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,
  4101. internal::None, internal::None, internal::None, internal::None,
  4102. internal::None, internal::None, internal::None, internal::None,
  4103. internal::None> {
  4104. typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4105. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4106. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,
  4107. T40> type;
  4108. };
  4109. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4110. typename T6, typename T7, typename T8, typename T9, typename T10,
  4111. typename T11, typename T12, typename T13, typename T14, typename T15,
  4112. typename T16, typename T17, typename T18, typename T19, typename T20,
  4113. typename T21, typename T22, typename T23, typename T24, typename T25,
  4114. typename T26, typename T27, typename T28, typename T29, typename T30,
  4115. typename T31, typename T32, typename T33, typename T34, typename T35,
  4116. typename T36, typename T37, typename T38, typename T39, typename T40,
  4117. typename T41>
  4118. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4119. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4120. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,
  4121. internal::None, internal::None, internal::None, internal::None,
  4122. internal::None, internal::None, internal::None, internal::None> {
  4123. typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4124. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4125. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4126. T41> type;
  4127. };
  4128. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4129. typename T6, typename T7, typename T8, typename T9, typename T10,
  4130. typename T11, typename T12, typename T13, typename T14, typename T15,
  4131. typename T16, typename T17, typename T18, typename T19, typename T20,
  4132. typename T21, typename T22, typename T23, typename T24, typename T25,
  4133. typename T26, typename T27, typename T28, typename T29, typename T30,
  4134. typename T31, typename T32, typename T33, typename T34, typename T35,
  4135. typename T36, typename T37, typename T38, typename T39, typename T40,
  4136. typename T41, typename T42>
  4137. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4138. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4139. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,
  4140. internal::None, internal::None, internal::None, internal::None,
  4141. internal::None, internal::None, internal::None> {
  4142. typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4143. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4144. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4145. T41, T42> type;
  4146. };
  4147. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4148. typename T6, typename T7, typename T8, typename T9, typename T10,
  4149. typename T11, typename T12, typename T13, typename T14, typename T15,
  4150. typename T16, typename T17, typename T18, typename T19, typename T20,
  4151. typename T21, typename T22, typename T23, typename T24, typename T25,
  4152. typename T26, typename T27, typename T28, typename T29, typename T30,
  4153. typename T31, typename T32, typename T33, typename T34, typename T35,
  4154. typename T36, typename T37, typename T38, typename T39, typename T40,
  4155. typename T41, typename T42, typename T43>
  4156. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4157. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4158. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  4159. internal::None, internal::None, internal::None, internal::None,
  4160. internal::None, internal::None, internal::None> {
  4161. typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4162. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4163. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4164. T41, T42, T43> type;
  4165. };
  4166. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4167. typename T6, typename T7, typename T8, typename T9, typename T10,
  4168. typename T11, typename T12, typename T13, typename T14, typename T15,
  4169. typename T16, typename T17, typename T18, typename T19, typename T20,
  4170. typename T21, typename T22, typename T23, typename T24, typename T25,
  4171. typename T26, typename T27, typename T28, typename T29, typename T30,
  4172. typename T31, typename T32, typename T33, typename T34, typename T35,
  4173. typename T36, typename T37, typename T38, typename T39, typename T40,
  4174. typename T41, typename T42, typename T43, typename T44>
  4175. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4176. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4177. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  4178. internal::None, internal::None, internal::None, internal::None,
  4179. internal::None, internal::None> {
  4180. typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4181. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4182. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4183. T41, T42, T43, T44> type;
  4184. };
  4185. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4186. typename T6, typename T7, typename T8, typename T9, typename T10,
  4187. typename T11, typename T12, typename T13, typename T14, typename T15,
  4188. typename T16, typename T17, typename T18, typename T19, typename T20,
  4189. typename T21, typename T22, typename T23, typename T24, typename T25,
  4190. typename T26, typename T27, typename T28, typename T29, typename T30,
  4191. typename T31, typename T32, typename T33, typename T34, typename T35,
  4192. typename T36, typename T37, typename T38, typename T39, typename T40,
  4193. typename T41, typename T42, typename T43, typename T44, typename T45>
  4194. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4195. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4196. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
  4197. internal::None, internal::None, internal::None, internal::None,
  4198. internal::None> {
  4199. typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4200. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4201. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4202. T41, T42, T43, T44, T45> type;
  4203. };
  4204. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4205. typename T6, typename T7, typename T8, typename T9, typename T10,
  4206. typename T11, typename T12, typename T13, typename T14, typename T15,
  4207. typename T16, typename T17, typename T18, typename T19, typename T20,
  4208. typename T21, typename T22, typename T23, typename T24, typename T25,
  4209. typename T26, typename T27, typename T28, typename T29, typename T30,
  4210. typename T31, typename T32, typename T33, typename T34, typename T35,
  4211. typename T36, typename T37, typename T38, typename T39, typename T40,
  4212. typename T41, typename T42, typename T43, typename T44, typename T45,
  4213. typename T46>
  4214. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4215. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4216. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
  4217. T46, internal::None, internal::None, internal::None, internal::None> {
  4218. typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4219. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4220. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4221. T41, T42, T43, T44, T45, T46> type;
  4222. };
  4223. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4224. typename T6, typename T7, typename T8, typename T9, typename T10,
  4225. typename T11, typename T12, typename T13, typename T14, typename T15,
  4226. typename T16, typename T17, typename T18, typename T19, typename T20,
  4227. typename T21, typename T22, typename T23, typename T24, typename T25,
  4228. typename T26, typename T27, typename T28, typename T29, typename T30,
  4229. typename T31, typename T32, typename T33, typename T34, typename T35,
  4230. typename T36, typename T37, typename T38, typename T39, typename T40,
  4231. typename T41, typename T42, typename T43, typename T44, typename T45,
  4232. typename T46, typename T47>
  4233. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4234. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4235. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
  4236. T46, T47, internal::None, internal::None, internal::None> {
  4237. typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4238. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4239. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4240. T41, T42, T43, T44, T45, T46, T47> type;
  4241. };
  4242. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4243. typename T6, typename T7, typename T8, typename T9, typename T10,
  4244. typename T11, typename T12, typename T13, typename T14, typename T15,
  4245. typename T16, typename T17, typename T18, typename T19, typename T20,
  4246. typename T21, typename T22, typename T23, typename T24, typename T25,
  4247. typename T26, typename T27, typename T28, typename T29, typename T30,
  4248. typename T31, typename T32, typename T33, typename T34, typename T35,
  4249. typename T36, typename T37, typename T38, typename T39, typename T40,
  4250. typename T41, typename T42, typename T43, typename T44, typename T45,
  4251. typename T46, typename T47, typename T48>
  4252. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4253. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4254. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
  4255. T46, T47, T48, internal::None, internal::None> {
  4256. typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4257. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4258. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4259. T41, T42, T43, T44, T45, T46, T47, T48> type;
  4260. };
  4261. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  4262. typename T6, typename T7, typename T8, typename T9, typename T10,
  4263. typename T11, typename T12, typename T13, typename T14, typename T15,
  4264. typename T16, typename T17, typename T18, typename T19, typename T20,
  4265. typename T21, typename T22, typename T23, typename T24, typename T25,
  4266. typename T26, typename T27, typename T28, typename T29, typename T30,
  4267. typename T31, typename T32, typename T33, typename T34, typename T35,
  4268. typename T36, typename T37, typename T38, typename T39, typename T40,
  4269. typename T41, typename T42, typename T43, typename T44, typename T45,
  4270. typename T46, typename T47, typename T48, typename T49>
  4271. struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
  4272. T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,
  4273. T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
  4274. T46, T47, T48, T49, internal::None> {
  4275. typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  4276. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  4277. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  4278. T41, T42, T43, T44, T45, T46, T47, T48, T49> type;
  4279. };
  4280. namespace internal {
  4281. # define GTEST_TEMPLATE_ template <typename T> class
  4282. // The template "selector" struct TemplateSel<Tmpl> is used to
  4283. // represent Tmpl, which must be a class template with one type
  4284. // parameter, as a type. TemplateSel<Tmpl>::Bind<T>::type is defined
  4285. // as the type Tmpl<T>. This allows us to actually instantiate the
  4286. // template "selected" by TemplateSel<Tmpl>.
  4287. //
  4288. // This trick is necessary for simulating typedef for class templates,
  4289. // which C++ doesn't support directly.
  4290. template <GTEST_TEMPLATE_ Tmpl>
  4291. struct TemplateSel {
  4292. template <typename T>
  4293. struct Bind {
  4294. typedef Tmpl<T> type;
  4295. };
  4296. };
  4297. # define GTEST_BIND_(TmplSel, T) \
  4298. TmplSel::template Bind<T>::type
  4299. // A unique struct template used as the default value for the
  4300. // arguments of class template Templates. This allows us to simulate
  4301. // variadic templates (e.g. Templates<int>, Templates<int, double>,
  4302. // and etc), which C++ doesn't support directly.
  4303. template <typename T>
  4304. struct NoneT {};
  4305. // The following family of struct and struct templates are used to
  4306. // represent template lists. In particular, TemplatesN<T1, T2, ...,
  4307. // TN> represents a list of N templates (T1, T2, ..., and TN). Except
  4308. // for Templates0, every struct in the family has two member types:
  4309. // Head for the selector of the first template in the list, and Tail
  4310. // for the rest of the list.
  4311. // The empty template list.
  4312. struct Templates0 {};
  4313. // Template lists of length 1, 2, 3, and so on.
  4314. template <GTEST_TEMPLATE_ T1>
  4315. struct Templates1 {
  4316. typedef TemplateSel<T1> Head;
  4317. typedef Templates0 Tail;
  4318. };
  4319. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
  4320. struct Templates2 {
  4321. typedef TemplateSel<T1> Head;
  4322. typedef Templates1<T2> Tail;
  4323. };
  4324. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
  4325. struct Templates3 {
  4326. typedef TemplateSel<T1> Head;
  4327. typedef Templates2<T2, T3> Tail;
  4328. };
  4329. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4330. GTEST_TEMPLATE_ T4>
  4331. struct Templates4 {
  4332. typedef TemplateSel<T1> Head;
  4333. typedef Templates3<T2, T3, T4> Tail;
  4334. };
  4335. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4336. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
  4337. struct Templates5 {
  4338. typedef TemplateSel<T1> Head;
  4339. typedef Templates4<T2, T3, T4, T5> Tail;
  4340. };
  4341. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4342. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
  4343. struct Templates6 {
  4344. typedef TemplateSel<T1> Head;
  4345. typedef Templates5<T2, T3, T4, T5, T6> Tail;
  4346. };
  4347. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4348. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4349. GTEST_TEMPLATE_ T7>
  4350. struct Templates7 {
  4351. typedef TemplateSel<T1> Head;
  4352. typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;
  4353. };
  4354. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4355. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4356. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
  4357. struct Templates8 {
  4358. typedef TemplateSel<T1> Head;
  4359. typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;
  4360. };
  4361. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4362. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4363. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
  4364. struct Templates9 {
  4365. typedef TemplateSel<T1> Head;
  4366. typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
  4367. };
  4368. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4369. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4370. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4371. GTEST_TEMPLATE_ T10>
  4372. struct Templates10 {
  4373. typedef TemplateSel<T1> Head;
  4374. typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
  4375. };
  4376. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4377. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4378. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4379. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
  4380. struct Templates11 {
  4381. typedef TemplateSel<T1> Head;
  4382. typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
  4383. };
  4384. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4385. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4386. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4387. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
  4388. struct Templates12 {
  4389. typedef TemplateSel<T1> Head;
  4390. typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
  4391. };
  4392. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4393. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4394. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4395. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4396. GTEST_TEMPLATE_ T13>
  4397. struct Templates13 {
  4398. typedef TemplateSel<T1> Head;
  4399. typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
  4400. };
  4401. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4402. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4403. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4404. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4405. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
  4406. struct Templates14 {
  4407. typedef TemplateSel<T1> Head;
  4408. typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  4409. T14> Tail;
  4410. };
  4411. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4412. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4413. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4414. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4415. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
  4416. struct Templates15 {
  4417. typedef TemplateSel<T1> Head;
  4418. typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4419. T15> Tail;
  4420. };
  4421. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4422. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4423. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4424. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4425. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4426. GTEST_TEMPLATE_ T16>
  4427. struct Templates16 {
  4428. typedef TemplateSel<T1> Head;
  4429. typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4430. T15, T16> Tail;
  4431. };
  4432. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4433. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4434. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4435. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4436. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4437. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
  4438. struct Templates17 {
  4439. typedef TemplateSel<T1> Head;
  4440. typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4441. T15, T16, T17> Tail;
  4442. };
  4443. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4444. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4445. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4446. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4447. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4448. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
  4449. struct Templates18 {
  4450. typedef TemplateSel<T1> Head;
  4451. typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4452. T15, T16, T17, T18> Tail;
  4453. };
  4454. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4455. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4456. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4457. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4458. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4459. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4460. GTEST_TEMPLATE_ T19>
  4461. struct Templates19 {
  4462. typedef TemplateSel<T1> Head;
  4463. typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4464. T15, T16, T17, T18, T19> Tail;
  4465. };
  4466. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4467. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4468. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4469. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4470. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4471. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4472. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
  4473. struct Templates20 {
  4474. typedef TemplateSel<T1> Head;
  4475. typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4476. T15, T16, T17, T18, T19, T20> Tail;
  4477. };
  4478. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4479. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4480. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4481. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4482. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4483. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4484. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
  4485. struct Templates21 {
  4486. typedef TemplateSel<T1> Head;
  4487. typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4488. T15, T16, T17, T18, T19, T20, T21> Tail;
  4489. };
  4490. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4491. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4492. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4493. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4494. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4495. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4496. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4497. GTEST_TEMPLATE_ T22>
  4498. struct Templates22 {
  4499. typedef TemplateSel<T1> Head;
  4500. typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4501. T15, T16, T17, T18, T19, T20, T21, T22> Tail;
  4502. };
  4503. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4504. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4505. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4506. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4507. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4508. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4509. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4510. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
  4511. struct Templates23 {
  4512. typedef TemplateSel<T1> Head;
  4513. typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4514. T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;
  4515. };
  4516. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4517. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4518. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4519. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4520. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4521. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4522. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4523. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
  4524. struct Templates24 {
  4525. typedef TemplateSel<T1> Head;
  4526. typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4527. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
  4528. };
  4529. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4530. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4531. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4532. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4533. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4534. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4535. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4536. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4537. GTEST_TEMPLATE_ T25>
  4538. struct Templates25 {
  4539. typedef TemplateSel<T1> Head;
  4540. typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4541. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
  4542. };
  4543. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4544. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4545. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4546. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4547. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4548. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4549. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4550. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4551. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
  4552. struct Templates26 {
  4553. typedef TemplateSel<T1> Head;
  4554. typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4555. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
  4556. };
  4557. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4558. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4559. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4560. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4561. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4562. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4563. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4564. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4565. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
  4566. struct Templates27 {
  4567. typedef TemplateSel<T1> Head;
  4568. typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4569. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
  4570. };
  4571. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4572. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4573. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4574. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4575. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4576. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4577. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4578. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4579. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4580. GTEST_TEMPLATE_ T28>
  4581. struct Templates28 {
  4582. typedef TemplateSel<T1> Head;
  4583. typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4584. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  4585. T28> Tail;
  4586. };
  4587. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4588. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4589. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4590. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4591. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4592. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4593. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4594. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4595. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4596. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
  4597. struct Templates29 {
  4598. typedef TemplateSel<T1> Head;
  4599. typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4600. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4601. T29> Tail;
  4602. };
  4603. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4604. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4605. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4606. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4607. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4608. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4609. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4610. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4611. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4612. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
  4613. struct Templates30 {
  4614. typedef TemplateSel<T1> Head;
  4615. typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4616. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4617. T29, T30> Tail;
  4618. };
  4619. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4620. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4621. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4622. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4623. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4624. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4625. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4626. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4627. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4628. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4629. GTEST_TEMPLATE_ T31>
  4630. struct Templates31 {
  4631. typedef TemplateSel<T1> Head;
  4632. typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4633. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4634. T29, T30, T31> Tail;
  4635. };
  4636. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4637. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4638. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4639. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4640. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4641. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4642. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4643. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4644. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4645. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4646. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
  4647. struct Templates32 {
  4648. typedef TemplateSel<T1> Head;
  4649. typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4650. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4651. T29, T30, T31, T32> Tail;
  4652. };
  4653. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4654. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4655. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4656. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4657. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4658. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4659. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4660. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4661. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4662. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4663. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
  4664. struct Templates33 {
  4665. typedef TemplateSel<T1> Head;
  4666. typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4667. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4668. T29, T30, T31, T32, T33> Tail;
  4669. };
  4670. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4671. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4672. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4673. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4674. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4675. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4676. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4677. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4678. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4679. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4680. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4681. GTEST_TEMPLATE_ T34>
  4682. struct Templates34 {
  4683. typedef TemplateSel<T1> Head;
  4684. typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4685. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4686. T29, T30, T31, T32, T33, T34> Tail;
  4687. };
  4688. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4689. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4690. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4691. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4692. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4693. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4694. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4695. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4696. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4697. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4698. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4699. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
  4700. struct Templates35 {
  4701. typedef TemplateSel<T1> Head;
  4702. typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4703. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4704. T29, T30, T31, T32, T33, T34, T35> Tail;
  4705. };
  4706. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4707. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4708. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4709. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4710. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4711. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4712. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4713. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4714. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4715. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4716. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4717. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
  4718. struct Templates36 {
  4719. typedef TemplateSel<T1> Head;
  4720. typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4721. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4722. T29, T30, T31, T32, T33, T34, T35, T36> Tail;
  4723. };
  4724. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4725. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4726. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4727. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4728. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4729. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4730. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4731. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4732. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4733. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4734. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4735. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4736. GTEST_TEMPLATE_ T37>
  4737. struct Templates37 {
  4738. typedef TemplateSel<T1> Head;
  4739. typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4740. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4741. T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;
  4742. };
  4743. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4744. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4745. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4746. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4747. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4748. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4749. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4750. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4751. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4752. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4753. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4754. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4755. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
  4756. struct Templates38 {
  4757. typedef TemplateSel<T1> Head;
  4758. typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4759. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4760. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
  4761. };
  4762. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4763. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4764. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4765. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4766. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4767. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4768. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4769. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4770. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4771. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4772. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4773. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4774. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
  4775. struct Templates39 {
  4776. typedef TemplateSel<T1> Head;
  4777. typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4778. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4779. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
  4780. };
  4781. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4782. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4783. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4784. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4785. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4786. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4787. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4788. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4789. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4790. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4791. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4792. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4793. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4794. GTEST_TEMPLATE_ T40>
  4795. struct Templates40 {
  4796. typedef TemplateSel<T1> Head;
  4797. typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4798. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4799. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
  4800. };
  4801. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4802. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4803. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4804. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4805. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4806. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4807. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4808. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4809. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4810. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4811. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4812. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4813. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4814. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
  4815. struct Templates41 {
  4816. typedef TemplateSel<T1> Head;
  4817. typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4818. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4819. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
  4820. };
  4821. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4822. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4823. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4824. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4825. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4826. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4827. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4828. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4829. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4830. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4831. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4832. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4833. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4834. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
  4835. struct Templates42 {
  4836. typedef TemplateSel<T1> Head;
  4837. typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4838. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4839. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  4840. T42> Tail;
  4841. };
  4842. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4843. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4844. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4845. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4846. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4847. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4848. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4849. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4850. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4851. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4852. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4853. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4854. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4855. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4856. GTEST_TEMPLATE_ T43>
  4857. struct Templates43 {
  4858. typedef TemplateSel<T1> Head;
  4859. typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4860. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4861. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4862. T43> Tail;
  4863. };
  4864. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4865. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4866. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4867. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4868. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4869. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4870. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4871. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4872. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4873. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4874. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4875. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4876. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4877. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4878. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
  4879. struct Templates44 {
  4880. typedef TemplateSel<T1> Head;
  4881. typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4882. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4883. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4884. T43, T44> Tail;
  4885. };
  4886. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4887. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4888. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4889. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4890. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4891. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4892. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4893. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4894. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4895. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4896. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4897. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4898. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4899. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4900. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
  4901. struct Templates45 {
  4902. typedef TemplateSel<T1> Head;
  4903. typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4904. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4905. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4906. T43, T44, T45> Tail;
  4907. };
  4908. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4909. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4910. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4911. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4912. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4913. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4914. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4915. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4916. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4917. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4918. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4919. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4920. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4921. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4922. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  4923. GTEST_TEMPLATE_ T46>
  4924. struct Templates46 {
  4925. typedef TemplateSel<T1> Head;
  4926. typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4927. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4928. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4929. T43, T44, T45, T46> Tail;
  4930. };
  4931. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4932. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4933. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4934. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4935. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4936. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4937. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4938. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4939. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4940. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4941. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4942. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4943. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4944. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4945. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  4946. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
  4947. struct Templates47 {
  4948. typedef TemplateSel<T1> Head;
  4949. typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4950. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4951. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4952. T43, T44, T45, T46, T47> Tail;
  4953. };
  4954. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4955. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4956. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4957. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4958. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4959. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4960. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4961. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4962. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4963. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4964. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4965. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4966. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4967. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4968. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  4969. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
  4970. struct Templates48 {
  4971. typedef TemplateSel<T1> Head;
  4972. typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4973. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4974. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4975. T43, T44, T45, T46, T47, T48> Tail;
  4976. };
  4977. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  4978. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  4979. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  4980. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  4981. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  4982. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  4983. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  4984. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  4985. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  4986. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  4987. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  4988. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  4989. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  4990. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  4991. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  4992. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
  4993. GTEST_TEMPLATE_ T49>
  4994. struct Templates49 {
  4995. typedef TemplateSel<T1> Head;
  4996. typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  4997. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  4998. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  4999. T43, T44, T45, T46, T47, T48, T49> Tail;
  5000. };
  5001. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5002. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5003. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5004. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5005. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5006. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5007. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5008. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5009. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5010. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5011. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5012. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5013. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5014. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5015. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  5016. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
  5017. GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>
  5018. struct Templates50 {
  5019. typedef TemplateSel<T1> Head;
  5020. typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5021. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  5022. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
  5023. T43, T44, T45, T46, T47, T48, T49, T50> Tail;
  5024. };
  5025. // We don't want to require the users to write TemplatesN<...> directly,
  5026. // as that would require them to count the length. Templates<...> is much
  5027. // easier to write, but generates horrible messages when there is a
  5028. // compiler error, as gcc insists on printing out each template
  5029. // argument, even if it has the default value (this means Templates<list>
  5030. // will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
  5031. // errors).
  5032. //
  5033. // Our solution is to combine the best part of the two approaches: a
  5034. // user would write Templates<T1, ..., TN>, and Google Test will translate
  5035. // that to TemplatesN<T1, ..., TN> internally to make error messages
  5036. // readable. The translation is done by the 'type' member of the
  5037. // Templates template.
  5038. template <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,
  5039. GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,
  5040. GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,
  5041. GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,
  5042. GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,
  5043. GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,
  5044. GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,
  5045. GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,
  5046. GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,
  5047. GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,
  5048. GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,
  5049. GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,
  5050. GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,
  5051. GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,
  5052. GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,
  5053. GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,
  5054. GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,
  5055. GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,
  5056. GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,
  5057. GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,
  5058. GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,
  5059. GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,
  5060. GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,
  5061. GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,
  5062. GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>
  5063. struct Templates {
  5064. typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5065. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5066. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5067. T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
  5068. };
  5069. template <>
  5070. struct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5071. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5072. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5073. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5074. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5075. NoneT> {
  5076. typedef Templates0 type;
  5077. };
  5078. template <GTEST_TEMPLATE_ T1>
  5079. struct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5080. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5081. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5082. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5083. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5084. NoneT> {
  5085. typedef Templates1<T1> type;
  5086. };
  5087. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>
  5088. struct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5089. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5090. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5091. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5092. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5093. NoneT> {
  5094. typedef Templates2<T1, T2> type;
  5095. };
  5096. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>
  5097. struct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5098. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5099. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5100. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5101. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5102. typedef Templates3<T1, T2, T3> type;
  5103. };
  5104. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5105. GTEST_TEMPLATE_ T4>
  5106. struct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5107. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5108. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5109. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5110. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5111. typedef Templates4<T1, T2, T3, T4> type;
  5112. };
  5113. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5114. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>
  5115. struct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5116. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5117. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5118. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5119. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5120. typedef Templates5<T1, T2, T3, T4, T5> type;
  5121. };
  5122. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5123. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>
  5124. struct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,
  5125. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5126. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5127. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5128. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5129. typedef Templates6<T1, T2, T3, T4, T5, T6> type;
  5130. };
  5131. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5132. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5133. GTEST_TEMPLATE_ T7>
  5134. struct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,
  5135. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5136. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5137. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5138. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5139. typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;
  5140. };
  5141. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5142. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5143. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>
  5144. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,
  5145. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5146. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5147. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5148. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5149. typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;
  5150. };
  5151. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5152. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5153. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>
  5154. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,
  5155. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5156. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5157. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5158. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5159. typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
  5160. };
  5161. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5162. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5163. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5164. GTEST_TEMPLATE_ T10>
  5165. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,
  5166. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5167. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5168. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5169. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5170. typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
  5171. };
  5172. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5173. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5174. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5175. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>
  5176. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,
  5177. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5178. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5179. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5180. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5181. typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
  5182. };
  5183. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5184. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5185. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5186. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>
  5187. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,
  5188. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5189. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5190. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5191. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5192. typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;
  5193. };
  5194. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5195. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5196. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5197. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5198. GTEST_TEMPLATE_ T13>
  5199. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,
  5200. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5201. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5202. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5203. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5204. typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  5205. T13> type;
  5206. };
  5207. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5208. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5209. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5210. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5211. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>
  5212. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5213. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5214. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5215. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5216. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5217. typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5218. T14> type;
  5219. };
  5220. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5221. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5222. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5223. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5224. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>
  5225. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5226. T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5227. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5228. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5229. NoneT, NoneT, NoneT, NoneT, NoneT> {
  5230. typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5231. T14, T15> type;
  5232. };
  5233. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5234. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5235. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5236. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5237. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5238. GTEST_TEMPLATE_ T16>
  5239. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5240. T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5241. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5242. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5243. NoneT, NoneT, NoneT, NoneT, NoneT> {
  5244. typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5245. T14, T15, T16> type;
  5246. };
  5247. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5248. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5249. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5250. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5251. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5252. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>
  5253. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5254. T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5255. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5256. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5257. NoneT, NoneT, NoneT, NoneT, NoneT> {
  5258. typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5259. T14, T15, T16, T17> type;
  5260. };
  5261. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5262. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5263. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5264. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5265. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5266. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>
  5267. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5268. T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5269. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5270. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5271. NoneT, NoneT, NoneT, NoneT> {
  5272. typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5273. T14, T15, T16, T17, T18> type;
  5274. };
  5275. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5276. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5277. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5278. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5279. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5280. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5281. GTEST_TEMPLATE_ T19>
  5282. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5283. T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5284. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5285. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5286. NoneT, NoneT, NoneT, NoneT> {
  5287. typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5288. T14, T15, T16, T17, T18, T19> type;
  5289. };
  5290. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5291. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5292. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5293. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5294. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5295. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5296. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>
  5297. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5298. T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5299. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5300. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5301. NoneT, NoneT, NoneT, NoneT> {
  5302. typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5303. T14, T15, T16, T17, T18, T19, T20> type;
  5304. };
  5305. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5306. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5307. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5308. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5309. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5310. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5311. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>
  5312. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5313. T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,
  5314. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5315. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5316. NoneT, NoneT, NoneT, NoneT> {
  5317. typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5318. T14, T15, T16, T17, T18, T19, T20, T21> type;
  5319. };
  5320. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5321. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5322. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5323. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5324. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5325. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5326. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5327. GTEST_TEMPLATE_ T22>
  5328. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5329. T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,
  5330. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5331. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5332. NoneT, NoneT, NoneT> {
  5333. typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5334. T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
  5335. };
  5336. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5337. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5338. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5339. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5340. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5341. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5342. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5343. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>
  5344. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5345. T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,
  5346. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5347. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5348. NoneT, NoneT, NoneT> {
  5349. typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5350. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;
  5351. };
  5352. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5353. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5354. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5355. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5356. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5357. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5358. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5359. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>
  5360. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5361. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,
  5362. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5363. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5364. NoneT, NoneT, NoneT> {
  5365. typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5366. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;
  5367. };
  5368. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5369. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5370. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5371. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5372. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5373. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5374. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5375. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5376. GTEST_TEMPLATE_ T25>
  5377. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5378. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,
  5379. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5380. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5381. NoneT, NoneT> {
  5382. typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5383. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;
  5384. };
  5385. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5386. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5387. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5388. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5389. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5390. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5391. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5392. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5393. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>
  5394. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5395. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,
  5396. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5397. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5398. NoneT, NoneT> {
  5399. typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5400. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;
  5401. };
  5402. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5403. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5404. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5405. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5406. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5407. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5408. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5409. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5410. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>
  5411. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5412. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,
  5413. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5414. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5415. NoneT, NoneT> {
  5416. typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5417. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  5418. T27> type;
  5419. };
  5420. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5421. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5422. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5423. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5424. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5425. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5426. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5427. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5428. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5429. GTEST_TEMPLATE_ T28>
  5430. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5431. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  5432. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5433. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5434. NoneT, NoneT> {
  5435. typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5436. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5437. T28> type;
  5438. };
  5439. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5440. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5441. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5442. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5443. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5444. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5445. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5446. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5447. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5448. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>
  5449. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5450. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5451. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5452. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5453. NoneT> {
  5454. typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5455. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5456. T28, T29> type;
  5457. };
  5458. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5459. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5460. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5461. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5462. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5463. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5464. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5465. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5466. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5467. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>
  5468. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5469. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5470. T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5471. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5472. typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5473. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5474. T28, T29, T30> type;
  5475. };
  5476. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5477. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5478. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5479. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5480. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5481. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5482. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5483. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5484. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5485. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5486. GTEST_TEMPLATE_ T31>
  5487. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5488. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5489. T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5490. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5491. typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5492. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5493. T28, T29, T30, T31> type;
  5494. };
  5495. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5496. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5497. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5498. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5499. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5500. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5501. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5502. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5503. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5504. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5505. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>
  5506. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5507. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5508. T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5509. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5510. typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5511. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5512. T28, T29, T30, T31, T32> type;
  5513. };
  5514. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5515. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5516. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5517. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5518. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5519. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5520. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5521. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5522. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5523. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5524. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>
  5525. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5526. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5527. T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5528. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5529. typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5530. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5531. T28, T29, T30, T31, T32, T33> type;
  5532. };
  5533. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5534. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5535. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5536. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5537. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5538. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5539. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5540. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5541. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5542. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5543. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5544. GTEST_TEMPLATE_ T34>
  5545. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5546. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5547. T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5548. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5549. typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5550. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5551. T28, T29, T30, T31, T32, T33, T34> type;
  5552. };
  5553. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5554. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5555. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5556. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5557. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5558. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5559. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5560. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5561. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5562. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5563. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5564. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>
  5565. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5566. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5567. T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,
  5568. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5569. typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5570. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5571. T28, T29, T30, T31, T32, T33, T34, T35> type;
  5572. };
  5573. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5574. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5575. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5576. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5577. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5578. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5579. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5580. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5581. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5582. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5583. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5584. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>
  5585. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5586. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5587. T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,
  5588. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5589. typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5590. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5591. T28, T29, T30, T31, T32, T33, T34, T35, T36> type;
  5592. };
  5593. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5594. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5595. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5596. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5597. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5598. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5599. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5600. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5601. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5602. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5603. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5604. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5605. GTEST_TEMPLATE_ T37>
  5606. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5607. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5608. T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,
  5609. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5610. typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5611. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5612. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;
  5613. };
  5614. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5615. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5616. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5617. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5618. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5619. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5620. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5621. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5622. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5623. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5624. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5625. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5626. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>
  5627. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5628. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5629. T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,
  5630. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5631. typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5632. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5633. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;
  5634. };
  5635. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5636. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5637. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5638. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5639. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5640. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5641. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5642. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5643. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5644. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5645. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5646. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5647. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>
  5648. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5649. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5650. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,
  5651. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5652. typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5653. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5654. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;
  5655. };
  5656. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5657. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5658. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5659. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5660. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5661. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5662. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5663. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5664. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5665. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5666. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5667. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5668. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5669. GTEST_TEMPLATE_ T40>
  5670. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5671. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5672. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,
  5673. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5674. typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5675. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5676. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;
  5677. };
  5678. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5679. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5680. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5681. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5682. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5683. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5684. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5685. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5686. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5687. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5688. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5689. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5690. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5691. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>
  5692. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5693. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5694. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,
  5695. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5696. typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5697. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5698. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  5699. T41> type;
  5700. };
  5701. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5702. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5703. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5704. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5705. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5706. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5707. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5708. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5709. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5710. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5711. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5712. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5713. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5714. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>
  5715. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5716. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5717. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,
  5718. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5719. typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5720. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5721. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5722. T42> type;
  5723. };
  5724. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5725. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5726. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5727. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5728. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5729. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5730. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5731. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5732. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5733. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5734. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5735. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5736. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5737. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5738. GTEST_TEMPLATE_ T43>
  5739. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5740. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5741. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  5742. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5743. typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5744. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5745. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5746. T42, T43> type;
  5747. };
  5748. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5749. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5750. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5751. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5752. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5753. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5754. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5755. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5756. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5757. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5758. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5759. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5760. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5761. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5762. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>
  5763. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5764. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5765. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5766. NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5767. typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5768. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5769. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5770. T42, T43, T44> type;
  5771. };
  5772. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5773. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5774. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5775. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5776. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5777. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5778. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5779. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5780. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5781. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5782. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5783. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5784. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5785. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5786. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>
  5787. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5788. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5789. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5790. T45, NoneT, NoneT, NoneT, NoneT, NoneT> {
  5791. typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5792. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5793. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5794. T42, T43, T44, T45> type;
  5795. };
  5796. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5797. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5798. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5799. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5800. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5801. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5802. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5803. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5804. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5805. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5806. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5807. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5808. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5809. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5810. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  5811. GTEST_TEMPLATE_ T46>
  5812. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5813. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5814. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5815. T45, T46, NoneT, NoneT, NoneT, NoneT> {
  5816. typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5817. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5818. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5819. T42, T43, T44, T45, T46> type;
  5820. };
  5821. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5822. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5823. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5824. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5825. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5826. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5827. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5828. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5829. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5830. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5831. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5832. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5833. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5834. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5835. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  5836. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>
  5837. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5838. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5839. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5840. T45, T46, T47, NoneT, NoneT, NoneT> {
  5841. typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5842. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5843. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5844. T42, T43, T44, T45, T46, T47> type;
  5845. };
  5846. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5847. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5848. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5849. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5850. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5851. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5852. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5853. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5854. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5855. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5856. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5857. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5858. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5859. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5860. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  5861. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>
  5862. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5863. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5864. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5865. T45, T46, T47, T48, NoneT, NoneT> {
  5866. typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5867. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5868. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5869. T42, T43, T44, T45, T46, T47, T48> type;
  5870. };
  5871. template <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,
  5872. GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,
  5873. GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,
  5874. GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,
  5875. GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,
  5876. GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,
  5877. GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,
  5878. GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,
  5879. GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,
  5880. GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,
  5881. GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,
  5882. GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,
  5883. GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,
  5884. GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,
  5885. GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,
  5886. GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,
  5887. GTEST_TEMPLATE_ T49>
  5888. struct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
  5889. T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
  5890. T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,
  5891. T45, T46, T47, T48, T49, NoneT> {
  5892. typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5893. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,
  5894. T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,
  5895. T42, T43, T44, T45, T46, T47, T48, T49> type;
  5896. };
  5897. // The TypeList template makes it possible to use either a single type
  5898. // or a Types<...> list in TYPED_TEST_SUITE() and
  5899. // INSTANTIATE_TYPED_TEST_SUITE_P().
  5900. template <typename T>
  5901. struct TypeList {
  5902. typedef Types1<T> type;
  5903. };
  5904. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  5905. typename T6, typename T7, typename T8, typename T9, typename T10,
  5906. typename T11, typename T12, typename T13, typename T14, typename T15,
  5907. typename T16, typename T17, typename T18, typename T19, typename T20,
  5908. typename T21, typename T22, typename T23, typename T24, typename T25,
  5909. typename T26, typename T27, typename T28, typename T29, typename T30,
  5910. typename T31, typename T32, typename T33, typename T34, typename T35,
  5911. typename T36, typename T37, typename T38, typename T39, typename T40,
  5912. typename T41, typename T42, typename T43, typename T44, typename T45,
  5913. typename T46, typename T47, typename T48, typename T49, typename T50>
  5914. struct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
  5915. T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
  5916. T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
  5917. T44, T45, T46, T47, T48, T49, T50> > {
  5918. typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
  5919. T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
  5920. T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
  5921. T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;
  5922. };
  5923. #endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
  5924. } // namespace internal
  5925. } // namespace testing
  5926. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
  5927. // Due to C++ preprocessor weirdness, we need double indirection to
  5928. // concatenate two tokens when one of them is __LINE__. Writing
  5929. //
  5930. // foo ## __LINE__
  5931. //
  5932. // will result in the token foo__LINE__, instead of foo followed by
  5933. // the current line number. For more details, see
  5934. // http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
  5935. #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
  5936. #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
  5937. // Stringifies its argument.
  5938. #define GTEST_STRINGIFY_(name) #name
  5939. class ProtocolMessage;
  5940. namespace proto2 { class Message; }
  5941. namespace testing {
  5942. // Forward declarations.
  5943. class AssertionResult; // Result of an assertion.
  5944. class Message; // Represents a failure message.
  5945. class Test; // Represents a test.
  5946. class TestInfo; // Information about a test.
  5947. class TestPartResult; // Result of a test part.
  5948. class UnitTest; // A collection of test suites.
  5949. template <typename T>
  5950. ::std::string PrintToString(const T& value);
  5951. namespace internal {
  5952. struct TraceInfo; // Information about a trace point.
  5953. class TestInfoImpl; // Opaque implementation of TestInfo
  5954. class UnitTestImpl; // Opaque implementation of UnitTest
  5955. // The text used in failure messages to indicate the start of the
  5956. // stack trace.
  5957. GTEST_API_ extern const char kStackTraceMarker[];
  5958. // An IgnoredValue object can be implicitly constructed from ANY value.
  5959. class IgnoredValue {
  5960. public:
  5961. // This constructor template allows any value to be implicitly
  5962. // converted to IgnoredValue. The object has no data member and
  5963. // doesn't try to remember anything about the argument. We
  5964. // deliberately omit the 'explicit' keyword in order to allow the
  5965. // conversion to be implicit.
  5966. template <typename T>
  5967. IgnoredValue(const T& /* ignored */) {} // NOLINT(runtime/explicit)
  5968. };
  5969. // Two overloaded helpers for checking at compile time whether an
  5970. // expression is a null pointer literal (i.e. NULL or any 0-valued
  5971. // compile-time integral constant). These helpers have no
  5972. // implementations, as we only need their signatures.
  5973. //
  5974. // Given IsNullLiteralHelper(x), the compiler will pick the first
  5975. // version if x can be implicitly converted to Secret*, and pick the
  5976. // second version otherwise. Since Secret is a secret and incomplete
  5977. // type, the only expression a user can write that has type Secret* is
  5978. // a null pointer literal. Therefore, we know that x is a null
  5979. // pointer literal if and only if the first version is picked by the
  5980. // compiler.
  5981. std::true_type IsNullLiteralHelper(Secret*);
  5982. std::false_type IsNullLiteralHelper(IgnoredValue);
  5983. // A compile-time bool constant that is true if and only if x is a null pointer
  5984. // literal (i.e. nullptr, NULL or any 0-valued compile-time integral constant).
  5985. #define GTEST_IS_NULL_LITERAL_(x) \
  5986. decltype(::testing::internal::IsNullLiteralHelper(x))::value
  5987. // Appends the user-supplied message to the Google-Test-generated message.
  5988. GTEST_API_ std::string AppendUserMessage(
  5989. const std::string& gtest_msg, const Message& user_msg);
  5990. #if GTEST_HAS_EXCEPTIONS
  5991. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \
  5992. /* an exported class was derived from a class that was not exported */)
  5993. // This exception is thrown by (and only by) a failed Google Test
  5994. // assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions
  5995. // are enabled). We derive it from std::runtime_error, which is for
  5996. // errors presumably detectable only at run time. Since
  5997. // std::runtime_error inherits from std::exception, many testing
  5998. // frameworks know how to extract and print the message inside it.
  5999. class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
  6000. public:
  6001. explicit GoogleTestFailureException(const TestPartResult& failure);
  6002. };
  6003. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4275
  6004. #endif // GTEST_HAS_EXCEPTIONS
  6005. namespace edit_distance {
  6006. // Returns the optimal edits to go from 'left' to 'right'.
  6007. // All edits cost the same, with replace having lower priority than
  6008. // add/remove.
  6009. // Simple implementation of the Wagner-Fischer algorithm.
  6010. // See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
  6011. enum EditType { kMatch, kAdd, kRemove, kReplace };
  6012. GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
  6013. const std::vector<size_t>& left, const std::vector<size_t>& right);
  6014. // Same as above, but the input is represented as strings.
  6015. GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
  6016. const std::vector<std::string>& left,
  6017. const std::vector<std::string>& right);
  6018. // Create a diff of the input strings in Unified diff format.
  6019. GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
  6020. const std::vector<std::string>& right,
  6021. size_t context = 2);
  6022. } // namespace edit_distance
  6023. // Calculate the diff between 'left' and 'right' and return it in unified diff
  6024. // format.
  6025. // If not null, stores in 'total_line_count' the total number of lines found
  6026. // in left + right.
  6027. GTEST_API_ std::string DiffStrings(const std::string& left,
  6028. const std::string& right,
  6029. size_t* total_line_count);
  6030. // Constructs and returns the message for an equality assertion
  6031. // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
  6032. //
  6033. // The first four parameters are the expressions used in the assertion
  6034. // and their values, as strings. For example, for ASSERT_EQ(foo, bar)
  6035. // where foo is 5 and bar is 6, we have:
  6036. //
  6037. // expected_expression: "foo"
  6038. // actual_expression: "bar"
  6039. // expected_value: "5"
  6040. // actual_value: "6"
  6041. //
  6042. // The ignoring_case parameter is true iff the assertion is a
  6043. // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
  6044. // be inserted into the message.
  6045. GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
  6046. const char* actual_expression,
  6047. const std::string& expected_value,
  6048. const std::string& actual_value,
  6049. bool ignoring_case);
  6050. // Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
  6051. GTEST_API_ std::string GetBoolAssertionFailureMessage(
  6052. const AssertionResult& assertion_result,
  6053. const char* expression_text,
  6054. const char* actual_predicate_value,
  6055. const char* expected_predicate_value);
  6056. // This template class represents an IEEE floating-point number
  6057. // (either single-precision or double-precision, depending on the
  6058. // template parameters).
  6059. //
  6060. // The purpose of this class is to do more sophisticated number
  6061. // comparison. (Due to round-off error, etc, it's very unlikely that
  6062. // two floating-points will be equal exactly. Hence a naive
  6063. // comparison by the == operation often doesn't work.)
  6064. //
  6065. // Format of IEEE floating-point:
  6066. //
  6067. // The most-significant bit being the leftmost, an IEEE
  6068. // floating-point looks like
  6069. //
  6070. // sign_bit exponent_bits fraction_bits
  6071. //
  6072. // Here, sign_bit is a single bit that designates the sign of the
  6073. // number.
  6074. //
  6075. // For float, there are 8 exponent bits and 23 fraction bits.
  6076. //
  6077. // For double, there are 11 exponent bits and 52 fraction bits.
  6078. //
  6079. // More details can be found at
  6080. // http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
  6081. //
  6082. // Template parameter:
  6083. //
  6084. // RawType: the raw floating-point type (either float or double)
  6085. template <typename RawType>
  6086. class FloatingPoint {
  6087. public:
  6088. // Defines the unsigned integer type that has the same size as the
  6089. // floating point number.
  6090. typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
  6091. // Constants.
  6092. // # of bits in a number.
  6093. static const size_t kBitCount = 8*sizeof(RawType);
  6094. // # of fraction bits in a number.
  6095. static const size_t kFractionBitCount =
  6096. std::numeric_limits<RawType>::digits - 1;
  6097. // # of exponent bits in a number.
  6098. static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
  6099. // The mask for the sign bit.
  6100. static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
  6101. // The mask for the fraction bits.
  6102. static const Bits kFractionBitMask =
  6103. ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
  6104. // The mask for the exponent bits.
  6105. static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
  6106. // How many ULP's (Units in the Last Place) we want to tolerate when
  6107. // comparing two numbers. The larger the value, the more error we
  6108. // allow. A 0 value means that two numbers must be exactly the same
  6109. // to be considered equal.
  6110. //
  6111. // The maximum error of a single floating-point operation is 0.5
  6112. // units in the last place. On Intel CPU's, all floating-point
  6113. // calculations are done with 80-bit precision, while double has 64
  6114. // bits. Therefore, 4 should be enough for ordinary use.
  6115. //
  6116. // See the following article for more details on ULP:
  6117. // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
  6118. static const size_t kMaxUlps = 4;
  6119. // Constructs a FloatingPoint from a raw floating-point number.
  6120. //
  6121. // On an Intel CPU, passing a non-normalized NAN (Not a Number)
  6122. // around may change its bits, although the new value is guaranteed
  6123. // to be also a NAN. Therefore, don't expect this constructor to
  6124. // preserve the bits in x when x is a NAN.
  6125. explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
  6126. // Static methods
  6127. // Reinterprets a bit pattern as a floating-point number.
  6128. //
  6129. // This function is needed to test the AlmostEquals() method.
  6130. static RawType ReinterpretBits(const Bits bits) {
  6131. FloatingPoint fp(0);
  6132. fp.u_.bits_ = bits;
  6133. return fp.u_.value_;
  6134. }
  6135. // Returns the floating-point number that represent positive infinity.
  6136. static RawType Infinity() {
  6137. return ReinterpretBits(kExponentBitMask);
  6138. }
  6139. // Returns the maximum representable finite floating-point number.
  6140. static RawType Max();
  6141. // Non-static methods
  6142. // Returns the bits that represents this number.
  6143. const Bits &bits() const { return u_.bits_; }
  6144. // Returns the exponent bits of this number.
  6145. Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
  6146. // Returns the fraction bits of this number.
  6147. Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
  6148. // Returns the sign bit of this number.
  6149. Bits sign_bit() const { return kSignBitMask & u_.bits_; }
  6150. // Returns true iff this is NAN (not a number).
  6151. bool is_nan() const {
  6152. // It's a NAN if the exponent bits are all ones and the fraction
  6153. // bits are not entirely zeros.
  6154. return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
  6155. }
  6156. // Returns true iff this number is at most kMaxUlps ULP's away from
  6157. // rhs. In particular, this function:
  6158. //
  6159. // - returns false if either number is (or both are) NAN.
  6160. // - treats really large numbers as almost equal to infinity.
  6161. // - thinks +0.0 and -0.0 are 0 DLP's apart.
  6162. bool AlmostEquals(const FloatingPoint& rhs) const {
  6163. // The IEEE standard says that any comparison operation involving
  6164. // a NAN must return false.
  6165. if (is_nan() || rhs.is_nan()) return false;
  6166. return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
  6167. <= kMaxUlps;
  6168. }
  6169. private:
  6170. // The data type used to store the actual floating-point number.
  6171. union FloatingPointUnion {
  6172. RawType value_; // The raw floating-point number.
  6173. Bits bits_; // The bits that represent the number.
  6174. };
  6175. // Converts an integer from the sign-and-magnitude representation to
  6176. // the biased representation. More precisely, let N be 2 to the
  6177. // power of (kBitCount - 1), an integer x is represented by the
  6178. // unsigned number x + N.
  6179. //
  6180. // For instance,
  6181. //
  6182. // -N + 1 (the most negative number representable using
  6183. // sign-and-magnitude) is represented by 1;
  6184. // 0 is represented by N; and
  6185. // N - 1 (the biggest number representable using
  6186. // sign-and-magnitude) is represented by 2N - 1.
  6187. //
  6188. // Read http://en.wikipedia.org/wiki/Signed_number_representations
  6189. // for more details on signed number representations.
  6190. static Bits SignAndMagnitudeToBiased(const Bits &sam) {
  6191. if (kSignBitMask & sam) {
  6192. // sam represents a negative number.
  6193. return ~sam + 1;
  6194. } else {
  6195. // sam represents a positive number.
  6196. return kSignBitMask | sam;
  6197. }
  6198. }
  6199. // Given two numbers in the sign-and-magnitude representation,
  6200. // returns the distance between them as an unsigned number.
  6201. static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
  6202. const Bits &sam2) {
  6203. const Bits biased1 = SignAndMagnitudeToBiased(sam1);
  6204. const Bits biased2 = SignAndMagnitudeToBiased(sam2);
  6205. return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
  6206. }
  6207. FloatingPointUnion u_;
  6208. };
  6209. // We cannot use std::numeric_limits<T>::max() as it clashes with the max()
  6210. // macro defined by <windows.h>.
  6211. template <>
  6212. inline float FloatingPoint<float>::Max() { return FLT_MAX; }
  6213. template <>
  6214. inline double FloatingPoint<double>::Max() { return DBL_MAX; }
  6215. // Typedefs the instances of the FloatingPoint template class that we
  6216. // care to use.
  6217. typedef FloatingPoint<float> Float;
  6218. typedef FloatingPoint<double> Double;
  6219. // In order to catch the mistake of putting tests that use different
  6220. // test fixture classes in the same test suite, we need to assign
  6221. // unique IDs to fixture classes and compare them. The TypeId type is
  6222. // used to hold such IDs. The user should treat TypeId as an opaque
  6223. // type: the only operation allowed on TypeId values is to compare
  6224. // them for equality using the == operator.
  6225. typedef const void* TypeId;
  6226. template <typename T>
  6227. class TypeIdHelper {
  6228. public:
  6229. // dummy_ must not have a const type. Otherwise an overly eager
  6230. // compiler (e.g. MSVC 7.1 & 8.0) may try to merge
  6231. // TypeIdHelper<T>::dummy_ for different Ts as an "optimization".
  6232. static bool dummy_;
  6233. };
  6234. template <typename T>
  6235. bool TypeIdHelper<T>::dummy_ = false;
  6236. // GetTypeId<T>() returns the ID of type T. Different values will be
  6237. // returned for different types. Calling the function twice with the
  6238. // same type argument is guaranteed to return the same ID.
  6239. template <typename T>
  6240. TypeId GetTypeId() {
  6241. // The compiler is required to allocate a different
  6242. // TypeIdHelper<T>::dummy_ variable for each T used to instantiate
  6243. // the template. Therefore, the address of dummy_ is guaranteed to
  6244. // be unique.
  6245. return &(TypeIdHelper<T>::dummy_);
  6246. }
  6247. // Returns the type ID of ::testing::Test. Always call this instead
  6248. // of GetTypeId< ::testing::Test>() to get the type ID of
  6249. // ::testing::Test, as the latter may give the wrong result due to a
  6250. // suspected linker bug when compiling Google Test as a Mac OS X
  6251. // framework.
  6252. GTEST_API_ TypeId GetTestTypeId();
  6253. // Defines the abstract factory interface that creates instances
  6254. // of a Test object.
  6255. class TestFactoryBase {
  6256. public:
  6257. virtual ~TestFactoryBase() {}
  6258. // Creates a test instance to run. The instance is both created and destroyed
  6259. // within TestInfoImpl::Run()
  6260. virtual Test* CreateTest() = 0;
  6261. protected:
  6262. TestFactoryBase() {}
  6263. private:
  6264. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
  6265. };
  6266. // This class provides implementation of TeastFactoryBase interface.
  6267. // It is used in TEST and TEST_F macros.
  6268. template <class TestClass>
  6269. class TestFactoryImpl : public TestFactoryBase {
  6270. public:
  6271. Test* CreateTest() override { return new TestClass; }
  6272. };
  6273. #if GTEST_OS_WINDOWS
  6274. // Predicate-formatters for implementing the HRESULT checking macros
  6275. // {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
  6276. // We pass a long instead of HRESULT to avoid causing an
  6277. // include dependency for the HRESULT type.
  6278. GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
  6279. long hr); // NOLINT
  6280. GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
  6281. long hr); // NOLINT
  6282. #endif // GTEST_OS_WINDOWS
  6283. // Types of SetUpTestSuite() and TearDownTestSuite() functions.
  6284. using SetUpTestSuiteFunc = void (*)();
  6285. using TearDownTestSuiteFunc = void (*)();
  6286. struct CodeLocation {
  6287. CodeLocation(const std::string& a_file, int a_line)
  6288. : file(a_file), line(a_line) {}
  6289. std::string file;
  6290. int line;
  6291. };
  6292. // Helper to identify which setup function for TestCase / TestSuite to call.
  6293. // Only one function is allowed, either TestCase or TestSute but not both.
  6294. // Utility functions to help SuiteApiResolver
  6295. using SetUpTearDownSuiteFuncType = void (*)();
  6296. inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(
  6297. SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) {
  6298. return a == def ? nullptr : a;
  6299. }
  6300. template <typename T>
  6301. // Note that SuiteApiResolver inherits from T because
  6302. // SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way
  6303. // SuiteApiResolver can access them.
  6304. struct SuiteApiResolver : T {
  6305. // testing::Test is only forward declared at this point. So we make it a
  6306. // dependend class for the compiler to be OK with it.
  6307. using Test =
  6308. typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;
  6309. static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite() {
  6310. SetUpTearDownSuiteFuncType test_case_fp =
  6311. GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase);
  6312. SetUpTearDownSuiteFuncType test_suite_fp =
  6313. GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite);
  6314. GTEST_CHECK_(!test_case_fp || !test_suite_fp)
  6315. << "Test can not provide both SetUpTestSuite and SetUpTestCase, please "
  6316. "make sure there is only one present ";
  6317. return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
  6318. }
  6319. static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite() {
  6320. SetUpTearDownSuiteFuncType test_case_fp =
  6321. GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase);
  6322. SetUpTearDownSuiteFuncType test_suite_fp =
  6323. GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite);
  6324. GTEST_CHECK_(!test_case_fp || !test_suite_fp)
  6325. << "Test can not provide both TearDownTestSuite and TearDownTestCase,"
  6326. " please make sure there is only one present ";
  6327. return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
  6328. }
  6329. };
  6330. // Creates a new TestInfo object and registers it with Google Test;
  6331. // returns the created object.
  6332. //
  6333. // Arguments:
  6334. //
  6335. // test_suite_name: name of the test suite
  6336. // name: name of the test
  6337. // type_param the name of the test's type parameter, or NULL if
  6338. // this is not a typed or a type-parameterized test.
  6339. // value_param text representation of the test's value parameter,
  6340. // or NULL if this is not a type-parameterized test.
  6341. // code_location: code location where the test is defined
  6342. // fixture_class_id: ID of the test fixture class
  6343. // set_up_tc: pointer to the function that sets up the test suite
  6344. // tear_down_tc: pointer to the function that tears down the test suite
  6345. // factory: pointer to the factory that creates a test object.
  6346. // The newly created TestInfo instance will assume
  6347. // ownership of the factory object.
  6348. GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
  6349. const char* test_suite_name, const char* name, const char* type_param,
  6350. const char* value_param, CodeLocation code_location,
  6351. TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
  6352. TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
  6353. // If *pstr starts with the given prefix, modifies *pstr to be right
  6354. // past the prefix and returns true; otherwise leaves *pstr unchanged
  6355. // and returns false. None of pstr, *pstr, and prefix can be NULL.
  6356. GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
  6357. #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
  6358. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  6359. /* class A needs to have dll-interface to be used by clients of class B */)
  6360. // State of the definition of a type-parameterized test suite.
  6361. class GTEST_API_ TypedTestSuitePState {
  6362. public:
  6363. TypedTestSuitePState() : registered_(false) {}
  6364. // Adds the given test name to defined_test_names_ and return true
  6365. // if the test suite hasn't been registered; otherwise aborts the
  6366. // program.
  6367. bool AddTestName(const char* file, int line, const char* case_name,
  6368. const char* test_name) {
  6369. if (registered_) {
  6370. fprintf(stderr,
  6371. "%s Test %s must be defined before "
  6372. "REGISTER_TYPED_TEST_SUITE_P(%s, ...).\n",
  6373. FormatFileLocation(file, line).c_str(), test_name, case_name);
  6374. fflush(stderr);
  6375. posix::Abort();
  6376. }
  6377. registered_tests_.insert(
  6378. ::std::make_pair(test_name, CodeLocation(file, line)));
  6379. return true;
  6380. }
  6381. bool TestExists(const std::string& test_name) const {
  6382. return registered_tests_.count(test_name) > 0;
  6383. }
  6384. const CodeLocation& GetCodeLocation(const std::string& test_name) const {
  6385. RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
  6386. GTEST_CHECK_(it != registered_tests_.end());
  6387. return it->second;
  6388. }
  6389. // Verifies that registered_tests match the test names in
  6390. // defined_test_names_; returns registered_tests if successful, or
  6391. // aborts the program otherwise.
  6392. const char* VerifyRegisteredTestNames(
  6393. const char* file, int line, const char* registered_tests);
  6394. private:
  6395. typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
  6396. bool registered_;
  6397. RegisteredTestsMap registered_tests_;
  6398. };
  6399. // Legacy API is deprecated but still available
  6400. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  6401. using TypedTestCasePState = TypedTestSuitePState;
  6402. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  6403. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  6404. // Skips to the first non-space char after the first comma in 'str';
  6405. // returns NULL if no comma is found in 'str'.
  6406. inline const char* SkipComma(const char* str) {
  6407. const char* comma = strchr(str, ',');
  6408. if (comma == nullptr) {
  6409. return nullptr;
  6410. }
  6411. while (IsSpace(*(++comma))) {}
  6412. return comma;
  6413. }
  6414. // Returns the prefix of 'str' before the first comma in it; returns
  6415. // the entire string if it contains no comma.
  6416. inline std::string GetPrefixUntilComma(const char* str) {
  6417. const char* comma = strchr(str, ',');
  6418. return comma == nullptr ? str : std::string(str, comma);
  6419. }
  6420. // Splits a given string on a given delimiter, populating a given
  6421. // vector with the fields.
  6422. void SplitString(const ::std::string& str, char delimiter,
  6423. ::std::vector< ::std::string>* dest);
  6424. // The default argument to the template below for the case when the user does
  6425. // not provide a name generator.
  6426. struct DefaultNameGenerator {
  6427. template <typename T>
  6428. static std::string GetName(int i) {
  6429. return StreamableToString(i);
  6430. }
  6431. };
  6432. template <typename Provided = DefaultNameGenerator>
  6433. struct NameGeneratorSelector {
  6434. typedef Provided type;
  6435. };
  6436. template <typename NameGenerator>
  6437. void GenerateNamesRecursively(Types0, std::vector<std::string>*, int) {}
  6438. template <typename NameGenerator, typename Types>
  6439. void GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) {
  6440. result->push_back(NameGenerator::template GetName<typename Types::Head>(i));
  6441. GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result,
  6442. i + 1);
  6443. }
  6444. template <typename NameGenerator, typename Types>
  6445. std::vector<std::string> GenerateNames() {
  6446. std::vector<std::string> result;
  6447. GenerateNamesRecursively<NameGenerator>(Types(), &result, 0);
  6448. return result;
  6449. }
  6450. // TypeParameterizedTest<Fixture, TestSel, Types>::Register()
  6451. // registers a list of type-parameterized tests with Google Test. The
  6452. // return value is insignificant - we just need to return something
  6453. // such that we can call this function in a namespace scope.
  6454. //
  6455. // Implementation note: The GTEST_TEMPLATE_ macro declares a template
  6456. // template parameter. It's defined in gtest-type-util.h.
  6457. template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
  6458. class TypeParameterizedTest {
  6459. public:
  6460. // 'index' is the index of the test in the type list 'Types'
  6461. // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
  6462. // Types). Valid values for 'index' are [0, N - 1] where N is the
  6463. // length of Types.
  6464. static bool Register(const char* prefix, const CodeLocation& code_location,
  6465. const char* case_name, const char* test_names, int index,
  6466. const std::vector<std::string>& type_names =
  6467. GenerateNames<DefaultNameGenerator, Types>()) {
  6468. typedef typename Types::Head Type;
  6469. typedef Fixture<Type> FixtureClass;
  6470. typedef typename GTEST_BIND_(TestSel, Type) TestClass;
  6471. // First, registers the first type-parameterized test in the type
  6472. // list.
  6473. MakeAndRegisterTestInfo(
  6474. (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
  6475. "/" + type_names[index])
  6476. .c_str(),
  6477. StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
  6478. GetTypeName<Type>().c_str(),
  6479. nullptr, // No value parameter.
  6480. code_location, GetTypeId<FixtureClass>(),
  6481. SuiteApiResolver<TestClass>::GetSetUpCaseOrSuite(),
  6482. SuiteApiResolver<TestClass>::GetTearDownCaseOrSuite(),
  6483. new TestFactoryImpl<TestClass>);
  6484. // Next, recurses (at compile time) with the tail of the type list.
  6485. return TypeParameterizedTest<Fixture, TestSel,
  6486. typename Types::Tail>::Register(prefix,
  6487. code_location,
  6488. case_name,
  6489. test_names,
  6490. index + 1,
  6491. type_names);
  6492. }
  6493. };
  6494. // The base case for the compile time recursion.
  6495. template <GTEST_TEMPLATE_ Fixture, class TestSel>
  6496. class TypeParameterizedTest<Fixture, TestSel, Types0> {
  6497. public:
  6498. static bool Register(const char* /*prefix*/, const CodeLocation&,
  6499. const char* /*case_name*/, const char* /*test_names*/,
  6500. int /*index*/,
  6501. const std::vector<std::string>& =
  6502. std::vector<std::string>() /*type_names*/) {
  6503. return true;
  6504. }
  6505. };
  6506. // TypeParameterizedTestSuite<Fixture, Tests, Types>::Register()
  6507. // registers *all combinations* of 'Tests' and 'Types' with Google
  6508. // Test. The return value is insignificant - we just need to return
  6509. // something such that we can call this function in a namespace scope.
  6510. template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
  6511. class TypeParameterizedTestSuite {
  6512. public:
  6513. static bool Register(const char* prefix, CodeLocation code_location,
  6514. const TypedTestSuitePState* state, const char* case_name,
  6515. const char* test_names,
  6516. const std::vector<std::string>& type_names =
  6517. GenerateNames<DefaultNameGenerator, Types>()) {
  6518. std::string test_name = StripTrailingSpaces(
  6519. GetPrefixUntilComma(test_names));
  6520. if (!state->TestExists(test_name)) {
  6521. fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
  6522. case_name, test_name.c_str(),
  6523. FormatFileLocation(code_location.file.c_str(),
  6524. code_location.line).c_str());
  6525. fflush(stderr);
  6526. posix::Abort();
  6527. }
  6528. const CodeLocation& test_location = state->GetCodeLocation(test_name);
  6529. typedef typename Tests::Head Head;
  6530. // First, register the first test in 'Test' for each type in 'Types'.
  6531. TypeParameterizedTest<Fixture, Head, Types>::Register(
  6532. prefix, test_location, case_name, test_names, 0, type_names);
  6533. // Next, recurses (at compile time) with the tail of the test list.
  6534. return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
  6535. Types>::Register(prefix, code_location,
  6536. state, case_name,
  6537. SkipComma(test_names),
  6538. type_names);
  6539. }
  6540. };
  6541. // The base case for the compile time recursion.
  6542. template <GTEST_TEMPLATE_ Fixture, typename Types>
  6543. class TypeParameterizedTestSuite<Fixture, Templates0, Types> {
  6544. public:
  6545. static bool Register(const char* /*prefix*/, const CodeLocation&,
  6546. const TypedTestSuitePState* /*state*/,
  6547. const char* /*case_name*/, const char* /*test_names*/,
  6548. const std::vector<std::string>& =
  6549. std::vector<std::string>() /*type_names*/) {
  6550. return true;
  6551. }
  6552. };
  6553. #endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
  6554. // Returns the current OS stack trace as an std::string.
  6555. //
  6556. // The maximum number of stack frames to be included is specified by
  6557. // the gtest_stack_trace_depth flag. The skip_count parameter
  6558. // specifies the number of top frames to be skipped, which doesn't
  6559. // count against the number of frames to be included.
  6560. //
  6561. // For example, if Foo() calls Bar(), which in turn calls
  6562. // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
  6563. // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
  6564. GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
  6565. UnitTest* unit_test, int skip_count);
  6566. // Helpers for suppressing warnings on unreachable code or constant
  6567. // condition.
  6568. // Always returns true.
  6569. GTEST_API_ bool AlwaysTrue();
  6570. // Always returns false.
  6571. inline bool AlwaysFalse() { return !AlwaysTrue(); }
  6572. // Helper for suppressing false warning from Clang on a const char*
  6573. // variable declared in a conditional expression always being NULL in
  6574. // the else branch.
  6575. struct GTEST_API_ ConstCharPtr {
  6576. ConstCharPtr(const char* str) : value(str) {}
  6577. operator bool() const { return true; }
  6578. const char* value;
  6579. };
  6580. // A simple Linear Congruential Generator for generating random
  6581. // numbers with a uniform distribution. Unlike rand() and srand(), it
  6582. // doesn't use global state (and therefore can't interfere with user
  6583. // code). Unlike rand_r(), it's portable. An LCG isn't very random,
  6584. // but it's good enough for our purposes.
  6585. class GTEST_API_ Random {
  6586. public:
  6587. static const UInt32 kMaxRange = 1u << 31;
  6588. explicit Random(UInt32 seed) : state_(seed) {}
  6589. void Reseed(UInt32 seed) { state_ = seed; }
  6590. // Generates a random number from [0, range). Crashes if 'range' is
  6591. // 0 or greater than kMaxRange.
  6592. UInt32 Generate(UInt32 range);
  6593. private:
  6594. UInt32 state_;
  6595. GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
  6596. };
  6597. // Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
  6598. // compiler error iff T1 and T2 are different types.
  6599. template <typename T1, typename T2>
  6600. struct CompileAssertTypesEqual;
  6601. template <typename T>
  6602. struct CompileAssertTypesEqual<T, T> {
  6603. };
  6604. // Removes the reference from a type if it is a reference type,
  6605. // otherwise leaves it unchanged. This is the same as
  6606. // tr1::remove_reference, which is not widely available yet.
  6607. template <typename T>
  6608. struct RemoveReference { typedef T type; }; // NOLINT
  6609. template <typename T>
  6610. struct RemoveReference<T&> { typedef T type; }; // NOLINT
  6611. // A handy wrapper around RemoveReference that works when the argument
  6612. // T depends on template parameters.
  6613. #define GTEST_REMOVE_REFERENCE_(T) \
  6614. typename ::testing::internal::RemoveReference<T>::type
  6615. // Removes const from a type if it is a const type, otherwise leaves
  6616. // it unchanged. This is the same as tr1::remove_const, which is not
  6617. // widely available yet.
  6618. template <typename T>
  6619. struct RemoveConst { typedef T type; }; // NOLINT
  6620. template <typename T>
  6621. struct RemoveConst<const T> { typedef T type; }; // NOLINT
  6622. // MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above
  6623. // definition to fail to remove the const in 'const int[3]' and 'const
  6624. // char[3][4]'. The following specialization works around the bug.
  6625. template <typename T, size_t N>
  6626. struct RemoveConst<const T[N]> {
  6627. typedef typename RemoveConst<T>::type type[N];
  6628. };
  6629. // A handy wrapper around RemoveConst that works when the argument
  6630. // T depends on template parameters.
  6631. #define GTEST_REMOVE_CONST_(T) \
  6632. typename ::testing::internal::RemoveConst<T>::type
  6633. // Turns const U&, U&, const U, and U all into U.
  6634. #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
  6635. GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
  6636. // ImplicitlyConvertible<From, To>::value is a compile-time bool
  6637. // constant that's true iff type From can be implicitly converted to
  6638. // type To.
  6639. template <typename From, typename To>
  6640. class ImplicitlyConvertible {
  6641. private:
  6642. // We need the following helper functions only for their types.
  6643. // They have no implementations.
  6644. // MakeFrom() is an expression whose type is From. We cannot simply
  6645. // use From(), as the type From may not have a public default
  6646. // constructor.
  6647. static typename AddReference<From>::type MakeFrom();
  6648. // These two functions are overloaded. Given an expression
  6649. // Helper(x), the compiler will pick the first version if x can be
  6650. // implicitly converted to type To; otherwise it will pick the
  6651. // second version.
  6652. //
  6653. // The first version returns a value of size 1, and the second
  6654. // version returns a value of size 2. Therefore, by checking the
  6655. // size of Helper(x), which can be done at compile time, we can tell
  6656. // which version of Helper() is used, and hence whether x can be
  6657. // implicitly converted to type To.
  6658. static char Helper(To);
  6659. static char (&Helper(...))[2]; // NOLINT
  6660. // We have to put the 'public' section after the 'private' section,
  6661. // or MSVC refuses to compile the code.
  6662. public:
  6663. #if defined(__BORLANDC__)
  6664. // C++Builder cannot use member overload resolution during template
  6665. // instantiation. The simplest workaround is to use its C++0x type traits
  6666. // functions (C++Builder 2009 and above only).
  6667. static const bool value = __is_convertible(From, To);
  6668. #else
  6669. // MSVC warns about implicitly converting from double to int for
  6670. // possible loss of data, so we need to temporarily disable the
  6671. // warning.
  6672. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244)
  6673. static const bool value =
  6674. sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
  6675. GTEST_DISABLE_MSC_WARNINGS_POP_()
  6676. #endif // __BORLANDC__
  6677. };
  6678. template <typename From, typename To>
  6679. const bool ImplicitlyConvertible<From, To>::value;
  6680. // IsAProtocolMessage<T>::value is a compile-time bool constant that's
  6681. // true iff T is type ProtocolMessage, proto2::Message, or a subclass
  6682. // of those.
  6683. template <typename T>
  6684. struct IsAProtocolMessage
  6685. : public bool_constant<
  6686. ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||
  6687. ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {
  6688. };
  6689. // When the compiler sees expression IsContainerTest<C>(0), if C is an
  6690. // STL-style container class, the first overload of IsContainerTest
  6691. // will be viable (since both C::iterator* and C::const_iterator* are
  6692. // valid types and NULL can be implicitly converted to them). It will
  6693. // be picked over the second overload as 'int' is a perfect match for
  6694. // the type of argument 0. If C::iterator or C::const_iterator is not
  6695. // a valid type, the first overload is not viable, and the second
  6696. // overload will be picked. Therefore, we can determine whether C is
  6697. // a container class by checking the type of IsContainerTest<C>(0).
  6698. // The value of the expression is insignificant.
  6699. //
  6700. // In C++11 mode we check the existence of a const_iterator and that an
  6701. // iterator is properly implemented for the container.
  6702. //
  6703. // For pre-C++11 that we look for both C::iterator and C::const_iterator.
  6704. // The reason is that C++ injects the name of a class as a member of the
  6705. // class itself (e.g. you can refer to class iterator as either
  6706. // 'iterator' or 'iterator::iterator'). If we look for C::iterator
  6707. // only, for example, we would mistakenly think that a class named
  6708. // iterator is an STL container.
  6709. //
  6710. // Also note that the simpler approach of overloading
  6711. // IsContainerTest(typename C::const_iterator*) and
  6712. // IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
  6713. typedef int IsContainer;
  6714. template <class C,
  6715. class Iterator = decltype(::std::declval<const C&>().begin()),
  6716. class = decltype(::std::declval<const C&>().end()),
  6717. class = decltype(++::std::declval<Iterator&>()),
  6718. class = decltype(*::std::declval<Iterator>()),
  6719. class = typename C::const_iterator>
  6720. IsContainer IsContainerTest(int /* dummy */) {
  6721. return 0;
  6722. }
  6723. typedef char IsNotContainer;
  6724. template <class C>
  6725. IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; }
  6726. // Trait to detect whether a type T is a hash table.
  6727. // The heuristic used is that the type contains an inner type `hasher` and does
  6728. // not contain an inner type `reverse_iterator`.
  6729. // If the container is iterable in reverse, then order might actually matter.
  6730. template <typename T>
  6731. struct IsHashTable {
  6732. private:
  6733. template <typename U>
  6734. static char test(typename U::hasher*, typename U::reverse_iterator*);
  6735. template <typename U>
  6736. static int test(typename U::hasher*, ...);
  6737. template <typename U>
  6738. static char test(...);
  6739. public:
  6740. static const bool value = sizeof(test<T>(nullptr, nullptr)) == sizeof(int);
  6741. };
  6742. template <typename T>
  6743. const bool IsHashTable<T>::value;
  6744. template <typename C,
  6745. bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)>
  6746. struct IsRecursiveContainerImpl;
  6747. template <typename C>
  6748. struct IsRecursiveContainerImpl<C, false> : public false_type {};
  6749. // Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to
  6750. // obey the same inconsistencies as the IsContainerTest, namely check if
  6751. // something is a container is relying on only const_iterator in C++11 and
  6752. // is relying on both const_iterator and iterator otherwise
  6753. template <typename C>
  6754. struct IsRecursiveContainerImpl<C, true> {
  6755. using value_type = decltype(*std::declval<typename C::const_iterator>());
  6756. using type =
  6757. is_same<typename std::remove_const<
  6758. typename std::remove_reference<value_type>::type>::type,
  6759. C>;
  6760. };
  6761. // IsRecursiveContainer<Type> is a unary compile-time predicate that
  6762. // evaluates whether C is a recursive container type. A recursive container
  6763. // type is a container type whose value_type is equal to the container type
  6764. // itself. An example for a recursive container type is
  6765. // boost::filesystem::path, whose iterator has a value_type that is equal to
  6766. // boost::filesystem::path.
  6767. template <typename C>
  6768. struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
  6769. // EnableIf<condition>::type is void when 'Cond' is true, and
  6770. // undefined when 'Cond' is false. To use SFINAE to make a function
  6771. // overload only apply when a particular expression is true, add
  6772. // "typename EnableIf<expression>::type* = 0" as the last parameter.
  6773. template<bool> struct EnableIf;
  6774. template<> struct EnableIf<true> { typedef void type; }; // NOLINT
  6775. // Utilities for native arrays.
  6776. // ArrayEq() compares two k-dimensional native arrays using the
  6777. // elements' operator==, where k can be any integer >= 0. When k is
  6778. // 0, ArrayEq() degenerates into comparing a single pair of values.
  6779. template <typename T, typename U>
  6780. bool ArrayEq(const T* lhs, size_t size, const U* rhs);
  6781. // This generic version is used when k is 0.
  6782. template <typename T, typename U>
  6783. inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
  6784. // This overload is used when k >= 1.
  6785. template <typename T, typename U, size_t N>
  6786. inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
  6787. return internal::ArrayEq(lhs, N, rhs);
  6788. }
  6789. // This helper reduces code bloat. If we instead put its logic inside
  6790. // the previous ArrayEq() function, arrays with different sizes would
  6791. // lead to different copies of the template code.
  6792. template <typename T, typename U>
  6793. bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
  6794. for (size_t i = 0; i != size; i++) {
  6795. if (!internal::ArrayEq(lhs[i], rhs[i]))
  6796. return false;
  6797. }
  6798. return true;
  6799. }
  6800. // Finds the first element in the iterator range [begin, end) that
  6801. // equals elem. Element may be a native array type itself.
  6802. template <typename Iter, typename Element>
  6803. Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
  6804. for (Iter it = begin; it != end; ++it) {
  6805. if (internal::ArrayEq(*it, elem))
  6806. return it;
  6807. }
  6808. return end;
  6809. }
  6810. // CopyArray() copies a k-dimensional native array using the elements'
  6811. // operator=, where k can be any integer >= 0. When k is 0,
  6812. // CopyArray() degenerates into copying a single value.
  6813. template <typename T, typename U>
  6814. void CopyArray(const T* from, size_t size, U* to);
  6815. // This generic version is used when k is 0.
  6816. template <typename T, typename U>
  6817. inline void CopyArray(const T& from, U* to) { *to = from; }
  6818. // This overload is used when k >= 1.
  6819. template <typename T, typename U, size_t N>
  6820. inline void CopyArray(const T(&from)[N], U(*to)[N]) {
  6821. internal::CopyArray(from, N, *to);
  6822. }
  6823. // This helper reduces code bloat. If we instead put its logic inside
  6824. // the previous CopyArray() function, arrays with different sizes
  6825. // would lead to different copies of the template code.
  6826. template <typename T, typename U>
  6827. void CopyArray(const T* from, size_t size, U* to) {
  6828. for (size_t i = 0; i != size; i++) {
  6829. internal::CopyArray(from[i], to + i);
  6830. }
  6831. }
  6832. // The relation between an NativeArray object (see below) and the
  6833. // native array it represents.
  6834. // We use 2 different structs to allow non-copyable types to be used, as long
  6835. // as RelationToSourceReference() is passed.
  6836. struct RelationToSourceReference {};
  6837. struct RelationToSourceCopy {};
  6838. // Adapts a native array to a read-only STL-style container. Instead
  6839. // of the complete STL container concept, this adaptor only implements
  6840. // members useful for Google Mock's container matchers. New members
  6841. // should be added as needed. To simplify the implementation, we only
  6842. // support Element being a raw type (i.e. having no top-level const or
  6843. // reference modifier). It's the client's responsibility to satisfy
  6844. // this requirement. Element can be an array type itself (hence
  6845. // multi-dimensional arrays are supported).
  6846. template <typename Element>
  6847. class NativeArray {
  6848. public:
  6849. // STL-style container typedefs.
  6850. typedef Element value_type;
  6851. typedef Element* iterator;
  6852. typedef const Element* const_iterator;
  6853. // Constructs from a native array. References the source.
  6854. NativeArray(const Element* array, size_t count, RelationToSourceReference) {
  6855. InitRef(array, count);
  6856. }
  6857. // Constructs from a native array. Copies the source.
  6858. NativeArray(const Element* array, size_t count, RelationToSourceCopy) {
  6859. InitCopy(array, count);
  6860. }
  6861. // Copy constructor.
  6862. NativeArray(const NativeArray& rhs) {
  6863. (this->*rhs.clone_)(rhs.array_, rhs.size_);
  6864. }
  6865. ~NativeArray() {
  6866. if (clone_ != &NativeArray::InitRef)
  6867. delete[] array_;
  6868. }
  6869. // STL-style container methods.
  6870. size_t size() const { return size_; }
  6871. const_iterator begin() const { return array_; }
  6872. const_iterator end() const { return array_ + size_; }
  6873. bool operator==(const NativeArray& rhs) const {
  6874. return size() == rhs.size() &&
  6875. ArrayEq(begin(), size(), rhs.begin());
  6876. }
  6877. private:
  6878. enum {
  6879. kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
  6880. Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value
  6881. };
  6882. // Initializes this object with a copy of the input.
  6883. void InitCopy(const Element* array, size_t a_size) {
  6884. Element* const copy = new Element[a_size];
  6885. CopyArray(array, a_size, copy);
  6886. array_ = copy;
  6887. size_ = a_size;
  6888. clone_ = &NativeArray::InitCopy;
  6889. }
  6890. // Initializes this object with a reference of the input.
  6891. void InitRef(const Element* array, size_t a_size) {
  6892. array_ = array;
  6893. size_ = a_size;
  6894. clone_ = &NativeArray::InitRef;
  6895. }
  6896. const Element* array_;
  6897. size_t size_;
  6898. void (NativeArray::*clone_)(const Element*, size_t);
  6899. GTEST_DISALLOW_ASSIGN_(NativeArray);
  6900. };
  6901. // Backport of std::index_sequence.
  6902. template <size_t... Is>
  6903. struct IndexSequence {
  6904. using type = IndexSequence;
  6905. };
  6906. // Double the IndexSequence, and one if plus_one is true.
  6907. template <bool plus_one, typename T, size_t sizeofT>
  6908. struct DoubleSequence;
  6909. template <size_t... I, size_t sizeofT>
  6910. struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
  6911. using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
  6912. };
  6913. template <size_t... I, size_t sizeofT>
  6914. struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
  6915. using type = IndexSequence<I..., (sizeofT + I)...>;
  6916. };
  6917. // Backport of std::make_index_sequence.
  6918. // It uses O(ln(N)) instantiation depth.
  6919. template <size_t N>
  6920. struct MakeIndexSequence
  6921. : DoubleSequence<N % 2 == 1, typename MakeIndexSequence<N / 2>::type,
  6922. N / 2>::type {};
  6923. template <>
  6924. struct MakeIndexSequence<0> : IndexSequence<> {};
  6925. // FIXME: This implementation of ElemFromList is O(1) in instantiation depth,
  6926. // but it is O(N^2) in total instantiations. Not sure if this is the best
  6927. // tradeoff, as it will make it somewhat slow to compile.
  6928. template <typename T, size_t, size_t>
  6929. struct ElemFromListImpl {};
  6930. template <typename T, size_t I>
  6931. struct ElemFromListImpl<T, I, I> {
  6932. using type = T;
  6933. };
  6934. // Get the Nth element from T...
  6935. // It uses O(1) instantiation depth.
  6936. template <size_t N, typename I, typename... T>
  6937. struct ElemFromList;
  6938. template <size_t N, size_t... I, typename... T>
  6939. struct ElemFromList<N, IndexSequence<I...>, T...>
  6940. : ElemFromListImpl<T, N, I>... {};
  6941. template <typename... T>
  6942. class FlatTuple;
  6943. template <typename Derived, size_t I>
  6944. struct FlatTupleElemBase;
  6945. template <typename... T, size_t I>
  6946. struct FlatTupleElemBase<FlatTuple<T...>, I> {
  6947. using value_type =
  6948. typename ElemFromList<I, typename MakeIndexSequence<sizeof...(T)>::type,
  6949. T...>::type;
  6950. FlatTupleElemBase() = default;
  6951. explicit FlatTupleElemBase(value_type t) : value(std::move(t)) {}
  6952. value_type value;
  6953. };
  6954. template <typename Derived, typename Idx>
  6955. struct FlatTupleBase;
  6956. template <size_t... Idx, typename... T>
  6957. struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
  6958. : FlatTupleElemBase<FlatTuple<T...>, Idx>... {
  6959. using Indices = IndexSequence<Idx...>;
  6960. FlatTupleBase() = default;
  6961. explicit FlatTupleBase(T... t)
  6962. : FlatTupleElemBase<FlatTuple<T...>, Idx>(std::move(t))... {}
  6963. };
  6964. // Analog to std::tuple but with different tradeoffs.
  6965. // This class minimizes the template instantiation depth, thus allowing more
  6966. // elements that std::tuple would. std::tuple has been seen to require an
  6967. // instantiation depth of more than 10x the number of elements in some
  6968. // implementations.
  6969. // FlatTuple and ElemFromList are not recursive and have a fixed depth
  6970. // regardless of T...
  6971. // MakeIndexSequence, on the other hand, it is recursive but with an
  6972. // instantiation depth of O(ln(N)).
  6973. template <typename... T>
  6974. class FlatTuple
  6975. : private FlatTupleBase<FlatTuple<T...>,
  6976. typename MakeIndexSequence<sizeof...(T)>::type> {
  6977. using Indices = typename FlatTuple::FlatTupleBase::Indices;
  6978. public:
  6979. FlatTuple() = default;
  6980. explicit FlatTuple(T... t) : FlatTuple::FlatTupleBase(std::move(t)...) {}
  6981. template <size_t I>
  6982. const typename ElemFromList<I, Indices, T...>::type& Get() const {
  6983. return static_cast<const FlatTupleElemBase<FlatTuple, I>*>(this)->value;
  6984. }
  6985. template <size_t I>
  6986. typename ElemFromList<I, Indices, T...>::type& Get() {
  6987. return static_cast<FlatTupleElemBase<FlatTuple, I>*>(this)->value;
  6988. }
  6989. };
  6990. } // namespace internal
  6991. } // namespace testing
  6992. #define GTEST_MESSAGE_AT_(file, line, message, result_type) \
  6993. ::testing::internal::AssertHelper(result_type, file, line, message) \
  6994. = ::testing::Message()
  6995. #define GTEST_MESSAGE_(message, result_type) \
  6996. GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
  6997. #define GTEST_FATAL_FAILURE_(message) \
  6998. return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
  6999. #define GTEST_NONFATAL_FAILURE_(message) \
  7000. GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
  7001. #define GTEST_SUCCESS_(message) \
  7002. GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
  7003. #define GTEST_SKIP_(message) \
  7004. return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
  7005. // Suppress MSVC warning 4072 (unreachable code) for the code following
  7006. // statement if it returns or throws (or doesn't return or throw in some
  7007. // situations).
  7008. #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
  7009. if (::testing::internal::AlwaysTrue()) { statement; }
  7010. #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
  7011. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  7012. if (::testing::internal::ConstCharPtr gtest_msg = "") { \
  7013. bool gtest_caught_expected = false; \
  7014. try { \
  7015. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  7016. } \
  7017. catch (expected_exception const&) { \
  7018. gtest_caught_expected = true; \
  7019. } \
  7020. catch (...) { \
  7021. gtest_msg.value = \
  7022. "Expected: " #statement " throws an exception of type " \
  7023. #expected_exception ".\n Actual: it throws a different type."; \
  7024. goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
  7025. } \
  7026. if (!gtest_caught_expected) { \
  7027. gtest_msg.value = \
  7028. "Expected: " #statement " throws an exception of type " \
  7029. #expected_exception ".\n Actual: it throws nothing."; \
  7030. goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
  7031. } \
  7032. } else \
  7033. GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
  7034. fail(gtest_msg.value)
  7035. #define GTEST_TEST_NO_THROW_(statement, fail) \
  7036. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  7037. if (::testing::internal::AlwaysTrue()) { \
  7038. try { \
  7039. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  7040. } \
  7041. catch (...) { \
  7042. goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
  7043. } \
  7044. } else \
  7045. GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
  7046. fail("Expected: " #statement " doesn't throw an exception.\n" \
  7047. " Actual: it throws.")
  7048. #define GTEST_TEST_ANY_THROW_(statement, fail) \
  7049. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  7050. if (::testing::internal::AlwaysTrue()) { \
  7051. bool gtest_caught_any = false; \
  7052. try { \
  7053. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  7054. } \
  7055. catch (...) { \
  7056. gtest_caught_any = true; \
  7057. } \
  7058. if (!gtest_caught_any) { \
  7059. goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
  7060. } \
  7061. } else \
  7062. GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
  7063. fail("Expected: " #statement " throws an exception.\n" \
  7064. " Actual: it doesn't.")
  7065. // Implements Boolean test assertions such as EXPECT_TRUE. expression can be
  7066. // either a boolean expression or an AssertionResult. text is a textual
  7067. // represenation of expression as it was passed into the EXPECT_TRUE.
  7068. #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
  7069. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  7070. if (const ::testing::AssertionResult gtest_ar_ = \
  7071. ::testing::AssertionResult(expression)) \
  7072. ; \
  7073. else \
  7074. fail(::testing::internal::GetBoolAssertionFailureMessage(\
  7075. gtest_ar_, text, #actual, #expected).c_str())
  7076. #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
  7077. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  7078. if (::testing::internal::AlwaysTrue()) { \
  7079. ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
  7080. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  7081. if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
  7082. goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
  7083. } \
  7084. } else \
  7085. GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
  7086. fail("Expected: " #statement " doesn't generate new fatal " \
  7087. "failures in the current thread.\n" \
  7088. " Actual: it does.")
  7089. // Expands to the name of the class that implements the given test.
  7090. #define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
  7091. test_suite_name##_##test_name##_Test
  7092. // Helper macro for defining tests.
  7093. #define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
  7094. class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
  7095. : public parent_class { \
  7096. public: \
  7097. GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
  7098. \
  7099. private: \
  7100. virtual void TestBody(); \
  7101. static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
  7102. GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
  7103. test_name)); \
  7104. }; \
  7105. \
  7106. ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
  7107. test_name)::test_info_ = \
  7108. ::testing::internal::MakeAndRegisterTestInfo( \
  7109. #test_suite_name, #test_name, nullptr, nullptr, \
  7110. ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
  7111. ::testing::internal::SuiteApiResolver< \
  7112. parent_class>::GetSetUpCaseOrSuite(), \
  7113. ::testing::internal::SuiteApiResolver< \
  7114. parent_class>::GetTearDownCaseOrSuite(), \
  7115. new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
  7116. test_suite_name, test_name)>); \
  7117. void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
  7118. // Internal Macro to mark an API deprecated, for googletest usage only
  7119. // Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or
  7120. // GTEST_INTERNAL_DEPRECATED(message) <return_type> myFunction(); Every usage of
  7121. // a deprecated entity will trigger a warning when compiled with
  7122. // `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler).
  7123. // For msvc /W3 option will need to be used
  7124. // Note that for 'other' compilers this macro evaluates to nothing to prevent
  7125. // compilations errors.
  7126. #if defined(_MSC_VER)
  7127. #define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))
  7128. #elif defined(__GNUC__)
  7129. #define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
  7130. #else
  7131. #define GTEST_INTERNAL_DEPRECATED(message)
  7132. #endif
  7133. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
  7134. // Copyright 2005, Google Inc.
  7135. // All rights reserved.
  7136. //
  7137. // Redistribution and use in source and binary forms, with or without
  7138. // modification, are permitted provided that the following conditions are
  7139. // met:
  7140. //
  7141. // * Redistributions of source code must retain the above copyright
  7142. // notice, this list of conditions and the following disclaimer.
  7143. // * Redistributions in binary form must reproduce the above
  7144. // copyright notice, this list of conditions and the following disclaimer
  7145. // in the documentation and/or other materials provided with the
  7146. // distribution.
  7147. // * Neither the name of Google Inc. nor the names of its
  7148. // contributors may be used to endorse or promote products derived from
  7149. // this software without specific prior written permission.
  7150. //
  7151. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  7152. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7153. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  7154. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7155. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  7156. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7157. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  7158. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7159. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7160. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  7161. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7162. //
  7163. // The Google C++ Testing and Mocking Framework (Google Test)
  7164. //
  7165. // This header file defines the public API for death tests. It is
  7166. // #included by gtest.h so a user doesn't need to include this
  7167. // directly.
  7168. // GOOGLETEST_CM0001 DO NOT DELETE
  7169. #ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
  7170. #define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
  7171. // Copyright 2005, Google Inc.
  7172. // All rights reserved.
  7173. //
  7174. // Redistribution and use in source and binary forms, with or without
  7175. // modification, are permitted provided that the following conditions are
  7176. // met:
  7177. //
  7178. // * Redistributions of source code must retain the above copyright
  7179. // notice, this list of conditions and the following disclaimer.
  7180. // * Redistributions in binary form must reproduce the above
  7181. // copyright notice, this list of conditions and the following disclaimer
  7182. // in the documentation and/or other materials provided with the
  7183. // distribution.
  7184. // * Neither the name of Google Inc. nor the names of its
  7185. // contributors may be used to endorse or promote products derived from
  7186. // this software without specific prior written permission.
  7187. //
  7188. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  7189. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7190. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  7191. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7192. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  7193. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7194. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  7195. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7196. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7197. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  7198. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7199. //
  7200. // The Google C++ Testing and Mocking Framework (Google Test)
  7201. //
  7202. // This header file defines internal utilities needed for implementing
  7203. // death tests. They are subject to change without notice.
  7204. // GOOGLETEST_CM0001 DO NOT DELETE
  7205. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
  7206. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
  7207. // Copyright 2007, Google Inc.
  7208. // All rights reserved.
  7209. //
  7210. // Redistribution and use in source and binary forms, with or without
  7211. // modification, are permitted provided that the following conditions are
  7212. // met:
  7213. //
  7214. // * Redistributions of source code must retain the above copyright
  7215. // notice, this list of conditions and the following disclaimer.
  7216. // * Redistributions in binary form must reproduce the above
  7217. // copyright notice, this list of conditions and the following disclaimer
  7218. // in the documentation and/or other materials provided with the
  7219. // distribution.
  7220. // * Neither the name of Google Inc. nor the names of its
  7221. // contributors may be used to endorse or promote products derived from
  7222. // this software without specific prior written permission.
  7223. //
  7224. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  7225. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7226. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  7227. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7228. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  7229. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7230. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  7231. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7232. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7233. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  7234. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7235. // The Google C++ Testing and Mocking Framework (Google Test)
  7236. //
  7237. // This file implements just enough of the matcher interface to allow
  7238. // EXPECT_DEATH and friends to accept a matcher argument.
  7239. // IWYU pragma: private, include "testing/base/public/gunit.h"
  7240. // IWYU pragma: friend third_party/googletest/googlemock/.*
  7241. // IWYU pragma: friend third_party/googletest/googletest/.*
  7242. #ifndef GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
  7243. #define GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
  7244. #include <memory>
  7245. #include <ostream>
  7246. #include <string>
  7247. // Copyright 2007, Google Inc.
  7248. // All rights reserved.
  7249. //
  7250. // Redistribution and use in source and binary forms, with or without
  7251. // modification, are permitted provided that the following conditions are
  7252. // met:
  7253. //
  7254. // * Redistributions of source code must retain the above copyright
  7255. // notice, this list of conditions and the following disclaimer.
  7256. // * Redistributions in binary form must reproduce the above
  7257. // copyright notice, this list of conditions and the following disclaimer
  7258. // in the documentation and/or other materials provided with the
  7259. // distribution.
  7260. // * Neither the name of Google Inc. nor the names of its
  7261. // contributors may be used to endorse or promote products derived from
  7262. // this software without specific prior written permission.
  7263. //
  7264. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  7265. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7266. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  7267. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7268. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  7269. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  7270. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  7271. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7272. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7273. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  7274. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7275. // Google Test - The Google C++ Testing and Mocking Framework
  7276. //
  7277. // This file implements a universal value printer that can print a
  7278. // value of any type T:
  7279. //
  7280. // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);
  7281. //
  7282. // A user can teach this function how to print a class type T by
  7283. // defining either operator<<() or PrintTo() in the namespace that
  7284. // defines T. More specifically, the FIRST defined function in the
  7285. // following list will be used (assuming T is defined in namespace
  7286. // foo):
  7287. //
  7288. // 1. foo::PrintTo(const T&, ostream*)
  7289. // 2. operator<<(ostream&, const T&) defined in either foo or the
  7290. // global namespace.
  7291. //
  7292. // However if T is an STL-style container then it is printed element-wise
  7293. // unless foo::PrintTo(const T&, ostream*) is defined. Note that
  7294. // operator<<() is ignored for container types.
  7295. //
  7296. // If none of the above is defined, it will print the debug string of
  7297. // the value if it is a protocol buffer, or print the raw bytes in the
  7298. // value otherwise.
  7299. //
  7300. // To aid debugging: when T is a reference type, the address of the
  7301. // value is also printed; when T is a (const) char pointer, both the
  7302. // pointer value and the NUL-terminated string it points to are
  7303. // printed.
  7304. //
  7305. // We also provide some convenient wrappers:
  7306. //
  7307. // // Prints a value to a string. For a (const or not) char
  7308. // // pointer, the NUL-terminated string (but not the pointer) is
  7309. // // printed.
  7310. // std::string ::testing::PrintToString(const T& value);
  7311. //
  7312. // // Prints a value tersely: for a reference type, the referenced
  7313. // // value (but not the address) is printed; for a (const or not) char
  7314. // // pointer, the NUL-terminated string (but not the pointer) is
  7315. // // printed.
  7316. // void ::testing::internal::UniversalTersePrint(const T& value, ostream*);
  7317. //
  7318. // // Prints value using the type inferred by the compiler. The difference
  7319. // // from UniversalTersePrint() is that this function prints both the
  7320. // // pointer and the NUL-terminated string for a (const or not) char pointer.
  7321. // void ::testing::internal::UniversalPrint(const T& value, ostream*);
  7322. //
  7323. // // Prints the fields of a tuple tersely to a string vector, one
  7324. // // element for each field. Tuple support must be enabled in
  7325. // // gtest-port.h.
  7326. // std::vector<string> UniversalTersePrintTupleFieldsToStrings(
  7327. // const Tuple& value);
  7328. //
  7329. // Known limitation:
  7330. //
  7331. // The print primitives print the elements of an STL-style container
  7332. // using the compiler-inferred type of *iter where iter is a
  7333. // const_iterator of the container. When const_iterator is an input
  7334. // iterator but not a forward iterator, this inferred type may not
  7335. // match value_type, and the print output may be incorrect. In
  7336. // practice, this is rarely a problem as for most containers
  7337. // const_iterator is a forward iterator. We'll fix this if there's an
  7338. // actual need for it. Note that this fix cannot rely on value_type
  7339. // being defined as many user-defined container types don't have
  7340. // value_type.
  7341. // GOOGLETEST_CM0001 DO NOT DELETE
  7342. #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
  7343. #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
  7344. #include <functional>
  7345. #include <ostream> // NOLINT
  7346. #include <sstream>
  7347. #include <string>
  7348. #include <tuple>
  7349. #include <type_traits>
  7350. #include <utility>
  7351. #include <vector>
  7352. #if GTEST_HAS_ABSL
  7353. #include "absl/strings/string_view.h"
  7354. #include "absl/types/optional.h"
  7355. #include "absl/types/variant.h"
  7356. #endif // GTEST_HAS_ABSL
  7357. namespace testing {
  7358. // Definitions in the 'internal' and 'internal2' name spaces are
  7359. // subject to change without notice. DO NOT USE THEM IN USER CODE!
  7360. namespace internal2 {
  7361. // Prints the given number of bytes in the given object to the given
  7362. // ostream.
  7363. GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
  7364. size_t count,
  7365. ::std::ostream* os);
  7366. // For selecting which printer to use when a given type has neither <<
  7367. // nor PrintTo().
  7368. enum TypeKind {
  7369. kProtobuf, // a protobuf type
  7370. kConvertibleToInteger, // a type implicitly convertible to BiggestInt
  7371. // (e.g. a named or unnamed enum type)
  7372. #if GTEST_HAS_ABSL
  7373. kConvertibleToStringView, // a type implicitly convertible to
  7374. // absl::string_view
  7375. #endif
  7376. kOtherType // anything else
  7377. };
  7378. // TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
  7379. // by the universal printer to print a value of type T when neither
  7380. // operator<< nor PrintTo() is defined for T, where kTypeKind is the
  7381. // "kind" of T as defined by enum TypeKind.
  7382. template <typename T, TypeKind kTypeKind>
  7383. class TypeWithoutFormatter {
  7384. public:
  7385. // This default version is called when kTypeKind is kOtherType.
  7386. static void PrintValue(const T& value, ::std::ostream* os) {
  7387. PrintBytesInObjectTo(static_cast<const unsigned char*>(
  7388. reinterpret_cast<const void*>(&value)),
  7389. sizeof(value), os);
  7390. }
  7391. };
  7392. // We print a protobuf using its ShortDebugString() when the string
  7393. // doesn't exceed this many characters; otherwise we print it using
  7394. // DebugString() for better readability.
  7395. const size_t kProtobufOneLinerMaxLength = 50;
  7396. template <typename T>
  7397. class TypeWithoutFormatter<T, kProtobuf> {
  7398. public:
  7399. static void PrintValue(const T& value, ::std::ostream* os) {
  7400. std::string pretty_str = value.ShortDebugString();
  7401. if (pretty_str.length() > kProtobufOneLinerMaxLength) {
  7402. pretty_str = "\n" + value.DebugString();
  7403. }
  7404. *os << ("<" + pretty_str + ">");
  7405. }
  7406. };
  7407. template <typename T>
  7408. class TypeWithoutFormatter<T, kConvertibleToInteger> {
  7409. public:
  7410. // Since T has no << operator or PrintTo() but can be implicitly
  7411. // converted to BiggestInt, we print it as a BiggestInt.
  7412. //
  7413. // Most likely T is an enum type (either named or unnamed), in which
  7414. // case printing it as an integer is the desired behavior. In case
  7415. // T is not an enum, printing it as an integer is the best we can do
  7416. // given that it has no user-defined printer.
  7417. static void PrintValue(const T& value, ::std::ostream* os) {
  7418. const internal::BiggestInt kBigInt = value;
  7419. *os << kBigInt;
  7420. }
  7421. };
  7422. #if GTEST_HAS_ABSL
  7423. template <typename T>
  7424. class TypeWithoutFormatter<T, kConvertibleToStringView> {
  7425. public:
  7426. // Since T has neither operator<< nor PrintTo() but can be implicitly
  7427. // converted to absl::string_view, we print it as a absl::string_view.
  7428. //
  7429. // Note: the implementation is further below, as it depends on
  7430. // internal::PrintTo symbol which is defined later in the file.
  7431. static void PrintValue(const T& value, ::std::ostream* os);
  7432. };
  7433. #endif
  7434. // Prints the given value to the given ostream. If the value is a
  7435. // protocol message, its debug string is printed; if it's an enum or
  7436. // of a type implicitly convertible to BiggestInt, it's printed as an
  7437. // integer; otherwise the bytes in the value are printed. This is
  7438. // what UniversalPrinter<T>::Print() does when it knows nothing about
  7439. // type T and T has neither << operator nor PrintTo().
  7440. //
  7441. // A user can override this behavior for a class type Foo by defining
  7442. // a << operator in the namespace where Foo is defined.
  7443. //
  7444. // We put this operator in namespace 'internal2' instead of 'internal'
  7445. // to simplify the implementation, as much code in 'internal' needs to
  7446. // use << in STL, which would conflict with our own << were it defined
  7447. // in 'internal'.
  7448. //
  7449. // Note that this operator<< takes a generic std::basic_ostream<Char,
  7450. // CharTraits> type instead of the more restricted std::ostream. If
  7451. // we define it to take an std::ostream instead, we'll get an
  7452. // "ambiguous overloads" compiler error when trying to print a type
  7453. // Foo that supports streaming to std::basic_ostream<Char,
  7454. // CharTraits>, as the compiler cannot tell whether
  7455. // operator<<(std::ostream&, const T&) or
  7456. // operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
  7457. // specific.
  7458. template <typename Char, typename CharTraits, typename T>
  7459. ::std::basic_ostream<Char, CharTraits>& operator<<(
  7460. ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
  7461. TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
  7462. ? kProtobuf
  7463. : internal::ImplicitlyConvertible<
  7464. const T&, internal::BiggestInt>::value
  7465. ? kConvertibleToInteger
  7466. :
  7467. #if GTEST_HAS_ABSL
  7468. internal::ImplicitlyConvertible<
  7469. const T&, absl::string_view>::value
  7470. ? kConvertibleToStringView
  7471. :
  7472. #endif
  7473. kOtherType)>::PrintValue(x, &os);
  7474. return os;
  7475. }
  7476. } // namespace internal2
  7477. } // namespace testing
  7478. // This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
  7479. // magic needed for implementing UniversalPrinter won't work.
  7480. namespace testing_internal {
  7481. // Used to print a value that is not an STL-style container when the
  7482. // user doesn't define PrintTo() for it.
  7483. template <typename T>
  7484. void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
  7485. // With the following statement, during unqualified name lookup,
  7486. // testing::internal2::operator<< appears as if it was declared in
  7487. // the nearest enclosing namespace that contains both
  7488. // ::testing_internal and ::testing::internal2, i.e. the global
  7489. // namespace. For more details, refer to the C++ Standard section
  7490. // 7.3.4-1 [namespace.udir]. This allows us to fall back onto
  7491. // testing::internal2::operator<< in case T doesn't come with a <<
  7492. // operator.
  7493. //
  7494. // We cannot write 'using ::testing::internal2::operator<<;', which
  7495. // gcc 3.3 fails to compile due to a compiler bug.
  7496. using namespace ::testing::internal2; // NOLINT
  7497. // Assuming T is defined in namespace foo, in the next statement,
  7498. // the compiler will consider all of:
  7499. //
  7500. // 1. foo::operator<< (thanks to Koenig look-up),
  7501. // 2. ::operator<< (as the current namespace is enclosed in ::),
  7502. // 3. testing::internal2::operator<< (thanks to the using statement above).
  7503. //
  7504. // The operator<< whose type matches T best will be picked.
  7505. //
  7506. // We deliberately allow #2 to be a candidate, as sometimes it's
  7507. // impossible to define #1 (e.g. when foo is ::std, defining
  7508. // anything in it is undefined behavior unless you are a compiler
  7509. // vendor.).
  7510. *os << value;
  7511. }
  7512. } // namespace testing_internal
  7513. namespace testing {
  7514. namespace internal {
  7515. // FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
  7516. // value of type ToPrint that is an operand of a comparison assertion
  7517. // (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in
  7518. // the comparison, and is used to help determine the best way to
  7519. // format the value. In particular, when the value is a C string
  7520. // (char pointer) and the other operand is an STL string object, we
  7521. // want to format the C string as a string, since we know it is
  7522. // compared by value with the string object. If the value is a char
  7523. // pointer but the other operand is not an STL string object, we don't
  7524. // know whether the pointer is supposed to point to a NUL-terminated
  7525. // string, and thus want to print it as a pointer to be safe.
  7526. //
  7527. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  7528. // The default case.
  7529. template <typename ToPrint, typename OtherOperand>
  7530. class FormatForComparison {
  7531. public:
  7532. static ::std::string Format(const ToPrint& value) {
  7533. return ::testing::PrintToString(value);
  7534. }
  7535. };
  7536. // Array.
  7537. template <typename ToPrint, size_t N, typename OtherOperand>
  7538. class FormatForComparison<ToPrint[N], OtherOperand> {
  7539. public:
  7540. static ::std::string Format(const ToPrint* value) {
  7541. return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
  7542. }
  7543. };
  7544. // By default, print C string as pointers to be safe, as we don't know
  7545. // whether they actually point to a NUL-terminated string.
  7546. #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \
  7547. template <typename OtherOperand> \
  7548. class FormatForComparison<CharType*, OtherOperand> { \
  7549. public: \
  7550. static ::std::string Format(CharType* value) { \
  7551. return ::testing::PrintToString(static_cast<const void*>(value)); \
  7552. } \
  7553. }
  7554. GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
  7555. GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
  7556. GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
  7557. GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
  7558. #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
  7559. // If a C string is compared with an STL string object, we know it's meant
  7560. // to point to a NUL-terminated string, and thus can print it as a string.
  7561. #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
  7562. template <> \
  7563. class FormatForComparison<CharType*, OtherStringType> { \
  7564. public: \
  7565. static ::std::string Format(CharType* value) { \
  7566. return ::testing::PrintToString(value); \
  7567. } \
  7568. }
  7569. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
  7570. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
  7571. #if GTEST_HAS_GLOBAL_STRING
  7572. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);
  7573. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);
  7574. #endif
  7575. #if GTEST_HAS_GLOBAL_WSTRING
  7576. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);
  7577. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);
  7578. #endif
  7579. #if GTEST_HAS_STD_WSTRING
  7580. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
  7581. GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
  7582. #endif
  7583. #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
  7584. // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)
  7585. // operand to be used in a failure message. The type (but not value)
  7586. // of the other operand may affect the format. This allows us to
  7587. // print a char* as a raw pointer when it is compared against another
  7588. // char* or void*, and print it as a C string when it is compared
  7589. // against an std::string object, for example.
  7590. //
  7591. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  7592. template <typename T1, typename T2>
  7593. std::string FormatForComparisonFailureMessage(
  7594. const T1& value, const T2& /* other_operand */) {
  7595. return FormatForComparison<T1, T2>::Format(value);
  7596. }
  7597. // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given
  7598. // value to the given ostream. The caller must ensure that
  7599. // 'ostream_ptr' is not NULL, or the behavior is undefined.
  7600. //
  7601. // We define UniversalPrinter as a class template (as opposed to a
  7602. // function template), as we need to partially specialize it for
  7603. // reference types, which cannot be done with function templates.
  7604. template <typename T>
  7605. class UniversalPrinter;
  7606. template <typename T>
  7607. void UniversalPrint(const T& value, ::std::ostream* os);
  7608. enum DefaultPrinterType {
  7609. kPrintContainer,
  7610. kPrintPointer,
  7611. kPrintFunctionPointer,
  7612. kPrintOther,
  7613. };
  7614. template <DefaultPrinterType type> struct WrapPrinterType {};
  7615. // Used to print an STL-style container when the user doesn't define
  7616. // a PrintTo() for it.
  7617. template <typename C>
  7618. void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
  7619. const C& container, ::std::ostream* os) {
  7620. const size_t kMaxCount = 32; // The maximum number of elements to print.
  7621. *os << '{';
  7622. size_t count = 0;
  7623. for (typename C::const_iterator it = container.begin();
  7624. it != container.end(); ++it, ++count) {
  7625. if (count > 0) {
  7626. *os << ',';
  7627. if (count == kMaxCount) { // Enough has been printed.
  7628. *os << " ...";
  7629. break;
  7630. }
  7631. }
  7632. *os << ' ';
  7633. // We cannot call PrintTo(*it, os) here as PrintTo() doesn't
  7634. // handle *it being a native array.
  7635. internal::UniversalPrint(*it, os);
  7636. }
  7637. if (count > 0) {
  7638. *os << ' ';
  7639. }
  7640. *os << '}';
  7641. }
  7642. // Used to print a pointer that is neither a char pointer nor a member
  7643. // pointer, when the user doesn't define PrintTo() for it. (A member
  7644. // variable pointer or member function pointer doesn't really point to
  7645. // a location in the address space. Their representation is
  7646. // implementation-defined. Therefore they will be printed as raw
  7647. // bytes.)
  7648. template <typename T>
  7649. void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
  7650. T* p, ::std::ostream* os) {
  7651. if (p == nullptr) {
  7652. *os << "NULL";
  7653. } else {
  7654. // T is not a function type. We just call << to print p,
  7655. // relying on ADL to pick up user-defined << for their pointer
  7656. // types, if any.
  7657. *os << p;
  7658. }
  7659. }
  7660. template <typename T>
  7661. void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,
  7662. T* p, ::std::ostream* os) {
  7663. if (p == nullptr) {
  7664. *os << "NULL";
  7665. } else {
  7666. // T is a function type, so '*os << p' doesn't do what we want
  7667. // (it just prints p as bool). We want to print p as a const
  7668. // void*.
  7669. *os << reinterpret_cast<const void*>(p);
  7670. }
  7671. }
  7672. // Used to print a non-container, non-pointer value when the user
  7673. // doesn't define PrintTo() for it.
  7674. template <typename T>
  7675. void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
  7676. const T& value, ::std::ostream* os) {
  7677. ::testing_internal::DefaultPrintNonContainerTo(value, os);
  7678. }
  7679. // Prints the given value using the << operator if it has one;
  7680. // otherwise prints the bytes in it. This is what
  7681. // UniversalPrinter<T>::Print() does when PrintTo() is not specialized
  7682. // or overloaded for type T.
  7683. //
  7684. // A user can override this behavior for a class type Foo by defining
  7685. // an overload of PrintTo() in the namespace where Foo is defined. We
  7686. // give the user this option as sometimes defining a << operator for
  7687. // Foo is not desirable (e.g. the coding style may prevent doing it,
  7688. // or there is already a << operator but it doesn't do what the user
  7689. // wants).
  7690. template <typename T>
  7691. void PrintTo(const T& value, ::std::ostream* os) {
  7692. // DefaultPrintTo() is overloaded. The type of its first argument
  7693. // determines which version will be picked.
  7694. //
  7695. // Note that we check for container types here, prior to we check
  7696. // for protocol message types in our operator<<. The rationale is:
  7697. //
  7698. // For protocol messages, we want to give people a chance to
  7699. // override Google Mock's format by defining a PrintTo() or
  7700. // operator<<. For STL containers, other formats can be
  7701. // incompatible with Google Mock's format for the container
  7702. // elements; therefore we check for container types here to ensure
  7703. // that our format is used.
  7704. //
  7705. // Note that MSVC and clang-cl do allow an implicit conversion from
  7706. // pointer-to-function to pointer-to-object, but clang-cl warns on it.
  7707. // So don't use ImplicitlyConvertible if it can be helped since it will
  7708. // cause this warning, and use a separate overload of DefaultPrintTo for
  7709. // function pointers so that the `*os << p` in the object pointer overload
  7710. // doesn't cause that warning either.
  7711. DefaultPrintTo(
  7712. WrapPrinterType <
  7713. (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
  7714. !IsRecursiveContainer<T>::value
  7715. ? kPrintContainer
  7716. : !std::is_pointer<T>::value
  7717. ? kPrintOther
  7718. : std::is_function<typename std::remove_pointer<T>::type>::value
  7719. ? kPrintFunctionPointer
  7720. : kPrintPointer > (),
  7721. value, os);
  7722. }
  7723. // The following list of PrintTo() overloads tells
  7724. // UniversalPrinter<T>::Print() how to print standard types (built-in
  7725. // types, strings, plain arrays, and pointers).
  7726. // Overloads for various char types.
  7727. GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
  7728. GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
  7729. inline void PrintTo(char c, ::std::ostream* os) {
  7730. // When printing a plain char, we always treat it as unsigned. This
  7731. // way, the output won't be affected by whether the compiler thinks
  7732. // char is signed or not.
  7733. PrintTo(static_cast<unsigned char>(c), os);
  7734. }
  7735. // Overloads for other simple built-in types.
  7736. inline void PrintTo(bool x, ::std::ostream* os) {
  7737. *os << (x ? "true" : "false");
  7738. }
  7739. // Overload for wchar_t type.
  7740. // Prints a wchar_t as a symbol if it is printable or as its internal
  7741. // code otherwise and also as its decimal code (except for L'\0').
  7742. // The L'\0' char is printed as "L'\\0'". The decimal code is printed
  7743. // as signed integer when wchar_t is implemented by the compiler
  7744. // as a signed type and is printed as an unsigned integer when wchar_t
  7745. // is implemented as an unsigned type.
  7746. GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
  7747. // Overloads for C strings.
  7748. GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
  7749. inline void PrintTo(char* s, ::std::ostream* os) {
  7750. PrintTo(ImplicitCast_<const char*>(s), os);
  7751. }
  7752. // signed/unsigned char is often used for representing binary data, so
  7753. // we print pointers to it as void* to be safe.
  7754. inline void PrintTo(const signed char* s, ::std::ostream* os) {
  7755. PrintTo(ImplicitCast_<const void*>(s), os);
  7756. }
  7757. inline void PrintTo(signed char* s, ::std::ostream* os) {
  7758. PrintTo(ImplicitCast_<const void*>(s), os);
  7759. }
  7760. inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
  7761. PrintTo(ImplicitCast_<const void*>(s), os);
  7762. }
  7763. inline void PrintTo(unsigned char* s, ::std::ostream* os) {
  7764. PrintTo(ImplicitCast_<const void*>(s), os);
  7765. }
  7766. // MSVC can be configured to define wchar_t as a typedef of unsigned
  7767. // short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native
  7768. // type. When wchar_t is a typedef, defining an overload for const
  7769. // wchar_t* would cause unsigned short* be printed as a wide string,
  7770. // possibly causing invalid memory accesses.
  7771. #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
  7772. // Overloads for wide C strings
  7773. GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
  7774. inline void PrintTo(wchar_t* s, ::std::ostream* os) {
  7775. PrintTo(ImplicitCast_<const wchar_t*>(s), os);
  7776. }
  7777. #endif
  7778. // Overload for C arrays. Multi-dimensional arrays are printed
  7779. // properly.
  7780. // Prints the given number of elements in an array, without printing
  7781. // the curly braces.
  7782. template <typename T>
  7783. void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
  7784. UniversalPrint(a[0], os);
  7785. for (size_t i = 1; i != count; i++) {
  7786. *os << ", ";
  7787. UniversalPrint(a[i], os);
  7788. }
  7789. }
  7790. // Overloads for ::string and ::std::string.
  7791. #if GTEST_HAS_GLOBAL_STRING
  7792. GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
  7793. inline void PrintTo(const ::string& s, ::std::ostream* os) {
  7794. PrintStringTo(s, os);
  7795. }
  7796. #endif // GTEST_HAS_GLOBAL_STRING
  7797. GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
  7798. inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
  7799. PrintStringTo(s, os);
  7800. }
  7801. // Overloads for ::wstring and ::std::wstring.
  7802. #if GTEST_HAS_GLOBAL_WSTRING
  7803. GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
  7804. inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
  7805. PrintWideStringTo(s, os);
  7806. }
  7807. #endif // GTEST_HAS_GLOBAL_WSTRING
  7808. #if GTEST_HAS_STD_WSTRING
  7809. GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
  7810. inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
  7811. PrintWideStringTo(s, os);
  7812. }
  7813. #endif // GTEST_HAS_STD_WSTRING
  7814. #if GTEST_HAS_ABSL
  7815. // Overload for absl::string_view.
  7816. inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
  7817. PrintTo(::std::string(sp), os);
  7818. }
  7819. #endif // GTEST_HAS_ABSL
  7820. inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
  7821. template <typename T>
  7822. void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
  7823. // Delegate to wrapped value.
  7824. PrintTo(ref.get(), os);
  7825. }
  7826. // Helper function for printing a tuple. T must be instantiated with
  7827. // a tuple type.
  7828. template <typename T>
  7829. void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
  7830. ::std::ostream*) {}
  7831. template <typename T, size_t I>
  7832. void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
  7833. ::std::ostream* os) {
  7834. PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
  7835. GTEST_INTENTIONAL_CONST_COND_PUSH_()
  7836. if (I > 1) {
  7837. GTEST_INTENTIONAL_CONST_COND_POP_()
  7838. *os << ", ";
  7839. }
  7840. UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
  7841. std::get<I - 1>(t), os);
  7842. }
  7843. template <typename... Types>
  7844. void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
  7845. *os << "(";
  7846. PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
  7847. *os << ")";
  7848. }
  7849. // Overload for std::pair.
  7850. template <typename T1, typename T2>
  7851. void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
  7852. *os << '(';
  7853. // We cannot use UniversalPrint(value.first, os) here, as T1 may be
  7854. // a reference type. The same for printing value.second.
  7855. UniversalPrinter<T1>::Print(value.first, os);
  7856. *os << ", ";
  7857. UniversalPrinter<T2>::Print(value.second, os);
  7858. *os << ')';
  7859. }
  7860. // Implements printing a non-reference type T by letting the compiler
  7861. // pick the right overload of PrintTo() for T.
  7862. template <typename T>
  7863. class UniversalPrinter {
  7864. public:
  7865. // MSVC warns about adding const to a function type, so we want to
  7866. // disable the warning.
  7867. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
  7868. // Note: we deliberately don't call this PrintTo(), as that name
  7869. // conflicts with ::testing::internal::PrintTo in the body of the
  7870. // function.
  7871. static void Print(const T& value, ::std::ostream* os) {
  7872. // By default, ::testing::internal::PrintTo() is used for printing
  7873. // the value.
  7874. //
  7875. // Thanks to Koenig look-up, if T is a class and has its own
  7876. // PrintTo() function defined in its namespace, that function will
  7877. // be visible here. Since it is more specific than the generic ones
  7878. // in ::testing::internal, it will be picked by the compiler in the
  7879. // following statement - exactly what we want.
  7880. PrintTo(value, os);
  7881. }
  7882. GTEST_DISABLE_MSC_WARNINGS_POP_()
  7883. };
  7884. #if GTEST_HAS_ABSL
  7885. // Printer for absl::optional
  7886. template <typename T>
  7887. class UniversalPrinter<::absl::optional<T>> {
  7888. public:
  7889. static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
  7890. *os << '(';
  7891. if (!value) {
  7892. *os << "nullopt";
  7893. } else {
  7894. UniversalPrint(*value, os);
  7895. }
  7896. *os << ')';
  7897. }
  7898. };
  7899. // Printer for absl::variant
  7900. template <typename... T>
  7901. class UniversalPrinter<::absl::variant<T...>> {
  7902. public:
  7903. static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {
  7904. *os << '(';
  7905. absl::visit(Visitor{os}, value);
  7906. *os << ')';
  7907. }
  7908. private:
  7909. struct Visitor {
  7910. template <typename U>
  7911. void operator()(const U& u) const {
  7912. *os << "'" << GetTypeName<U>() << "' with value ";
  7913. UniversalPrint(u, os);
  7914. }
  7915. ::std::ostream* os;
  7916. };
  7917. };
  7918. #endif // GTEST_HAS_ABSL
  7919. // UniversalPrintArray(begin, len, os) prints an array of 'len'
  7920. // elements, starting at address 'begin'.
  7921. template <typename T>
  7922. void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
  7923. if (len == 0) {
  7924. *os << "{}";
  7925. } else {
  7926. *os << "{ ";
  7927. const size_t kThreshold = 18;
  7928. const size_t kChunkSize = 8;
  7929. // If the array has more than kThreshold elements, we'll have to
  7930. // omit some details by printing only the first and the last
  7931. // kChunkSize elements.
  7932. if (len <= kThreshold) {
  7933. PrintRawArrayTo(begin, len, os);
  7934. } else {
  7935. PrintRawArrayTo(begin, kChunkSize, os);
  7936. *os << ", ..., ";
  7937. PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
  7938. }
  7939. *os << " }";
  7940. }
  7941. }
  7942. // This overload prints a (const) char array compactly.
  7943. GTEST_API_ void UniversalPrintArray(
  7944. const char* begin, size_t len, ::std::ostream* os);
  7945. // This overload prints a (const) wchar_t array compactly.
  7946. GTEST_API_ void UniversalPrintArray(
  7947. const wchar_t* begin, size_t len, ::std::ostream* os);
  7948. // Implements printing an array type T[N].
  7949. template <typename T, size_t N>
  7950. class UniversalPrinter<T[N]> {
  7951. public:
  7952. // Prints the given array, omitting some elements when there are too
  7953. // many.
  7954. static void Print(const T (&a)[N], ::std::ostream* os) {
  7955. UniversalPrintArray(a, N, os);
  7956. }
  7957. };
  7958. // Implements printing a reference type T&.
  7959. template <typename T>
  7960. class UniversalPrinter<T&> {
  7961. public:
  7962. // MSVC warns about adding const to a function type, so we want to
  7963. // disable the warning.
  7964. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
  7965. static void Print(const T& value, ::std::ostream* os) {
  7966. // Prints the address of the value. We use reinterpret_cast here
  7967. // as static_cast doesn't compile when T is a function type.
  7968. *os << "@" << reinterpret_cast<const void*>(&value) << " ";
  7969. // Then prints the value itself.
  7970. UniversalPrint(value, os);
  7971. }
  7972. GTEST_DISABLE_MSC_WARNINGS_POP_()
  7973. };
  7974. // Prints a value tersely: for a reference type, the referenced value
  7975. // (but not the address) is printed; for a (const) char pointer, the
  7976. // NUL-terminated string (but not the pointer) is printed.
  7977. template <typename T>
  7978. class UniversalTersePrinter {
  7979. public:
  7980. static void Print(const T& value, ::std::ostream* os) {
  7981. UniversalPrint(value, os);
  7982. }
  7983. };
  7984. template <typename T>
  7985. class UniversalTersePrinter<T&> {
  7986. public:
  7987. static void Print(const T& value, ::std::ostream* os) {
  7988. UniversalPrint(value, os);
  7989. }
  7990. };
  7991. template <typename T, size_t N>
  7992. class UniversalTersePrinter<T[N]> {
  7993. public:
  7994. static void Print(const T (&value)[N], ::std::ostream* os) {
  7995. UniversalPrinter<T[N]>::Print(value, os);
  7996. }
  7997. };
  7998. template <>
  7999. class UniversalTersePrinter<const char*> {
  8000. public:
  8001. static void Print(const char* str, ::std::ostream* os) {
  8002. if (str == nullptr) {
  8003. *os << "NULL";
  8004. } else {
  8005. UniversalPrint(std::string(str), os);
  8006. }
  8007. }
  8008. };
  8009. template <>
  8010. class UniversalTersePrinter<char*> {
  8011. public:
  8012. static void Print(char* str, ::std::ostream* os) {
  8013. UniversalTersePrinter<const char*>::Print(str, os);
  8014. }
  8015. };
  8016. #if GTEST_HAS_STD_WSTRING
  8017. template <>
  8018. class UniversalTersePrinter<const wchar_t*> {
  8019. public:
  8020. static void Print(const wchar_t* str, ::std::ostream* os) {
  8021. if (str == nullptr) {
  8022. *os << "NULL";
  8023. } else {
  8024. UniversalPrint(::std::wstring(str), os);
  8025. }
  8026. }
  8027. };
  8028. #endif
  8029. template <>
  8030. class UniversalTersePrinter<wchar_t*> {
  8031. public:
  8032. static void Print(wchar_t* str, ::std::ostream* os) {
  8033. UniversalTersePrinter<const wchar_t*>::Print(str, os);
  8034. }
  8035. };
  8036. template <typename T>
  8037. void UniversalTersePrint(const T& value, ::std::ostream* os) {
  8038. UniversalTersePrinter<T>::Print(value, os);
  8039. }
  8040. // Prints a value using the type inferred by the compiler. The
  8041. // difference between this and UniversalTersePrint() is that for a
  8042. // (const) char pointer, this prints both the pointer and the
  8043. // NUL-terminated string.
  8044. template <typename T>
  8045. void UniversalPrint(const T& value, ::std::ostream* os) {
  8046. // A workarond for the bug in VC++ 7.1 that prevents us from instantiating
  8047. // UniversalPrinter with T directly.
  8048. typedef T T1;
  8049. UniversalPrinter<T1>::Print(value, os);
  8050. }
  8051. typedef ::std::vector< ::std::string> Strings;
  8052. // Tersely prints the first N fields of a tuple to a string vector,
  8053. // one element for each field.
  8054. template <typename Tuple>
  8055. void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
  8056. Strings*) {}
  8057. template <typename Tuple, size_t I>
  8058. void TersePrintPrefixToStrings(const Tuple& t,
  8059. std::integral_constant<size_t, I>,
  8060. Strings* strings) {
  8061. TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
  8062. strings);
  8063. ::std::stringstream ss;
  8064. UniversalTersePrint(std::get<I - 1>(t), &ss);
  8065. strings->push_back(ss.str());
  8066. }
  8067. // Prints the fields of a tuple tersely to a string vector, one
  8068. // element for each field. See the comment before
  8069. // UniversalTersePrint() for how we define "tersely".
  8070. template <typename Tuple>
  8071. Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
  8072. Strings result;
  8073. TersePrintPrefixToStrings(
  8074. value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
  8075. &result);
  8076. return result;
  8077. }
  8078. } // namespace internal
  8079. #if GTEST_HAS_ABSL
  8080. namespace internal2 {
  8081. template <typename T>
  8082. void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(
  8083. const T& value, ::std::ostream* os) {
  8084. internal::PrintTo(absl::string_view(value), os);
  8085. }
  8086. } // namespace internal2
  8087. #endif
  8088. template <typename T>
  8089. ::std::string PrintToString(const T& value) {
  8090. ::std::stringstream ss;
  8091. internal::UniversalTersePrinter<T>::Print(value, &ss);
  8092. return ss.str();
  8093. }
  8094. } // namespace testing
  8095. // Include any custom printer added by the local installation.
  8096. // We must include this header at the end to make sure it can use the
  8097. // declarations from this file.
  8098. // Copyright 2015, Google Inc.
  8099. // All rights reserved.
  8100. //
  8101. // Redistribution and use in source and binary forms, with or without
  8102. // modification, are permitted provided that the following conditions are
  8103. // met:
  8104. //
  8105. // * Redistributions of source code must retain the above copyright
  8106. // notice, this list of conditions and the following disclaimer.
  8107. // * Redistributions in binary form must reproduce the above
  8108. // copyright notice, this list of conditions and the following disclaimer
  8109. // in the documentation and/or other materials provided with the
  8110. // distribution.
  8111. // * Neither the name of Google Inc. nor the names of its
  8112. // contributors may be used to endorse or promote products derived from
  8113. // this software without specific prior written permission.
  8114. //
  8115. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8116. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  8117. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8118. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  8119. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8120. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  8121. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  8122. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8123. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8124. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  8125. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8126. //
  8127. // This file provides an injection point for custom printers in a local
  8128. // installation of gTest.
  8129. // It will be included from gtest-printers.h and the overrides in this file
  8130. // will be visible to everyone.
  8131. //
  8132. // Injection point for custom user configurations. See README for details
  8133. //
  8134. // ** Custom implementation starts here **
  8135. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
  8136. #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
  8137. #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
  8138. #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
  8139. GTEST_DISABLE_MSC_WARNINGS_PUSH_(
  8140. 4251 5046 /* class A needs to have dll-interface to be used by clients of
  8141. class B */
  8142. /* Symbol involving type with internal linkage not defined */)
  8143. namespace testing {
  8144. // To implement a matcher Foo for type T, define:
  8145. // 1. a class FooMatcherImpl that implements the
  8146. // MatcherInterface<T> interface, and
  8147. // 2. a factory function that creates a Matcher<T> object from a
  8148. // FooMatcherImpl*.
  8149. //
  8150. // The two-level delegation design makes it possible to allow a user
  8151. // to write "v" instead of "Eq(v)" where a Matcher is expected, which
  8152. // is impossible if we pass matchers by pointers. It also eases
  8153. // ownership management as Matcher objects can now be copied like
  8154. // plain values.
  8155. // MatchResultListener is an abstract class. Its << operator can be
  8156. // used by a matcher to explain why a value matches or doesn't match.
  8157. //
  8158. class MatchResultListener {
  8159. public:
  8160. // Creates a listener object with the given underlying ostream. The
  8161. // listener does not own the ostream, and does not dereference it
  8162. // in the constructor or destructor.
  8163. explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
  8164. virtual ~MatchResultListener() = 0; // Makes this class abstract.
  8165. // Streams x to the underlying ostream; does nothing if the ostream
  8166. // is NULL.
  8167. template <typename T>
  8168. MatchResultListener& operator<<(const T& x) {
  8169. if (stream_ != nullptr) *stream_ << x;
  8170. return *this;
  8171. }
  8172. // Returns the underlying ostream.
  8173. ::std::ostream* stream() { return stream_; }
  8174. // Returns true iff the listener is interested in an explanation of
  8175. // the match result. A matcher's MatchAndExplain() method can use
  8176. // this information to avoid generating the explanation when no one
  8177. // intends to hear it.
  8178. bool IsInterested() const { return stream_ != nullptr; }
  8179. private:
  8180. ::std::ostream* const stream_;
  8181. GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
  8182. };
  8183. inline MatchResultListener::~MatchResultListener() {
  8184. }
  8185. // An instance of a subclass of this knows how to describe itself as a
  8186. // matcher.
  8187. class MatcherDescriberInterface {
  8188. public:
  8189. virtual ~MatcherDescriberInterface() {}
  8190. // Describes this matcher to an ostream. The function should print
  8191. // a verb phrase that describes the property a value matching this
  8192. // matcher should have. The subject of the verb phrase is the value
  8193. // being matched. For example, the DescribeTo() method of the Gt(7)
  8194. // matcher prints "is greater than 7".
  8195. virtual void DescribeTo(::std::ostream* os) const = 0;
  8196. // Describes the negation of this matcher to an ostream. For
  8197. // example, if the description of this matcher is "is greater than
  8198. // 7", the negated description could be "is not greater than 7".
  8199. // You are not required to override this when implementing
  8200. // MatcherInterface, but it is highly advised so that your matcher
  8201. // can produce good error messages.
  8202. virtual void DescribeNegationTo(::std::ostream* os) const {
  8203. *os << "not (";
  8204. DescribeTo(os);
  8205. *os << ")";
  8206. }
  8207. };
  8208. // The implementation of a matcher.
  8209. template <typename T>
  8210. class MatcherInterface : public MatcherDescriberInterface {
  8211. public:
  8212. // Returns true iff the matcher matches x; also explains the match
  8213. // result to 'listener' if necessary (see the next paragraph), in
  8214. // the form of a non-restrictive relative clause ("which ...",
  8215. // "whose ...", etc) that describes x. For example, the
  8216. // MatchAndExplain() method of the Pointee(...) matcher should
  8217. // generate an explanation like "which points to ...".
  8218. //
  8219. // Implementations of MatchAndExplain() should add an explanation of
  8220. // the match result *if and only if* they can provide additional
  8221. // information that's not already present (or not obvious) in the
  8222. // print-out of x and the matcher's description. Whether the match
  8223. // succeeds is not a factor in deciding whether an explanation is
  8224. // needed, as sometimes the caller needs to print a failure message
  8225. // when the match succeeds (e.g. when the matcher is used inside
  8226. // Not()).
  8227. //
  8228. // For example, a "has at least 10 elements" matcher should explain
  8229. // what the actual element count is, regardless of the match result,
  8230. // as it is useful information to the reader; on the other hand, an
  8231. // "is empty" matcher probably only needs to explain what the actual
  8232. // size is when the match fails, as it's redundant to say that the
  8233. // size is 0 when the value is already known to be empty.
  8234. //
  8235. // You should override this method when defining a new matcher.
  8236. //
  8237. // It's the responsibility of the caller (Google Test) to guarantee
  8238. // that 'listener' is not NULL. This helps to simplify a matcher's
  8239. // implementation when it doesn't care about the performance, as it
  8240. // can talk to 'listener' without checking its validity first.
  8241. // However, in order to implement dummy listeners efficiently,
  8242. // listener->stream() may be NULL.
  8243. virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
  8244. // Inherits these methods from MatcherDescriberInterface:
  8245. // virtual void DescribeTo(::std::ostream* os) const = 0;
  8246. // virtual void DescribeNegationTo(::std::ostream* os) const;
  8247. };
  8248. namespace internal {
  8249. // Converts a MatcherInterface<T> to a MatcherInterface<const T&>.
  8250. template <typename T>
  8251. class MatcherInterfaceAdapter : public MatcherInterface<const T&> {
  8252. public:
  8253. explicit MatcherInterfaceAdapter(const MatcherInterface<T>* impl)
  8254. : impl_(impl) {}
  8255. ~MatcherInterfaceAdapter() override { delete impl_; }
  8256. void DescribeTo(::std::ostream* os) const override { impl_->DescribeTo(os); }
  8257. void DescribeNegationTo(::std::ostream* os) const override {
  8258. impl_->DescribeNegationTo(os);
  8259. }
  8260. bool MatchAndExplain(const T& x,
  8261. MatchResultListener* listener) const override {
  8262. return impl_->MatchAndExplain(x, listener);
  8263. }
  8264. private:
  8265. const MatcherInterface<T>* const impl_;
  8266. GTEST_DISALLOW_COPY_AND_ASSIGN_(MatcherInterfaceAdapter);
  8267. };
  8268. struct AnyEq {
  8269. template <typename A, typename B>
  8270. bool operator()(const A& a, const B& b) const { return a == b; }
  8271. };
  8272. struct AnyNe {
  8273. template <typename A, typename B>
  8274. bool operator()(const A& a, const B& b) const { return a != b; }
  8275. };
  8276. struct AnyLt {
  8277. template <typename A, typename B>
  8278. bool operator()(const A& a, const B& b) const { return a < b; }
  8279. };
  8280. struct AnyGt {
  8281. template <typename A, typename B>
  8282. bool operator()(const A& a, const B& b) const { return a > b; }
  8283. };
  8284. struct AnyLe {
  8285. template <typename A, typename B>
  8286. bool operator()(const A& a, const B& b) const { return a <= b; }
  8287. };
  8288. struct AnyGe {
  8289. template <typename A, typename B>
  8290. bool operator()(const A& a, const B& b) const { return a >= b; }
  8291. };
  8292. // A match result listener that ignores the explanation.
  8293. class DummyMatchResultListener : public MatchResultListener {
  8294. public:
  8295. DummyMatchResultListener() : MatchResultListener(nullptr) {}
  8296. private:
  8297. GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
  8298. };
  8299. // A match result listener that forwards the explanation to a given
  8300. // ostream. The difference between this and MatchResultListener is
  8301. // that the former is concrete.
  8302. class StreamMatchResultListener : public MatchResultListener {
  8303. public:
  8304. explicit StreamMatchResultListener(::std::ostream* os)
  8305. : MatchResultListener(os) {}
  8306. private:
  8307. GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
  8308. };
  8309. // An internal class for implementing Matcher<T>, which will derive
  8310. // from it. We put functionalities common to all Matcher<T>
  8311. // specializations here to avoid code duplication.
  8312. template <typename T>
  8313. class MatcherBase {
  8314. public:
  8315. // Returns true iff the matcher matches x; also explains the match
  8316. // result to 'listener'.
  8317. bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
  8318. return impl_->MatchAndExplain(x, listener);
  8319. }
  8320. // Returns true iff this matcher matches x.
  8321. bool Matches(const T& x) const {
  8322. DummyMatchResultListener dummy;
  8323. return MatchAndExplain(x, &dummy);
  8324. }
  8325. // Describes this matcher to an ostream.
  8326. void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
  8327. // Describes the negation of this matcher to an ostream.
  8328. void DescribeNegationTo(::std::ostream* os) const {
  8329. impl_->DescribeNegationTo(os);
  8330. }
  8331. // Explains why x matches, or doesn't match, the matcher.
  8332. void ExplainMatchResultTo(const T& x, ::std::ostream* os) const {
  8333. StreamMatchResultListener listener(os);
  8334. MatchAndExplain(x, &listener);
  8335. }
  8336. // Returns the describer for this matcher object; retains ownership
  8337. // of the describer, which is only guaranteed to be alive when
  8338. // this matcher object is alive.
  8339. const MatcherDescriberInterface* GetDescriber() const {
  8340. return impl_.get();
  8341. }
  8342. protected:
  8343. MatcherBase() {}
  8344. // Constructs a matcher from its implementation.
  8345. explicit MatcherBase(const MatcherInterface<const T&>* impl) : impl_(impl) {}
  8346. template <typename U>
  8347. explicit MatcherBase(
  8348. const MatcherInterface<U>* impl,
  8349. typename internal::EnableIf<
  8350. !internal::IsSame<U, const U&>::value>::type* = nullptr)
  8351. : impl_(new internal::MatcherInterfaceAdapter<U>(impl)) {}
  8352. virtual ~MatcherBase() {}
  8353. private:
  8354. std::shared_ptr<const MatcherInterface<const T&>> impl_;
  8355. };
  8356. } // namespace internal
  8357. // A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
  8358. // object that can check whether a value of type T matches. The
  8359. // implementation of Matcher<T> is just a std::shared_ptr to const
  8360. // MatcherInterface<T>. Don't inherit from Matcher!
  8361. template <typename T>
  8362. class Matcher : public internal::MatcherBase<T> {
  8363. public:
  8364. // Constructs a null matcher. Needed for storing Matcher objects in STL
  8365. // containers. A default-constructed matcher is not yet initialized. You
  8366. // cannot use it until a valid value has been assigned to it.
  8367. explicit Matcher() {} // NOLINT
  8368. // Constructs a matcher from its implementation.
  8369. explicit Matcher(const MatcherInterface<const T&>* impl)
  8370. : internal::MatcherBase<T>(impl) {}
  8371. template <typename U>
  8372. explicit Matcher(const MatcherInterface<U>* impl,
  8373. typename internal::EnableIf<
  8374. !internal::IsSame<U, const U&>::value>::type* = nullptr)
  8375. : internal::MatcherBase<T>(impl) {}
  8376. // Implicit constructor here allows people to write
  8377. // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
  8378. Matcher(T value); // NOLINT
  8379. };
  8380. // The following two specializations allow the user to write str
  8381. // instead of Eq(str) and "foo" instead of Eq("foo") when a std::string
  8382. // matcher is expected.
  8383. template <>
  8384. class GTEST_API_ Matcher<const std::string&>
  8385. : public internal::MatcherBase<const std::string&> {
  8386. public:
  8387. Matcher() {}
  8388. explicit Matcher(const MatcherInterface<const std::string&>* impl)
  8389. : internal::MatcherBase<const std::string&>(impl) {}
  8390. // Allows the user to write str instead of Eq(str) sometimes, where
  8391. // str is a std::string object.
  8392. Matcher(const std::string& s); // NOLINT
  8393. #if GTEST_HAS_GLOBAL_STRING
  8394. // Allows the user to write str instead of Eq(str) sometimes, where
  8395. // str is a ::string object.
  8396. Matcher(const ::string& s); // NOLINT
  8397. #endif // GTEST_HAS_GLOBAL_STRING
  8398. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8399. Matcher(const char* s); // NOLINT
  8400. };
  8401. template <>
  8402. class GTEST_API_ Matcher<std::string>
  8403. : public internal::MatcherBase<std::string> {
  8404. public:
  8405. Matcher() {}
  8406. explicit Matcher(const MatcherInterface<const std::string&>* impl)
  8407. : internal::MatcherBase<std::string>(impl) {}
  8408. explicit Matcher(const MatcherInterface<std::string>* impl)
  8409. : internal::MatcherBase<std::string>(impl) {}
  8410. // Allows the user to write str instead of Eq(str) sometimes, where
  8411. // str is a string object.
  8412. Matcher(const std::string& s); // NOLINT
  8413. #if GTEST_HAS_GLOBAL_STRING
  8414. // Allows the user to write str instead of Eq(str) sometimes, where
  8415. // str is a ::string object.
  8416. Matcher(const ::string& s); // NOLINT
  8417. #endif // GTEST_HAS_GLOBAL_STRING
  8418. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8419. Matcher(const char* s); // NOLINT
  8420. };
  8421. #if GTEST_HAS_GLOBAL_STRING
  8422. // The following two specializations allow the user to write str
  8423. // instead of Eq(str) and "foo" instead of Eq("foo") when a ::string
  8424. // matcher is expected.
  8425. template <>
  8426. class GTEST_API_ Matcher<const ::string&>
  8427. : public internal::MatcherBase<const ::string&> {
  8428. public:
  8429. Matcher() {}
  8430. explicit Matcher(const MatcherInterface<const ::string&>* impl)
  8431. : internal::MatcherBase<const ::string&>(impl) {}
  8432. // Allows the user to write str instead of Eq(str) sometimes, where
  8433. // str is a std::string object.
  8434. Matcher(const std::string& s); // NOLINT
  8435. // Allows the user to write str instead of Eq(str) sometimes, where
  8436. // str is a ::string object.
  8437. Matcher(const ::string& s); // NOLINT
  8438. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8439. Matcher(const char* s); // NOLINT
  8440. };
  8441. template <>
  8442. class GTEST_API_ Matcher< ::string>
  8443. : public internal::MatcherBase< ::string> {
  8444. public:
  8445. Matcher() {}
  8446. explicit Matcher(const MatcherInterface<const ::string&>* impl)
  8447. : internal::MatcherBase< ::string>(impl) {}
  8448. explicit Matcher(const MatcherInterface< ::string>* impl)
  8449. : internal::MatcherBase< ::string>(impl) {}
  8450. // Allows the user to write str instead of Eq(str) sometimes, where
  8451. // str is a std::string object.
  8452. Matcher(const std::string& s); // NOLINT
  8453. // Allows the user to write str instead of Eq(str) sometimes, where
  8454. // str is a ::string object.
  8455. Matcher(const ::string& s); // NOLINT
  8456. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8457. Matcher(const char* s); // NOLINT
  8458. };
  8459. #endif // GTEST_HAS_GLOBAL_STRING
  8460. #if GTEST_HAS_ABSL
  8461. // The following two specializations allow the user to write str
  8462. // instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
  8463. // matcher is expected.
  8464. template <>
  8465. class GTEST_API_ Matcher<const absl::string_view&>
  8466. : public internal::MatcherBase<const absl::string_view&> {
  8467. public:
  8468. Matcher() {}
  8469. explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
  8470. : internal::MatcherBase<const absl::string_view&>(impl) {}
  8471. // Allows the user to write str instead of Eq(str) sometimes, where
  8472. // str is a std::string object.
  8473. Matcher(const std::string& s); // NOLINT
  8474. #if GTEST_HAS_GLOBAL_STRING
  8475. // Allows the user to write str instead of Eq(str) sometimes, where
  8476. // str is a ::string object.
  8477. Matcher(const ::string& s); // NOLINT
  8478. #endif // GTEST_HAS_GLOBAL_STRING
  8479. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8480. Matcher(const char* s); // NOLINT
  8481. // Allows the user to pass absl::string_views directly.
  8482. Matcher(absl::string_view s); // NOLINT
  8483. };
  8484. template <>
  8485. class GTEST_API_ Matcher<absl::string_view>
  8486. : public internal::MatcherBase<absl::string_view> {
  8487. public:
  8488. Matcher() {}
  8489. explicit Matcher(const MatcherInterface<const absl::string_view&>* impl)
  8490. : internal::MatcherBase<absl::string_view>(impl) {}
  8491. explicit Matcher(const MatcherInterface<absl::string_view>* impl)
  8492. : internal::MatcherBase<absl::string_view>(impl) {}
  8493. // Allows the user to write str instead of Eq(str) sometimes, where
  8494. // str is a std::string object.
  8495. Matcher(const std::string& s); // NOLINT
  8496. #if GTEST_HAS_GLOBAL_STRING
  8497. // Allows the user to write str instead of Eq(str) sometimes, where
  8498. // str is a ::string object.
  8499. Matcher(const ::string& s); // NOLINT
  8500. #endif // GTEST_HAS_GLOBAL_STRING
  8501. // Allows the user to write "foo" instead of Eq("foo") sometimes.
  8502. Matcher(const char* s); // NOLINT
  8503. // Allows the user to pass absl::string_views directly.
  8504. Matcher(absl::string_view s); // NOLINT
  8505. };
  8506. #endif // GTEST_HAS_ABSL
  8507. // Prints a matcher in a human-readable format.
  8508. template <typename T>
  8509. std::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) {
  8510. matcher.DescribeTo(&os);
  8511. return os;
  8512. }
  8513. // The PolymorphicMatcher class template makes it easy to implement a
  8514. // polymorphic matcher (i.e. a matcher that can match values of more
  8515. // than one type, e.g. Eq(n) and NotNull()).
  8516. //
  8517. // To define a polymorphic matcher, a user should provide an Impl
  8518. // class that has a DescribeTo() method and a DescribeNegationTo()
  8519. // method, and define a member function (or member function template)
  8520. //
  8521. // bool MatchAndExplain(const Value& value,
  8522. // MatchResultListener* listener) const;
  8523. //
  8524. // See the definition of NotNull() for a complete example.
  8525. template <class Impl>
  8526. class PolymorphicMatcher {
  8527. public:
  8528. explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
  8529. // Returns a mutable reference to the underlying matcher
  8530. // implementation object.
  8531. Impl& mutable_impl() { return impl_; }
  8532. // Returns an immutable reference to the underlying matcher
  8533. // implementation object.
  8534. const Impl& impl() const { return impl_; }
  8535. template <typename T>
  8536. operator Matcher<T>() const {
  8537. return Matcher<T>(new MonomorphicImpl<const T&>(impl_));
  8538. }
  8539. private:
  8540. template <typename T>
  8541. class MonomorphicImpl : public MatcherInterface<T> {
  8542. public:
  8543. explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
  8544. virtual void DescribeTo(::std::ostream* os) const { impl_.DescribeTo(os); }
  8545. virtual void DescribeNegationTo(::std::ostream* os) const {
  8546. impl_.DescribeNegationTo(os);
  8547. }
  8548. virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
  8549. return impl_.MatchAndExplain(x, listener);
  8550. }
  8551. private:
  8552. const Impl impl_;
  8553. GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
  8554. };
  8555. Impl impl_;
  8556. GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
  8557. };
  8558. // Creates a matcher from its implementation. This is easier to use
  8559. // than the Matcher<T> constructor as it doesn't require you to
  8560. // explicitly write the template argument, e.g.
  8561. //
  8562. // MakeMatcher(foo);
  8563. // vs
  8564. // Matcher<const string&>(foo);
  8565. template <typename T>
  8566. inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
  8567. return Matcher<T>(impl);
  8568. }
  8569. // Creates a polymorphic matcher from its implementation. This is
  8570. // easier to use than the PolymorphicMatcher<Impl> constructor as it
  8571. // doesn't require you to explicitly write the template argument, e.g.
  8572. //
  8573. // MakePolymorphicMatcher(foo);
  8574. // vs
  8575. // PolymorphicMatcher<TypeOfFoo>(foo);
  8576. template <class Impl>
  8577. inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
  8578. return PolymorphicMatcher<Impl>(impl);
  8579. }
  8580. namespace internal {
  8581. // Implements a matcher that compares a given value with a
  8582. // pre-supplied value using one of the ==, <=, <, etc, operators. The
  8583. // two values being compared don't have to have the same type.
  8584. //
  8585. // The matcher defined here is polymorphic (for example, Eq(5) can be
  8586. // used to match an int, a short, a double, etc). Therefore we use
  8587. // a template type conversion operator in the implementation.
  8588. //
  8589. // The following template definition assumes that the Rhs parameter is
  8590. // a "bare" type (i.e. neither 'const T' nor 'T&').
  8591. template <typename D, typename Rhs, typename Op>
  8592. class ComparisonBase {
  8593. public:
  8594. explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {}
  8595. template <typename Lhs>
  8596. operator Matcher<Lhs>() const {
  8597. return MakeMatcher(new Impl<Lhs>(rhs_));
  8598. }
  8599. private:
  8600. template <typename Lhs>
  8601. class Impl : public MatcherInterface<Lhs> {
  8602. public:
  8603. explicit Impl(const Rhs& rhs) : rhs_(rhs) {}
  8604. bool MatchAndExplain(Lhs lhs,
  8605. MatchResultListener* /* listener */) const override {
  8606. return Op()(lhs, rhs_);
  8607. }
  8608. void DescribeTo(::std::ostream* os) const override {
  8609. *os << D::Desc() << " ";
  8610. UniversalPrint(rhs_, os);
  8611. }
  8612. void DescribeNegationTo(::std::ostream* os) const override {
  8613. *os << D::NegatedDesc() << " ";
  8614. UniversalPrint(rhs_, os);
  8615. }
  8616. private:
  8617. Rhs rhs_;
  8618. GTEST_DISALLOW_ASSIGN_(Impl);
  8619. };
  8620. Rhs rhs_;
  8621. GTEST_DISALLOW_ASSIGN_(ComparisonBase);
  8622. };
  8623. template <typename Rhs>
  8624. class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
  8625. public:
  8626. explicit EqMatcher(const Rhs& rhs)
  8627. : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }
  8628. static const char* Desc() { return "is equal to"; }
  8629. static const char* NegatedDesc() { return "isn't equal to"; }
  8630. };
  8631. template <typename Rhs>
  8632. class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
  8633. public:
  8634. explicit NeMatcher(const Rhs& rhs)
  8635. : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }
  8636. static const char* Desc() { return "isn't equal to"; }
  8637. static const char* NegatedDesc() { return "is equal to"; }
  8638. };
  8639. template <typename Rhs>
  8640. class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
  8641. public:
  8642. explicit LtMatcher(const Rhs& rhs)
  8643. : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }
  8644. static const char* Desc() { return "is <"; }
  8645. static const char* NegatedDesc() { return "isn't <"; }
  8646. };
  8647. template <typename Rhs>
  8648. class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
  8649. public:
  8650. explicit GtMatcher(const Rhs& rhs)
  8651. : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }
  8652. static const char* Desc() { return "is >"; }
  8653. static const char* NegatedDesc() { return "isn't >"; }
  8654. };
  8655. template <typename Rhs>
  8656. class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
  8657. public:
  8658. explicit LeMatcher(const Rhs& rhs)
  8659. : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }
  8660. static const char* Desc() { return "is <="; }
  8661. static const char* NegatedDesc() { return "isn't <="; }
  8662. };
  8663. template <typename Rhs>
  8664. class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
  8665. public:
  8666. explicit GeMatcher(const Rhs& rhs)
  8667. : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }
  8668. static const char* Desc() { return "is >="; }
  8669. static const char* NegatedDesc() { return "isn't >="; }
  8670. };
  8671. // Implements polymorphic matchers MatchesRegex(regex) and
  8672. // ContainsRegex(regex), which can be used as a Matcher<T> as long as
  8673. // T can be converted to a string.
  8674. class MatchesRegexMatcher {
  8675. public:
  8676. MatchesRegexMatcher(const RE* regex, bool full_match)
  8677. : regex_(regex), full_match_(full_match) {}
  8678. #if GTEST_HAS_ABSL
  8679. bool MatchAndExplain(const absl::string_view& s,
  8680. MatchResultListener* listener) const {
  8681. return MatchAndExplain(string(s), listener);
  8682. }
  8683. #endif // GTEST_HAS_ABSL
  8684. // Accepts pointer types, particularly:
  8685. // const char*
  8686. // char*
  8687. // const wchar_t*
  8688. // wchar_t*
  8689. template <typename CharType>
  8690. bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
  8691. return s != nullptr && MatchAndExplain(std::string(s), listener);
  8692. }
  8693. // Matches anything that can convert to std::string.
  8694. //
  8695. // This is a template, not just a plain function with const std::string&,
  8696. // because absl::string_view has some interfering non-explicit constructors.
  8697. template <class MatcheeStringType>
  8698. bool MatchAndExplain(const MatcheeStringType& s,
  8699. MatchResultListener* /* listener */) const {
  8700. const std::string& s2(s);
  8701. return full_match_ ? RE::FullMatch(s2, *regex_)
  8702. : RE::PartialMatch(s2, *regex_);
  8703. }
  8704. void DescribeTo(::std::ostream* os) const {
  8705. *os << (full_match_ ? "matches" : "contains") << " regular expression ";
  8706. UniversalPrinter<std::string>::Print(regex_->pattern(), os);
  8707. }
  8708. void DescribeNegationTo(::std::ostream* os) const {
  8709. *os << "doesn't " << (full_match_ ? "match" : "contain")
  8710. << " regular expression ";
  8711. UniversalPrinter<std::string>::Print(regex_->pattern(), os);
  8712. }
  8713. private:
  8714. const std::shared_ptr<const RE> regex_;
  8715. const bool full_match_;
  8716. GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
  8717. };
  8718. } // namespace internal
  8719. // Matches a string that fully matches regular expression 'regex'.
  8720. // The matcher takes ownership of 'regex'.
  8721. inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
  8722. const internal::RE* regex) {
  8723. return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
  8724. }
  8725. inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
  8726. const std::string& regex) {
  8727. return MatchesRegex(new internal::RE(regex));
  8728. }
  8729. // Matches a string that contains regular expression 'regex'.
  8730. // The matcher takes ownership of 'regex'.
  8731. inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
  8732. const internal::RE* regex) {
  8733. return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
  8734. }
  8735. inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
  8736. const std::string& regex) {
  8737. return ContainsRegex(new internal::RE(regex));
  8738. }
  8739. // Creates a polymorphic matcher that matches anything equal to x.
  8740. // Note: if the parameter of Eq() were declared as const T&, Eq("foo")
  8741. // wouldn't compile.
  8742. template <typename T>
  8743. inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
  8744. // Constructs a Matcher<T> from a 'value' of type T. The constructed
  8745. // matcher matches any value that's equal to 'value'.
  8746. template <typename T>
  8747. Matcher<T>::Matcher(T value) { *this = Eq(value); }
  8748. // Creates a monomorphic matcher that matches anything with type Lhs
  8749. // and equal to rhs. A user may need to use this instead of Eq(...)
  8750. // in order to resolve an overloading ambiguity.
  8751. //
  8752. // TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
  8753. // or Matcher<T>(x), but more readable than the latter.
  8754. //
  8755. // We could define similar monomorphic matchers for other comparison
  8756. // operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
  8757. // it yet as those are used much less than Eq() in practice. A user
  8758. // can always write Matcher<T>(Lt(5)) to be explicit about the type,
  8759. // for example.
  8760. template <typename Lhs, typename Rhs>
  8761. inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
  8762. // Creates a polymorphic matcher that matches anything >= x.
  8763. template <typename Rhs>
  8764. inline internal::GeMatcher<Rhs> Ge(Rhs x) {
  8765. return internal::GeMatcher<Rhs>(x);
  8766. }
  8767. // Creates a polymorphic matcher that matches anything > x.
  8768. template <typename Rhs>
  8769. inline internal::GtMatcher<Rhs> Gt(Rhs x) {
  8770. return internal::GtMatcher<Rhs>(x);
  8771. }
  8772. // Creates a polymorphic matcher that matches anything <= x.
  8773. template <typename Rhs>
  8774. inline internal::LeMatcher<Rhs> Le(Rhs x) {
  8775. return internal::LeMatcher<Rhs>(x);
  8776. }
  8777. // Creates a polymorphic matcher that matches anything < x.
  8778. template <typename Rhs>
  8779. inline internal::LtMatcher<Rhs> Lt(Rhs x) {
  8780. return internal::LtMatcher<Rhs>(x);
  8781. }
  8782. // Creates a polymorphic matcher that matches anything != x.
  8783. template <typename Rhs>
  8784. inline internal::NeMatcher<Rhs> Ne(Rhs x) {
  8785. return internal::NeMatcher<Rhs>(x);
  8786. }
  8787. } // namespace testing
  8788. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 5046
  8789. #endif // GTEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
  8790. #include <stdio.h>
  8791. #include <memory>
  8792. namespace testing {
  8793. namespace internal {
  8794. GTEST_DECLARE_string_(internal_run_death_test);
  8795. // Names of the flags (needed for parsing Google Test flags).
  8796. const char kDeathTestStyleFlag[] = "death_test_style";
  8797. const char kDeathTestUseFork[] = "death_test_use_fork";
  8798. const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
  8799. #if GTEST_HAS_DEATH_TEST
  8800. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  8801. /* class A needs to have dll-interface to be used by clients of class B */)
  8802. // DeathTest is a class that hides much of the complexity of the
  8803. // GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
  8804. // returns a concrete class that depends on the prevailing death test
  8805. // style, as defined by the --gtest_death_test_style and/or
  8806. // --gtest_internal_run_death_test flags.
  8807. // In describing the results of death tests, these terms are used with
  8808. // the corresponding definitions:
  8809. //
  8810. // exit status: The integer exit information in the format specified
  8811. // by wait(2)
  8812. // exit code: The integer code passed to exit(3), _exit(2), or
  8813. // returned from main()
  8814. class GTEST_API_ DeathTest {
  8815. public:
  8816. // Create returns false if there was an error determining the
  8817. // appropriate action to take for the current death test; for example,
  8818. // if the gtest_death_test_style flag is set to an invalid value.
  8819. // The LastMessage method will return a more detailed message in that
  8820. // case. Otherwise, the DeathTest pointer pointed to by the "test"
  8821. // argument is set. If the death test should be skipped, the pointer
  8822. // is set to NULL; otherwise, it is set to the address of a new concrete
  8823. // DeathTest object that controls the execution of the current test.
  8824. static bool Create(const char* statement, Matcher<const std::string&> matcher,
  8825. const char* file, int line, DeathTest** test);
  8826. DeathTest();
  8827. virtual ~DeathTest() { }
  8828. // A helper class that aborts a death test when it's deleted.
  8829. class ReturnSentinel {
  8830. public:
  8831. explicit ReturnSentinel(DeathTest* test) : test_(test) { }
  8832. ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
  8833. private:
  8834. DeathTest* const test_;
  8835. GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
  8836. } GTEST_ATTRIBUTE_UNUSED_;
  8837. // An enumeration of possible roles that may be taken when a death
  8838. // test is encountered. EXECUTE means that the death test logic should
  8839. // be executed immediately. OVERSEE means that the program should prepare
  8840. // the appropriate environment for a child process to execute the death
  8841. // test, then wait for it to complete.
  8842. enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
  8843. // An enumeration of the three reasons that a test might be aborted.
  8844. enum AbortReason {
  8845. TEST_ENCOUNTERED_RETURN_STATEMENT,
  8846. TEST_THREW_EXCEPTION,
  8847. TEST_DID_NOT_DIE
  8848. };
  8849. // Assumes one of the above roles.
  8850. virtual TestRole AssumeRole() = 0;
  8851. // Waits for the death test to finish and returns its status.
  8852. virtual int Wait() = 0;
  8853. // Returns true if the death test passed; that is, the test process
  8854. // exited during the test, its exit status matches a user-supplied
  8855. // predicate, and its stderr output matches a user-supplied regular
  8856. // expression.
  8857. // The user-supplied predicate may be a macro expression rather
  8858. // than a function pointer or functor, or else Wait and Passed could
  8859. // be combined.
  8860. virtual bool Passed(bool exit_status_ok) = 0;
  8861. // Signals that the death test did not die as expected.
  8862. virtual void Abort(AbortReason reason) = 0;
  8863. // Returns a human-readable outcome message regarding the outcome of
  8864. // the last death test.
  8865. static const char* LastMessage();
  8866. static void set_last_death_test_message(const std::string& message);
  8867. private:
  8868. // A string containing a description of the outcome of the last death test.
  8869. static std::string last_death_test_message_;
  8870. GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
  8871. };
  8872. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  8873. // Factory interface for death tests. May be mocked out for testing.
  8874. class DeathTestFactory {
  8875. public:
  8876. virtual ~DeathTestFactory() { }
  8877. virtual bool Create(const char* statement,
  8878. Matcher<const std::string&> matcher, const char* file,
  8879. int line, DeathTest** test) = 0;
  8880. };
  8881. // A concrete DeathTestFactory implementation for normal use.
  8882. class DefaultDeathTestFactory : public DeathTestFactory {
  8883. public:
  8884. bool Create(const char* statement, Matcher<const std::string&> matcher,
  8885. const char* file, int line, DeathTest** test) override;
  8886. };
  8887. // Returns true if exit_status describes a process that was terminated
  8888. // by a signal, or exited normally with a nonzero exit code.
  8889. GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
  8890. // A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
  8891. // and interpreted as a regex (rather than an Eq matcher) for legacy
  8892. // compatibility.
  8893. inline Matcher<const ::std::string&> MakeDeathTestMatcher(
  8894. ::testing::internal::RE regex) {
  8895. return ContainsRegex(regex.pattern());
  8896. }
  8897. inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
  8898. return ContainsRegex(regex);
  8899. }
  8900. inline Matcher<const ::std::string&> MakeDeathTestMatcher(
  8901. const ::std::string& regex) {
  8902. return ContainsRegex(regex);
  8903. }
  8904. #if GTEST_HAS_GLOBAL_STRING
  8905. inline Matcher<const ::std::string&> MakeDeathTestMatcher(
  8906. const ::string& regex) {
  8907. return ContainsRegex(regex);
  8908. }
  8909. #endif
  8910. // If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
  8911. // used directly.
  8912. inline Matcher<const ::std::string&> MakeDeathTestMatcher(
  8913. Matcher<const ::std::string&> matcher) {
  8914. return matcher;
  8915. }
  8916. // Traps C++ exceptions escaping statement and reports them as test
  8917. // failures. Note that trapping SEH exceptions is not implemented here.
  8918. # if GTEST_HAS_EXCEPTIONS
  8919. # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
  8920. try { \
  8921. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  8922. } catch (const ::std::exception& gtest_exception) { \
  8923. fprintf(\
  8924. stderr, \
  8925. "\n%s: Caught std::exception-derived exception escaping the " \
  8926. "death test statement. Exception message: %s\n", \
  8927. ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
  8928. gtest_exception.what()); \
  8929. fflush(stderr); \
  8930. death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
  8931. } catch (...) { \
  8932. death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
  8933. }
  8934. # else
  8935. # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
  8936. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
  8937. # endif
  8938. // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
  8939. // ASSERT_EXIT*, and EXPECT_EXIT*.
  8940. #define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail) \
  8941. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  8942. if (::testing::internal::AlwaysTrue()) { \
  8943. ::testing::internal::DeathTest* gtest_dt; \
  8944. if (!::testing::internal::DeathTest::Create( \
  8945. #statement, \
  8946. ::testing::internal::MakeDeathTestMatcher(regex_or_matcher), \
  8947. __FILE__, __LINE__, &gtest_dt)) { \
  8948. goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
  8949. } \
  8950. if (gtest_dt != nullptr) { \
  8951. std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
  8952. switch (gtest_dt->AssumeRole()) { \
  8953. case ::testing::internal::DeathTest::OVERSEE_TEST: \
  8954. if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
  8955. goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
  8956. } \
  8957. break; \
  8958. case ::testing::internal::DeathTest::EXECUTE_TEST: { \
  8959. ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
  8960. gtest_dt); \
  8961. GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
  8962. gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
  8963. break; \
  8964. } \
  8965. default: \
  8966. break; \
  8967. } \
  8968. } \
  8969. } else \
  8970. GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__) \
  8971. : fail(::testing::internal::DeathTest::LastMessage())
  8972. // The symbol "fail" here expands to something into which a message
  8973. // can be streamed.
  8974. // This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
  8975. // NDEBUG mode. In this case we need the statements to be executed and the macro
  8976. // must accept a streamed message even though the message is never printed.
  8977. // The regex object is not evaluated, but it is used to prevent "unused"
  8978. // warnings and to avoid an expression that doesn't compile in debug mode.
  8979. #define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \
  8980. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  8981. if (::testing::internal::AlwaysTrue()) { \
  8982. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  8983. } else if (!::testing::internal::AlwaysTrue()) { \
  8984. ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
  8985. } else \
  8986. ::testing::Message()
  8987. // A class representing the parsed contents of the
  8988. // --gtest_internal_run_death_test flag, as it existed when
  8989. // RUN_ALL_TESTS was called.
  8990. class InternalRunDeathTestFlag {
  8991. public:
  8992. InternalRunDeathTestFlag(const std::string& a_file,
  8993. int a_line,
  8994. int an_index,
  8995. int a_write_fd)
  8996. : file_(a_file), line_(a_line), index_(an_index),
  8997. write_fd_(a_write_fd) {}
  8998. ~InternalRunDeathTestFlag() {
  8999. if (write_fd_ >= 0)
  9000. posix::Close(write_fd_);
  9001. }
  9002. const std::string& file() const { return file_; }
  9003. int line() const { return line_; }
  9004. int index() const { return index_; }
  9005. int write_fd() const { return write_fd_; }
  9006. private:
  9007. std::string file_;
  9008. int line_;
  9009. int index_;
  9010. int write_fd_;
  9011. GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
  9012. };
  9013. // Returns a newly created InternalRunDeathTestFlag object with fields
  9014. // initialized from the GTEST_FLAG(internal_run_death_test) flag if
  9015. // the flag is specified; otherwise returns NULL.
  9016. InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
  9017. #endif // GTEST_HAS_DEATH_TEST
  9018. } // namespace internal
  9019. } // namespace testing
  9020. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
  9021. namespace testing {
  9022. // This flag controls the style of death tests. Valid values are "threadsafe",
  9023. // meaning that the death test child process will re-execute the test binary
  9024. // from the start, running only a single death test, or "fast",
  9025. // meaning that the child process will execute the test logic immediately
  9026. // after forking.
  9027. GTEST_DECLARE_string_(death_test_style);
  9028. #if GTEST_HAS_DEATH_TEST
  9029. namespace internal {
  9030. // Returns a Boolean value indicating whether the caller is currently
  9031. // executing in the context of the death test child process. Tools such as
  9032. // Valgrind heap checkers may need this to modify their behavior in death
  9033. // tests. IMPORTANT: This is an internal utility. Using it may break the
  9034. // implementation of death tests. User code MUST NOT use it.
  9035. GTEST_API_ bool InDeathTestChild();
  9036. } // namespace internal
  9037. // The following macros are useful for writing death tests.
  9038. // Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
  9039. // executed:
  9040. //
  9041. // 1. It generates a warning if there is more than one active
  9042. // thread. This is because it's safe to fork() or clone() only
  9043. // when there is a single thread.
  9044. //
  9045. // 2. The parent process clone()s a sub-process and runs the death
  9046. // test in it; the sub-process exits with code 0 at the end of the
  9047. // death test, if it hasn't exited already.
  9048. //
  9049. // 3. The parent process waits for the sub-process to terminate.
  9050. //
  9051. // 4. The parent process checks the exit code and error message of
  9052. // the sub-process.
  9053. //
  9054. // Examples:
  9055. //
  9056. // ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
  9057. // for (int i = 0; i < 5; i++) {
  9058. // EXPECT_DEATH(server.ProcessRequest(i),
  9059. // "Invalid request .* in ProcessRequest()")
  9060. // << "Failed to die on request " << i;
  9061. // }
  9062. //
  9063. // ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
  9064. //
  9065. // bool KilledBySIGHUP(int exit_code) {
  9066. // return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
  9067. // }
  9068. //
  9069. // ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
  9070. //
  9071. // On the regular expressions used in death tests:
  9072. //
  9073. // GOOGLETEST_CM0005 DO NOT DELETE
  9074. // On POSIX-compliant systems (*nix), we use the <regex.h> library,
  9075. // which uses the POSIX extended regex syntax.
  9076. //
  9077. // On other platforms (e.g. Windows or Mac), we only support a simple regex
  9078. // syntax implemented as part of Google Test. This limited
  9079. // implementation should be enough most of the time when writing
  9080. // death tests; though it lacks many features you can find in PCRE
  9081. // or POSIX extended regex syntax. For example, we don't support
  9082. // union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
  9083. // repetition count ("x{5,7}"), among others.
  9084. //
  9085. // Below is the syntax that we do support. We chose it to be a
  9086. // subset of both PCRE and POSIX extended regex, so it's easy to
  9087. // learn wherever you come from. In the following: 'A' denotes a
  9088. // literal character, period (.), or a single \\ escape sequence;
  9089. // 'x' and 'y' denote regular expressions; 'm' and 'n' are for
  9090. // natural numbers.
  9091. //
  9092. // c matches any literal character c
  9093. // \\d matches any decimal digit
  9094. // \\D matches any character that's not a decimal digit
  9095. // \\f matches \f
  9096. // \\n matches \n
  9097. // \\r matches \r
  9098. // \\s matches any ASCII whitespace, including \n
  9099. // \\S matches any character that's not a whitespace
  9100. // \\t matches \t
  9101. // \\v matches \v
  9102. // \\w matches any letter, _, or decimal digit
  9103. // \\W matches any character that \\w doesn't match
  9104. // \\c matches any literal character c, which must be a punctuation
  9105. // . matches any single character except \n
  9106. // A? matches 0 or 1 occurrences of A
  9107. // A* matches 0 or many occurrences of A
  9108. // A+ matches 1 or many occurrences of A
  9109. // ^ matches the beginning of a string (not that of each line)
  9110. // $ matches the end of a string (not that of each line)
  9111. // xy matches x followed by y
  9112. //
  9113. // If you accidentally use PCRE or POSIX extended regex features
  9114. // not implemented by us, you will get a run-time failure. In that
  9115. // case, please try to rewrite your regular expression within the
  9116. // above syntax.
  9117. //
  9118. // This implementation is *not* meant to be as highly tuned or robust
  9119. // as a compiled regex library, but should perform well enough for a
  9120. // death test, which already incurs significant overhead by launching
  9121. // a child process.
  9122. //
  9123. // Known caveats:
  9124. //
  9125. // A "threadsafe" style death test obtains the path to the test
  9126. // program from argv[0] and re-executes it in the sub-process. For
  9127. // simplicity, the current implementation doesn't search the PATH
  9128. // when launching the sub-process. This means that the user must
  9129. // invoke the test program via a path that contains at least one
  9130. // path separator (e.g. path/to/foo_test and
  9131. // /absolute/path/to/bar_test are fine, but foo_test is not). This
  9132. // is rarely a problem as people usually don't put the test binary
  9133. // directory in PATH.
  9134. //
  9135. // Asserts that a given statement causes the program to exit, with an
  9136. // integer exit status that satisfies predicate, and emitting error output
  9137. // that matches regex.
  9138. # define ASSERT_EXIT(statement, predicate, regex) \
  9139. GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
  9140. // Like ASSERT_EXIT, but continues on to successive tests in the
  9141. // test suite, if any:
  9142. # define EXPECT_EXIT(statement, predicate, regex) \
  9143. GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
  9144. // Asserts that a given statement causes the program to exit, either by
  9145. // explicitly exiting with a nonzero exit code or being killed by a
  9146. // signal, and emitting error output that matches regex.
  9147. # define ASSERT_DEATH(statement, regex) \
  9148. ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
  9149. // Like ASSERT_DEATH, but continues on to successive tests in the
  9150. // test suite, if any:
  9151. # define EXPECT_DEATH(statement, regex) \
  9152. EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
  9153. // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
  9154. // Tests that an exit code describes a normal exit with a given exit code.
  9155. class GTEST_API_ ExitedWithCode {
  9156. public:
  9157. explicit ExitedWithCode(int exit_code);
  9158. bool operator()(int exit_status) const;
  9159. private:
  9160. // No implementation - assignment is unsupported.
  9161. void operator=(const ExitedWithCode& other);
  9162. const int exit_code_;
  9163. };
  9164. # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
  9165. // Tests that an exit code describes an exit due to termination by a
  9166. // given signal.
  9167. // GOOGLETEST_CM0006 DO NOT DELETE
  9168. class GTEST_API_ KilledBySignal {
  9169. public:
  9170. explicit KilledBySignal(int signum);
  9171. bool operator()(int exit_status) const;
  9172. private:
  9173. const int signum_;
  9174. };
  9175. # endif // !GTEST_OS_WINDOWS
  9176. // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
  9177. // The death testing framework causes this to have interesting semantics,
  9178. // since the sideeffects of the call are only visible in opt mode, and not
  9179. // in debug mode.
  9180. //
  9181. // In practice, this can be used to test functions that utilize the
  9182. // LOG(DFATAL) macro using the following style:
  9183. //
  9184. // int DieInDebugOr12(int* sideeffect) {
  9185. // if (sideeffect) {
  9186. // *sideeffect = 12;
  9187. // }
  9188. // LOG(DFATAL) << "death";
  9189. // return 12;
  9190. // }
  9191. //
  9192. // TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) {
  9193. // int sideeffect = 0;
  9194. // // Only asserts in dbg.
  9195. // EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
  9196. //
  9197. // #ifdef NDEBUG
  9198. // // opt-mode has sideeffect visible.
  9199. // EXPECT_EQ(12, sideeffect);
  9200. // #else
  9201. // // dbg-mode no visible sideeffect.
  9202. // EXPECT_EQ(0, sideeffect);
  9203. // #endif
  9204. // }
  9205. //
  9206. // This will assert that DieInDebugReturn12InOpt() crashes in debug
  9207. // mode, usually due to a DCHECK or LOG(DFATAL), but returns the
  9208. // appropriate fallback value (12 in this case) in opt mode. If you
  9209. // need to test that a function has appropriate side-effects in opt
  9210. // mode, include assertions against the side-effects. A general
  9211. // pattern for this is:
  9212. //
  9213. // EXPECT_DEBUG_DEATH({
  9214. // // Side-effects here will have an effect after this statement in
  9215. // // opt mode, but none in debug mode.
  9216. // EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
  9217. // }, "death");
  9218. //
  9219. # ifdef NDEBUG
  9220. # define EXPECT_DEBUG_DEATH(statement, regex) \
  9221. GTEST_EXECUTE_STATEMENT_(statement, regex)
  9222. # define ASSERT_DEBUG_DEATH(statement, regex) \
  9223. GTEST_EXECUTE_STATEMENT_(statement, regex)
  9224. # else
  9225. # define EXPECT_DEBUG_DEATH(statement, regex) \
  9226. EXPECT_DEATH(statement, regex)
  9227. # define ASSERT_DEBUG_DEATH(statement, regex) \
  9228. ASSERT_DEATH(statement, regex)
  9229. # endif // NDEBUG for EXPECT_DEBUG_DEATH
  9230. #endif // GTEST_HAS_DEATH_TEST
  9231. // This macro is used for implementing macros such as
  9232. // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
  9233. // death tests are not supported. Those macros must compile on such systems
  9234. // iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
  9235. // systems that support death tests. This allows one to write such a macro
  9236. // on a system that does not support death tests and be sure that it will
  9237. // compile on a death-test supporting system. It is exposed publicly so that
  9238. // systems that have death-tests with stricter requirements than
  9239. // GTEST_HAS_DEATH_TEST can write their own equivalent of
  9240. // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
  9241. //
  9242. // Parameters:
  9243. // statement - A statement that a macro such as EXPECT_DEATH would test
  9244. // for program termination. This macro has to make sure this
  9245. // statement is compiled but not executed, to ensure that
  9246. // EXPECT_DEATH_IF_SUPPORTED compiles with a certain
  9247. // parameter iff EXPECT_DEATH compiles with it.
  9248. // regex - A regex that a macro such as EXPECT_DEATH would use to test
  9249. // the output of statement. This parameter has to be
  9250. // compiled but not evaluated by this macro, to ensure that
  9251. // this macro only accepts expressions that a macro such as
  9252. // EXPECT_DEATH would accept.
  9253. // terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
  9254. // and a return statement for ASSERT_DEATH_IF_SUPPORTED.
  9255. // This ensures that ASSERT_DEATH_IF_SUPPORTED will not
  9256. // compile inside functions where ASSERT_DEATH doesn't
  9257. // compile.
  9258. //
  9259. // The branch that has an always false condition is used to ensure that
  9260. // statement and regex are compiled (and thus syntactically correct) but
  9261. // never executed. The unreachable code macro protects the terminator
  9262. // statement from generating an 'unreachable code' warning in case
  9263. // statement unconditionally returns or throws. The Message constructor at
  9264. // the end allows the syntax of streaming additional messages into the
  9265. // macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
  9266. # define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
  9267. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  9268. if (::testing::internal::AlwaysTrue()) { \
  9269. GTEST_LOG_(WARNING) \
  9270. << "Death tests are not supported on this platform.\n" \
  9271. << "Statement '" #statement "' cannot be verified."; \
  9272. } else if (::testing::internal::AlwaysFalse()) { \
  9273. ::testing::internal::RE::PartialMatch(".*", (regex)); \
  9274. GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
  9275. terminator; \
  9276. } else \
  9277. ::testing::Message()
  9278. // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
  9279. // ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
  9280. // death tests are supported; otherwise they just issue a warning. This is
  9281. // useful when you are combining death test assertions with normal test
  9282. // assertions in one test.
  9283. #if GTEST_HAS_DEATH_TEST
  9284. # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
  9285. EXPECT_DEATH(statement, regex)
  9286. # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
  9287. ASSERT_DEATH(statement, regex)
  9288. #else
  9289. # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
  9290. GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
  9291. # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
  9292. GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
  9293. #endif
  9294. } // namespace testing
  9295. #endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
  9296. // This file was GENERATED by command:
  9297. // pump.py gtest-param-test.h.pump
  9298. // DO NOT EDIT BY HAND!!!
  9299. // Copyright 2008, Google Inc.
  9300. // All rights reserved.
  9301. //
  9302. // Redistribution and use in source and binary forms, with or without
  9303. // modification, are permitted provided that the following conditions are
  9304. // met:
  9305. //
  9306. // * Redistributions of source code must retain the above copyright
  9307. // notice, this list of conditions and the following disclaimer.
  9308. // * Redistributions in binary form must reproduce the above
  9309. // copyright notice, this list of conditions and the following disclaimer
  9310. // in the documentation and/or other materials provided with the
  9311. // distribution.
  9312. // * Neither the name of Google Inc. nor the names of its
  9313. // contributors may be used to endorse or promote products derived from
  9314. // this software without specific prior written permission.
  9315. //
  9316. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  9317. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9318. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  9319. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9320. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  9321. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9322. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  9323. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9324. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9325. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  9326. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9327. //
  9328. // Macros and functions for implementing parameterized tests
  9329. // in Google C++ Testing and Mocking Framework (Google Test)
  9330. //
  9331. // This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
  9332. //
  9333. // GOOGLETEST_CM0001 DO NOT DELETE
  9334. #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
  9335. #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
  9336. // Value-parameterized tests allow you to test your code with different
  9337. // parameters without writing multiple copies of the same test.
  9338. //
  9339. // Here is how you use value-parameterized tests:
  9340. #if 0
  9341. // To write value-parameterized tests, first you should define a fixture
  9342. // class. It is usually derived from testing::TestWithParam<T> (see below for
  9343. // another inheritance scheme that's sometimes useful in more complicated
  9344. // class hierarchies), where the type of your parameter values.
  9345. // TestWithParam<T> is itself derived from testing::Test. T can be any
  9346. // copyable type. If it's a raw pointer, you are responsible for managing the
  9347. // lifespan of the pointed values.
  9348. class FooTest : public ::testing::TestWithParam<const char*> {
  9349. // You can implement all the usual class fixture members here.
  9350. };
  9351. // Then, use the TEST_P macro to define as many parameterized tests
  9352. // for this fixture as you want. The _P suffix is for "parameterized"
  9353. // or "pattern", whichever you prefer to think.
  9354. TEST_P(FooTest, DoesBlah) {
  9355. // Inside a test, access the test parameter with the GetParam() method
  9356. // of the TestWithParam<T> class:
  9357. EXPECT_TRUE(foo.Blah(GetParam()));
  9358. ...
  9359. }
  9360. TEST_P(FooTest, HasBlahBlah) {
  9361. ...
  9362. }
  9363. // Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test
  9364. // case with any set of parameters you want. Google Test defines a number
  9365. // of functions for generating test parameters. They return what we call
  9366. // (surprise!) parameter generators. Here is a summary of them, which
  9367. // are all in the testing namespace:
  9368. //
  9369. //
  9370. // Range(begin, end [, step]) - Yields values {begin, begin+step,
  9371. // begin+step+step, ...}. The values do not
  9372. // include end. step defaults to 1.
  9373. // Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
  9374. // ValuesIn(container) - Yields values from a C-style array, an STL
  9375. // ValuesIn(begin,end) container, or an iterator range [begin, end).
  9376. // Bool() - Yields sequence {false, true}.
  9377. // Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
  9378. // for the math savvy) of the values generated
  9379. // by the N generators.
  9380. //
  9381. // For more details, see comments at the definitions of these functions below
  9382. // in this file.
  9383. //
  9384. // The following statement will instantiate tests from the FooTest test suite
  9385. // each with parameter values "meeny", "miny", and "moe".
  9386. INSTANTIATE_TEST_SUITE_P(InstantiationName,
  9387. FooTest,
  9388. Values("meeny", "miny", "moe"));
  9389. // To distinguish different instances of the pattern, (yes, you
  9390. // can instantiate it more then once) the first argument to the
  9391. // INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the
  9392. // actual test suite name. Remember to pick unique prefixes for different
  9393. // instantiations. The tests from the instantiation above will have
  9394. // these names:
  9395. //
  9396. // * InstantiationName/FooTest.DoesBlah/0 for "meeny"
  9397. // * InstantiationName/FooTest.DoesBlah/1 for "miny"
  9398. // * InstantiationName/FooTest.DoesBlah/2 for "moe"
  9399. // * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
  9400. // * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
  9401. // * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
  9402. //
  9403. // You can use these names in --gtest_filter.
  9404. //
  9405. // This statement will instantiate all tests from FooTest again, each
  9406. // with parameter values "cat" and "dog":
  9407. const char* pets[] = {"cat", "dog"};
  9408. INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
  9409. // The tests from the instantiation above will have these names:
  9410. //
  9411. // * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
  9412. // * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
  9413. // * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
  9414. // * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
  9415. //
  9416. // Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests
  9417. // in the given test suite, whether their definitions come before or
  9418. // AFTER the INSTANTIATE_TEST_SUITE_P statement.
  9419. //
  9420. // Please also note that generator expressions (including parameters to the
  9421. // generators) are evaluated in InitGoogleTest(), after main() has started.
  9422. // This allows the user on one hand, to adjust generator parameters in order
  9423. // to dynamically determine a set of tests to run and on the other hand,
  9424. // give the user a chance to inspect the generated tests with Google Test
  9425. // reflection API before RUN_ALL_TESTS() is executed.
  9426. //
  9427. // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
  9428. // for more examples.
  9429. //
  9430. // In the future, we plan to publish the API for defining new parameter
  9431. // generators. But for now this interface remains part of the internal
  9432. // implementation and is subject to change.
  9433. //
  9434. //
  9435. // A parameterized test fixture must be derived from testing::Test and from
  9436. // testing::WithParamInterface<T>, where T is the type of the parameter
  9437. // values. Inheriting from TestWithParam<T> satisfies that requirement because
  9438. // TestWithParam<T> inherits from both Test and WithParamInterface. In more
  9439. // complicated hierarchies, however, it is occasionally useful to inherit
  9440. // separately from Test and WithParamInterface. For example:
  9441. class BaseTest : public ::testing::Test {
  9442. // You can inherit all the usual members for a non-parameterized test
  9443. // fixture here.
  9444. };
  9445. class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
  9446. // The usual test fixture members go here too.
  9447. };
  9448. TEST_F(BaseTest, HasFoo) {
  9449. // This is an ordinary non-parameterized test.
  9450. }
  9451. TEST_P(DerivedTest, DoesBlah) {
  9452. // GetParam works just the same here as if you inherit from TestWithParam.
  9453. EXPECT_TRUE(foo.Blah(GetParam()));
  9454. }
  9455. #endif // 0
  9456. #include <utility>
  9457. // Copyright 2008 Google Inc.
  9458. // All Rights Reserved.
  9459. //
  9460. // Redistribution and use in source and binary forms, with or without
  9461. // modification, are permitted provided that the following conditions are
  9462. // met:
  9463. //
  9464. // * Redistributions of source code must retain the above copyright
  9465. // notice, this list of conditions and the following disclaimer.
  9466. // * Redistributions in binary form must reproduce the above
  9467. // copyright notice, this list of conditions and the following disclaimer
  9468. // in the documentation and/or other materials provided with the
  9469. // distribution.
  9470. // * Neither the name of Google Inc. nor the names of its
  9471. // contributors may be used to endorse or promote products derived from
  9472. // this software without specific prior written permission.
  9473. //
  9474. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  9475. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9476. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  9477. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9478. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  9479. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9480. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  9481. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9482. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9483. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  9484. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9485. // Type and function utilities for implementing parameterized tests.
  9486. // GOOGLETEST_CM0001 DO NOT DELETE
  9487. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
  9488. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
  9489. #include <ctype.h>
  9490. #include <iterator>
  9491. #include <memory>
  9492. #include <set>
  9493. #include <tuple>
  9494. #include <utility>
  9495. #include <vector>
  9496. namespace testing {
  9497. // Input to a parameterized test name generator, describing a test parameter.
  9498. // Consists of the parameter value and the integer parameter index.
  9499. template <class ParamType>
  9500. struct TestParamInfo {
  9501. TestParamInfo(const ParamType& a_param, size_t an_index) :
  9502. param(a_param),
  9503. index(an_index) {}
  9504. ParamType param;
  9505. size_t index;
  9506. };
  9507. // A builtin parameterized test name generator which returns the result of
  9508. // testing::PrintToString.
  9509. struct PrintToStringParamName {
  9510. template <class ParamType>
  9511. std::string operator()(const TestParamInfo<ParamType>& info) const {
  9512. return PrintToString(info.param);
  9513. }
  9514. };
  9515. namespace internal {
  9516. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9517. // Utility Functions
  9518. // Outputs a message explaining invalid registration of different
  9519. // fixture class for the same test suite. This may happen when
  9520. // TEST_P macro is used to define two tests with the same name
  9521. // but in different namespaces.
  9522. GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
  9523. CodeLocation code_location);
  9524. template <typename> class ParamGeneratorInterface;
  9525. template <typename> class ParamGenerator;
  9526. // Interface for iterating over elements provided by an implementation
  9527. // of ParamGeneratorInterface<T>.
  9528. template <typename T>
  9529. class ParamIteratorInterface {
  9530. public:
  9531. virtual ~ParamIteratorInterface() {}
  9532. // A pointer to the base generator instance.
  9533. // Used only for the purposes of iterator comparison
  9534. // to make sure that two iterators belong to the same generator.
  9535. virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
  9536. // Advances iterator to point to the next element
  9537. // provided by the generator. The caller is responsible
  9538. // for not calling Advance() on an iterator equal to
  9539. // BaseGenerator()->End().
  9540. virtual void Advance() = 0;
  9541. // Clones the iterator object. Used for implementing copy semantics
  9542. // of ParamIterator<T>.
  9543. virtual ParamIteratorInterface* Clone() const = 0;
  9544. // Dereferences the current iterator and provides (read-only) access
  9545. // to the pointed value. It is the caller's responsibility not to call
  9546. // Current() on an iterator equal to BaseGenerator()->End().
  9547. // Used for implementing ParamGenerator<T>::operator*().
  9548. virtual const T* Current() const = 0;
  9549. // Determines whether the given iterator and other point to the same
  9550. // element in the sequence generated by the generator.
  9551. // Used for implementing ParamGenerator<T>::operator==().
  9552. virtual bool Equals(const ParamIteratorInterface& other) const = 0;
  9553. };
  9554. // Class iterating over elements provided by an implementation of
  9555. // ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>
  9556. // and implements the const forward iterator concept.
  9557. template <typename T>
  9558. class ParamIterator {
  9559. public:
  9560. typedef T value_type;
  9561. typedef const T& reference;
  9562. typedef ptrdiff_t difference_type;
  9563. // ParamIterator assumes ownership of the impl_ pointer.
  9564. ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
  9565. ParamIterator& operator=(const ParamIterator& other) {
  9566. if (this != &other)
  9567. impl_.reset(other.impl_->Clone());
  9568. return *this;
  9569. }
  9570. const T& operator*() const { return *impl_->Current(); }
  9571. const T* operator->() const { return impl_->Current(); }
  9572. // Prefix version of operator++.
  9573. ParamIterator& operator++() {
  9574. impl_->Advance();
  9575. return *this;
  9576. }
  9577. // Postfix version of operator++.
  9578. ParamIterator operator++(int /*unused*/) {
  9579. ParamIteratorInterface<T>* clone = impl_->Clone();
  9580. impl_->Advance();
  9581. return ParamIterator(clone);
  9582. }
  9583. bool operator==(const ParamIterator& other) const {
  9584. return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
  9585. }
  9586. bool operator!=(const ParamIterator& other) const {
  9587. return !(*this == other);
  9588. }
  9589. private:
  9590. friend class ParamGenerator<T>;
  9591. explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
  9592. std::unique_ptr<ParamIteratorInterface<T> > impl_;
  9593. };
  9594. // ParamGeneratorInterface<T> is the binary interface to access generators
  9595. // defined in other translation units.
  9596. template <typename T>
  9597. class ParamGeneratorInterface {
  9598. public:
  9599. typedef T ParamType;
  9600. virtual ~ParamGeneratorInterface() {}
  9601. // Generator interface definition
  9602. virtual ParamIteratorInterface<T>* Begin() const = 0;
  9603. virtual ParamIteratorInterface<T>* End() const = 0;
  9604. };
  9605. // Wraps ParamGeneratorInterface<T> and provides general generator syntax
  9606. // compatible with the STL Container concept.
  9607. // This class implements copy initialization semantics and the contained
  9608. // ParamGeneratorInterface<T> instance is shared among all copies
  9609. // of the original object. This is possible because that instance is immutable.
  9610. template<typename T>
  9611. class ParamGenerator {
  9612. public:
  9613. typedef ParamIterator<T> iterator;
  9614. explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
  9615. ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
  9616. ParamGenerator& operator=(const ParamGenerator& other) {
  9617. impl_ = other.impl_;
  9618. return *this;
  9619. }
  9620. iterator begin() const { return iterator(impl_->Begin()); }
  9621. iterator end() const { return iterator(impl_->End()); }
  9622. private:
  9623. std::shared_ptr<const ParamGeneratorInterface<T> > impl_;
  9624. };
  9625. // Generates values from a range of two comparable values. Can be used to
  9626. // generate sequences of user-defined types that implement operator+() and
  9627. // operator<().
  9628. // This class is used in the Range() function.
  9629. template <typename T, typename IncrementT>
  9630. class RangeGenerator : public ParamGeneratorInterface<T> {
  9631. public:
  9632. RangeGenerator(T begin, T end, IncrementT step)
  9633. : begin_(begin), end_(end),
  9634. step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
  9635. ~RangeGenerator() override {}
  9636. ParamIteratorInterface<T>* Begin() const override {
  9637. return new Iterator(this, begin_, 0, step_);
  9638. }
  9639. ParamIteratorInterface<T>* End() const override {
  9640. return new Iterator(this, end_, end_index_, step_);
  9641. }
  9642. private:
  9643. class Iterator : public ParamIteratorInterface<T> {
  9644. public:
  9645. Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
  9646. IncrementT step)
  9647. : base_(base), value_(value), index_(index), step_(step) {}
  9648. ~Iterator() override {}
  9649. const ParamGeneratorInterface<T>* BaseGenerator() const override {
  9650. return base_;
  9651. }
  9652. void Advance() override {
  9653. value_ = static_cast<T>(value_ + step_);
  9654. index_++;
  9655. }
  9656. ParamIteratorInterface<T>* Clone() const override {
  9657. return new Iterator(*this);
  9658. }
  9659. const T* Current() const override { return &value_; }
  9660. bool Equals(const ParamIteratorInterface<T>& other) const override {
  9661. // Having the same base generator guarantees that the other
  9662. // iterator is of the same type and we can downcast.
  9663. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  9664. << "The program attempted to compare iterators "
  9665. << "from different generators." << std::endl;
  9666. const int other_index =
  9667. CheckedDowncastToActualType<const Iterator>(&other)->index_;
  9668. return index_ == other_index;
  9669. }
  9670. private:
  9671. Iterator(const Iterator& other)
  9672. : ParamIteratorInterface<T>(),
  9673. base_(other.base_), value_(other.value_), index_(other.index_),
  9674. step_(other.step_) {}
  9675. // No implementation - assignment is unsupported.
  9676. void operator=(const Iterator& other);
  9677. const ParamGeneratorInterface<T>* const base_;
  9678. T value_;
  9679. int index_;
  9680. const IncrementT step_;
  9681. }; // class RangeGenerator::Iterator
  9682. static int CalculateEndIndex(const T& begin,
  9683. const T& end,
  9684. const IncrementT& step) {
  9685. int end_index = 0;
  9686. for (T i = begin; i < end; i = static_cast<T>(i + step))
  9687. end_index++;
  9688. return end_index;
  9689. }
  9690. // No implementation - assignment is unsupported.
  9691. void operator=(const RangeGenerator& other);
  9692. const T begin_;
  9693. const T end_;
  9694. const IncrementT step_;
  9695. // The index for the end() iterator. All the elements in the generated
  9696. // sequence are indexed (0-based) to aid iterator comparison.
  9697. const int end_index_;
  9698. }; // class RangeGenerator
  9699. // Generates values from a pair of STL-style iterators. Used in the
  9700. // ValuesIn() function. The elements are copied from the source range
  9701. // since the source can be located on the stack, and the generator
  9702. // is likely to persist beyond that stack frame.
  9703. template <typename T>
  9704. class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
  9705. public:
  9706. template <typename ForwardIterator>
  9707. ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
  9708. : container_(begin, end) {}
  9709. ~ValuesInIteratorRangeGenerator() override {}
  9710. ParamIteratorInterface<T>* Begin() const override {
  9711. return new Iterator(this, container_.begin());
  9712. }
  9713. ParamIteratorInterface<T>* End() const override {
  9714. return new Iterator(this, container_.end());
  9715. }
  9716. private:
  9717. typedef typename ::std::vector<T> ContainerType;
  9718. class Iterator : public ParamIteratorInterface<T> {
  9719. public:
  9720. Iterator(const ParamGeneratorInterface<T>* base,
  9721. typename ContainerType::const_iterator iterator)
  9722. : base_(base), iterator_(iterator) {}
  9723. ~Iterator() override {}
  9724. const ParamGeneratorInterface<T>* BaseGenerator() const override {
  9725. return base_;
  9726. }
  9727. void Advance() override {
  9728. ++iterator_;
  9729. value_.reset();
  9730. }
  9731. ParamIteratorInterface<T>* Clone() const override {
  9732. return new Iterator(*this);
  9733. }
  9734. // We need to use cached value referenced by iterator_ because *iterator_
  9735. // can return a temporary object (and of type other then T), so just
  9736. // having "return &*iterator_;" doesn't work.
  9737. // value_ is updated here and not in Advance() because Advance()
  9738. // can advance iterator_ beyond the end of the range, and we cannot
  9739. // detect that fact. The client code, on the other hand, is
  9740. // responsible for not calling Current() on an out-of-range iterator.
  9741. const T* Current() const override {
  9742. if (value_.get() == nullptr) value_.reset(new T(*iterator_));
  9743. return value_.get();
  9744. }
  9745. bool Equals(const ParamIteratorInterface<T>& other) const override {
  9746. // Having the same base generator guarantees that the other
  9747. // iterator is of the same type and we can downcast.
  9748. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  9749. << "The program attempted to compare iterators "
  9750. << "from different generators." << std::endl;
  9751. return iterator_ ==
  9752. CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
  9753. }
  9754. private:
  9755. Iterator(const Iterator& other)
  9756. // The explicit constructor call suppresses a false warning
  9757. // emitted by gcc when supplied with the -Wextra option.
  9758. : ParamIteratorInterface<T>(),
  9759. base_(other.base_),
  9760. iterator_(other.iterator_) {}
  9761. const ParamGeneratorInterface<T>* const base_;
  9762. typename ContainerType::const_iterator iterator_;
  9763. // A cached value of *iterator_. We keep it here to allow access by
  9764. // pointer in the wrapping iterator's operator->().
  9765. // value_ needs to be mutable to be accessed in Current().
  9766. // Use of std::unique_ptr helps manage cached value's lifetime,
  9767. // which is bound by the lifespan of the iterator itself.
  9768. mutable std::unique_ptr<const T> value_;
  9769. }; // class ValuesInIteratorRangeGenerator::Iterator
  9770. // No implementation - assignment is unsupported.
  9771. void operator=(const ValuesInIteratorRangeGenerator& other);
  9772. const ContainerType container_;
  9773. }; // class ValuesInIteratorRangeGenerator
  9774. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9775. //
  9776. // Default parameterized test name generator, returns a string containing the
  9777. // integer test parameter index.
  9778. template <class ParamType>
  9779. std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
  9780. Message name_stream;
  9781. name_stream << info.index;
  9782. return name_stream.GetString();
  9783. }
  9784. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9785. //
  9786. // Parameterized test name overload helpers, which help the
  9787. // INSTANTIATE_TEST_SUITE_P macro choose between the default parameterized
  9788. // test name generator and user param name generator.
  9789. template <class ParamType, class ParamNameGenFunctor>
  9790. ParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) {
  9791. return func;
  9792. }
  9793. template <class ParamType>
  9794. struct ParamNameGenFunc {
  9795. typedef std::string Type(const TestParamInfo<ParamType>&);
  9796. };
  9797. template <class ParamType>
  9798. typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
  9799. return &DefaultParamName;
  9800. }
  9801. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9802. //
  9803. // Stores a parameter value and later creates tests parameterized with that
  9804. // value.
  9805. template <class TestClass>
  9806. class ParameterizedTestFactory : public TestFactoryBase {
  9807. public:
  9808. typedef typename TestClass::ParamType ParamType;
  9809. explicit ParameterizedTestFactory(ParamType parameter) :
  9810. parameter_(parameter) {}
  9811. Test* CreateTest() override {
  9812. TestClass::SetParam(&parameter_);
  9813. return new TestClass();
  9814. }
  9815. private:
  9816. const ParamType parameter_;
  9817. GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
  9818. };
  9819. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9820. //
  9821. // TestMetaFactoryBase is a base class for meta-factories that create
  9822. // test factories for passing into MakeAndRegisterTestInfo function.
  9823. template <class ParamType>
  9824. class TestMetaFactoryBase {
  9825. public:
  9826. virtual ~TestMetaFactoryBase() {}
  9827. virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
  9828. };
  9829. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9830. //
  9831. // TestMetaFactory creates test factories for passing into
  9832. // MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives
  9833. // ownership of test factory pointer, same factory object cannot be passed
  9834. // into that method twice. But ParameterizedTestSuiteInfo is going to call
  9835. // it for each Test/Parameter value combination. Thus it needs meta factory
  9836. // creator class.
  9837. template <class TestSuite>
  9838. class TestMetaFactory
  9839. : public TestMetaFactoryBase<typename TestSuite::ParamType> {
  9840. public:
  9841. using ParamType = typename TestSuite::ParamType;
  9842. TestMetaFactory() {}
  9843. TestFactoryBase* CreateTestFactory(ParamType parameter) override {
  9844. return new ParameterizedTestFactory<TestSuite>(parameter);
  9845. }
  9846. private:
  9847. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
  9848. };
  9849. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9850. //
  9851. // ParameterizedTestSuiteInfoBase is a generic interface
  9852. // to ParameterizedTestSuiteInfo classes. ParameterizedTestSuiteInfoBase
  9853. // accumulates test information provided by TEST_P macro invocations
  9854. // and generators provided by INSTANTIATE_TEST_SUITE_P macro invocations
  9855. // and uses that information to register all resulting test instances
  9856. // in RegisterTests method. The ParameterizeTestSuiteRegistry class holds
  9857. // a collection of pointers to the ParameterizedTestSuiteInfo objects
  9858. // and calls RegisterTests() on each of them when asked.
  9859. class ParameterizedTestSuiteInfoBase {
  9860. public:
  9861. virtual ~ParameterizedTestSuiteInfoBase() {}
  9862. // Base part of test suite name for display purposes.
  9863. virtual const std::string& GetTestSuiteName() const = 0;
  9864. // Test case id to verify identity.
  9865. virtual TypeId GetTestSuiteTypeId() const = 0;
  9866. // UnitTest class invokes this method to register tests in this
  9867. // test suite right before running them in RUN_ALL_TESTS macro.
  9868. // This method should not be called more then once on any single
  9869. // instance of a ParameterizedTestSuiteInfoBase derived class.
  9870. virtual void RegisterTests() = 0;
  9871. protected:
  9872. ParameterizedTestSuiteInfoBase() {}
  9873. private:
  9874. GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);
  9875. };
  9876. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  9877. //
  9878. // ParameterizedTestSuiteInfo accumulates tests obtained from TEST_P
  9879. // macro invocations for a particular test suite and generators
  9880. // obtained from INSTANTIATE_TEST_SUITE_P macro invocations for that
  9881. // test suite. It registers tests with all values generated by all
  9882. // generators when asked.
  9883. template <class TestSuite>
  9884. class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
  9885. public:
  9886. // ParamType and GeneratorCreationFunc are private types but are required
  9887. // for declarations of public methods AddTestPattern() and
  9888. // AddTestSuiteInstantiation().
  9889. using ParamType = typename TestSuite::ParamType;
  9890. // A function that returns an instance of appropriate generator type.
  9891. typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
  9892. typedef typename ParamNameGenFunc<ParamType>::Type ParamNameGeneratorFunc;
  9893. explicit ParameterizedTestSuiteInfo(const char* name,
  9894. CodeLocation code_location)
  9895. : test_suite_name_(name), code_location_(code_location) {}
  9896. // Test case base name for display purposes.
  9897. const std::string& GetTestSuiteName() const override {
  9898. return test_suite_name_;
  9899. }
  9900. // Test case id to verify identity.
  9901. TypeId GetTestSuiteTypeId() const override { return GetTypeId<TestSuite>(); }
  9902. // TEST_P macro uses AddTestPattern() to record information
  9903. // about a single test in a LocalTestInfo structure.
  9904. // test_suite_name is the base name of the test suite (without invocation
  9905. // prefix). test_base_name is the name of an individual test without
  9906. // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
  9907. // test suite base name and DoBar is test base name.
  9908. void AddTestPattern(const char* test_suite_name, const char* test_base_name,
  9909. TestMetaFactoryBase<ParamType>* meta_factory) {
  9910. tests_.push_back(std::shared_ptr<TestInfo>(
  9911. new TestInfo(test_suite_name, test_base_name, meta_factory)));
  9912. }
  9913. // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
  9914. // about a generator.
  9915. int AddTestSuiteInstantiation(const std::string& instantiation_name,
  9916. GeneratorCreationFunc* func,
  9917. ParamNameGeneratorFunc* name_func,
  9918. const char* file, int line) {
  9919. instantiations_.push_back(
  9920. InstantiationInfo(instantiation_name, func, name_func, file, line));
  9921. return 0; // Return value used only to run this method in namespace scope.
  9922. }
  9923. // UnitTest class invokes this method to register tests in this test suite
  9924. // test suites right before running tests in RUN_ALL_TESTS macro.
  9925. // This method should not be called more then once on any single
  9926. // instance of a ParameterizedTestSuiteInfoBase derived class.
  9927. // UnitTest has a guard to prevent from calling this method more then once.
  9928. void RegisterTests() override {
  9929. for (typename TestInfoContainer::iterator test_it = tests_.begin();
  9930. test_it != tests_.end(); ++test_it) {
  9931. std::shared_ptr<TestInfo> test_info = *test_it;
  9932. for (typename InstantiationContainer::iterator gen_it =
  9933. instantiations_.begin(); gen_it != instantiations_.end();
  9934. ++gen_it) {
  9935. const std::string& instantiation_name = gen_it->name;
  9936. ParamGenerator<ParamType> generator((*gen_it->generator)());
  9937. ParamNameGeneratorFunc* name_func = gen_it->name_func;
  9938. const char* file = gen_it->file;
  9939. int line = gen_it->line;
  9940. std::string test_suite_name;
  9941. if ( !instantiation_name.empty() )
  9942. test_suite_name = instantiation_name + "/";
  9943. test_suite_name += test_info->test_suite_base_name;
  9944. size_t i = 0;
  9945. std::set<std::string> test_param_names;
  9946. for (typename ParamGenerator<ParamType>::iterator param_it =
  9947. generator.begin();
  9948. param_it != generator.end(); ++param_it, ++i) {
  9949. Message test_name_stream;
  9950. std::string param_name = name_func(
  9951. TestParamInfo<ParamType>(*param_it, i));
  9952. GTEST_CHECK_(IsValidParamName(param_name))
  9953. << "Parameterized test name '" << param_name
  9954. << "' is invalid, in " << file
  9955. << " line " << line << std::endl;
  9956. GTEST_CHECK_(test_param_names.count(param_name) == 0)
  9957. << "Duplicate parameterized test name '" << param_name
  9958. << "', in " << file << " line " << line << std::endl;
  9959. test_param_names.insert(param_name);
  9960. test_name_stream << test_info->test_base_name << "/" << param_name;
  9961. MakeAndRegisterTestInfo(
  9962. test_suite_name.c_str(), test_name_stream.GetString().c_str(),
  9963. nullptr, // No type parameter.
  9964. PrintToString(*param_it).c_str(), code_location_,
  9965. GetTestSuiteTypeId(),
  9966. SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(),
  9967. SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(),
  9968. test_info->test_meta_factory->CreateTestFactory(*param_it));
  9969. } // for param_it
  9970. } // for gen_it
  9971. } // for test_it
  9972. } // RegisterTests
  9973. private:
  9974. // LocalTestInfo structure keeps information about a single test registered
  9975. // with TEST_P macro.
  9976. struct TestInfo {
  9977. TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
  9978. TestMetaFactoryBase<ParamType>* a_test_meta_factory)
  9979. : test_suite_base_name(a_test_suite_base_name),
  9980. test_base_name(a_test_base_name),
  9981. test_meta_factory(a_test_meta_factory) {}
  9982. const std::string test_suite_base_name;
  9983. const std::string test_base_name;
  9984. const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
  9985. };
  9986. using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;
  9987. // Records data received from INSTANTIATE_TEST_SUITE_P macros:
  9988. // <Instantiation name, Sequence generator creation function,
  9989. // Name generator function, Source file, Source line>
  9990. struct InstantiationInfo {
  9991. InstantiationInfo(const std::string &name_in,
  9992. GeneratorCreationFunc* generator_in,
  9993. ParamNameGeneratorFunc* name_func_in,
  9994. const char* file_in,
  9995. int line_in)
  9996. : name(name_in),
  9997. generator(generator_in),
  9998. name_func(name_func_in),
  9999. file(file_in),
  10000. line(line_in) {}
  10001. std::string name;
  10002. GeneratorCreationFunc* generator;
  10003. ParamNameGeneratorFunc* name_func;
  10004. const char* file;
  10005. int line;
  10006. };
  10007. typedef ::std::vector<InstantiationInfo> InstantiationContainer;
  10008. static bool IsValidParamName(const std::string& name) {
  10009. // Check for empty string
  10010. if (name.empty())
  10011. return false;
  10012. // Check for invalid characters
  10013. for (std::string::size_type index = 0; index < name.size(); ++index) {
  10014. if (!isalnum(name[index]) && name[index] != '_')
  10015. return false;
  10016. }
  10017. return true;
  10018. }
  10019. const std::string test_suite_name_;
  10020. CodeLocation code_location_;
  10021. TestInfoContainer tests_;
  10022. InstantiationContainer instantiations_;
  10023. GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);
  10024. }; // class ParameterizedTestSuiteInfo
  10025. // Legacy API is deprecated but still available
  10026. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  10027. template <class TestCase>
  10028. using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
  10029. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  10030. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  10031. //
  10032. // ParameterizedTestSuiteRegistry contains a map of
  10033. // ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P
  10034. // and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding
  10035. // ParameterizedTestSuiteInfo descriptors.
  10036. class ParameterizedTestSuiteRegistry {
  10037. public:
  10038. ParameterizedTestSuiteRegistry() {}
  10039. ~ParameterizedTestSuiteRegistry() {
  10040. for (auto& test_suite_info : test_suite_infos_) {
  10041. delete test_suite_info;
  10042. }
  10043. }
  10044. // Looks up or creates and returns a structure containing information about
  10045. // tests and instantiations of a particular test suite.
  10046. template <class TestSuite>
  10047. ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(
  10048. const char* test_suite_name, CodeLocation code_location) {
  10049. ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;
  10050. for (auto& test_suite_info : test_suite_infos_) {
  10051. if (test_suite_info->GetTestSuiteName() == test_suite_name) {
  10052. if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
  10053. // Complain about incorrect usage of Google Test facilities
  10054. // and terminate the program since we cannot guaranty correct
  10055. // test suite setup and tear-down in this case.
  10056. ReportInvalidTestSuiteType(test_suite_name, code_location);
  10057. posix::Abort();
  10058. } else {
  10059. // At this point we are sure that the object we found is of the same
  10060. // type we are looking for, so we downcast it to that type
  10061. // without further checks.
  10062. typed_test_info = CheckedDowncastToActualType<
  10063. ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);
  10064. }
  10065. break;
  10066. }
  10067. }
  10068. if (typed_test_info == nullptr) {
  10069. typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(
  10070. test_suite_name, code_location);
  10071. test_suite_infos_.push_back(typed_test_info);
  10072. }
  10073. return typed_test_info;
  10074. }
  10075. void RegisterTests() {
  10076. for (auto& test_suite_info : test_suite_infos_) {
  10077. test_suite_info->RegisterTests();
  10078. }
  10079. }
  10080. // Legacy API is deprecated but still available
  10081. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  10082. template <class TestCase>
  10083. ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
  10084. const char* test_case_name, CodeLocation code_location) {
  10085. return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);
  10086. }
  10087. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  10088. private:
  10089. using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;
  10090. TestSuiteInfoContainer test_suite_infos_;
  10091. GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);
  10092. };
  10093. } // namespace internal
  10094. // Forward declarations of ValuesIn(), which is implemented in
  10095. // include/gtest/gtest-param-test.h.
  10096. template <class Container>
  10097. internal::ParamGenerator<typename Container::value_type> ValuesIn(
  10098. const Container& container);
  10099. namespace internal {
  10100. // Used in the Values() function to provide polymorphic capabilities.
  10101. template <typename... Ts>
  10102. class ValueArray {
  10103. public:
  10104. ValueArray(Ts... v) : v_{std::move(v)...} {}
  10105. template <typename T>
  10106. operator ParamGenerator<T>() const { // NOLINT
  10107. return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
  10108. }
  10109. private:
  10110. template <typename T, size_t... I>
  10111. std::vector<T> MakeVector(IndexSequence<I...>) const {
  10112. return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
  10113. }
  10114. FlatTuple<Ts...> v_;
  10115. };
  10116. } // namespace internal
  10117. } // namespace testing
  10118. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
  10119. // This file was GENERATED by command:
  10120. // pump.py gtest-param-util-generated.h.pump
  10121. // DO NOT EDIT BY HAND!!!
  10122. // Copyright 2008 Google Inc.
  10123. // All Rights Reserved.
  10124. //
  10125. // Redistribution and use in source and binary forms, with or without
  10126. // modification, are permitted provided that the following conditions are
  10127. // met:
  10128. //
  10129. // * Redistributions of source code must retain the above copyright
  10130. // notice, this list of conditions and the following disclaimer.
  10131. // * Redistributions in binary form must reproduce the above
  10132. // copyright notice, this list of conditions and the following disclaimer
  10133. // in the documentation and/or other materials provided with the
  10134. // distribution.
  10135. // * Neither the name of Google Inc. nor the names of its
  10136. // contributors may be used to endorse or promote products derived from
  10137. // this software without specific prior written permission.
  10138. //
  10139. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  10140. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  10141. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10142. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10143. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10144. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  10145. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10146. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10147. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10148. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  10149. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10150. // Type and function utilities for implementing parameterized tests.
  10151. // This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
  10152. //
  10153. // Currently Google Test supports at most 50 arguments in Values,
  10154. // and at most 10 arguments in Combine. Please contact
  10155. // googletestframework@googlegroups.com if you need more.
  10156. // Please note that the number of arguments to Combine is limited
  10157. // by the maximum arity of the implementation of tuple which is
  10158. // currently set at 10.
  10159. // GOOGLETEST_CM0001 DO NOT DELETE
  10160. #include <assert.h>
  10161. #include <memory>
  10162. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
  10163. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
  10164. namespace testing {
  10165. namespace internal {
  10166. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  10167. //
  10168. // Generates values from the Cartesian product of values produced
  10169. // by the argument generators.
  10170. //
  10171. template <typename T1, typename T2>
  10172. class CartesianProductGenerator2
  10173. : public ParamGeneratorInterface< ::std::tuple<T1, T2> > {
  10174. public:
  10175. typedef ::std::tuple<T1, T2> ParamType;
  10176. CartesianProductGenerator2(const ParamGenerator<T1>& g1,
  10177. const ParamGenerator<T2>& g2)
  10178. : g1_(g1), g2_(g2) {}
  10179. ~CartesianProductGenerator2() override {}
  10180. ParamIteratorInterface<ParamType>* Begin() const override {
  10181. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());
  10182. }
  10183. ParamIteratorInterface<ParamType>* End() const override {
  10184. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());
  10185. }
  10186. private:
  10187. class Iterator : public ParamIteratorInterface<ParamType> {
  10188. public:
  10189. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10190. const ParamGenerator<T1>& g1,
  10191. const typename ParamGenerator<T1>::iterator& current1,
  10192. const ParamGenerator<T2>& g2,
  10193. const typename ParamGenerator<T2>::iterator& current2)
  10194. : base_(base),
  10195. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10196. begin2_(g2.begin()), end2_(g2.end()), current2_(current2) {
  10197. ComputeCurrentValue();
  10198. }
  10199. ~Iterator() override {}
  10200. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10201. return base_;
  10202. }
  10203. // Advance should not be called on beyond-of-range iterators
  10204. // so no component iterators must be beyond end of range, either.
  10205. void Advance() override {
  10206. assert(!AtEnd());
  10207. ++current2_;
  10208. if (current2_ == end2_) {
  10209. current2_ = begin2_;
  10210. ++current1_;
  10211. }
  10212. ComputeCurrentValue();
  10213. }
  10214. ParamIteratorInterface<ParamType>* Clone() const override {
  10215. return new Iterator(*this);
  10216. }
  10217. const ParamType* Current() const override { return current_value_.get(); }
  10218. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10219. // Having the same base generator guarantees that the other
  10220. // iterator is of the same type and we can downcast.
  10221. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10222. << "The program attempted to compare iterators "
  10223. << "from different generators." << std::endl;
  10224. const Iterator* typed_other =
  10225. CheckedDowncastToActualType<const Iterator>(&other);
  10226. // We must report iterators equal if they both point beyond their
  10227. // respective ranges. That can happen in a variety of fashions,
  10228. // so we have to consult AtEnd().
  10229. return (AtEnd() && typed_other->AtEnd()) ||
  10230. (
  10231. current1_ == typed_other->current1_ &&
  10232. current2_ == typed_other->current2_);
  10233. }
  10234. private:
  10235. Iterator(const Iterator& other)
  10236. : base_(other.base_),
  10237. begin1_(other.begin1_),
  10238. end1_(other.end1_),
  10239. current1_(other.current1_),
  10240. begin2_(other.begin2_),
  10241. end2_(other.end2_),
  10242. current2_(other.current2_) {
  10243. ComputeCurrentValue();
  10244. }
  10245. void ComputeCurrentValue() {
  10246. if (!AtEnd())
  10247. current_value_.reset(new ParamType(*current1_, *current2_));
  10248. }
  10249. bool AtEnd() const {
  10250. // We must report iterator past the end of the range when either of the
  10251. // component iterators has reached the end of its range.
  10252. return
  10253. current1_ == end1_ ||
  10254. current2_ == end2_;
  10255. }
  10256. // No implementation - assignment is unsupported.
  10257. void operator=(const Iterator& other);
  10258. const ParamGeneratorInterface<ParamType>* const base_;
  10259. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  10260. // current[i]_ is the actual traversing iterator.
  10261. const typename ParamGenerator<T1>::iterator begin1_;
  10262. const typename ParamGenerator<T1>::iterator end1_;
  10263. typename ParamGenerator<T1>::iterator current1_;
  10264. const typename ParamGenerator<T2>::iterator begin2_;
  10265. const typename ParamGenerator<T2>::iterator end2_;
  10266. typename ParamGenerator<T2>::iterator current2_;
  10267. std::shared_ptr<ParamType> current_value_;
  10268. }; // class CartesianProductGenerator2::Iterator
  10269. // No implementation - assignment is unsupported.
  10270. void operator=(const CartesianProductGenerator2& other);
  10271. const ParamGenerator<T1> g1_;
  10272. const ParamGenerator<T2> g2_;
  10273. }; // class CartesianProductGenerator2
  10274. template <typename T1, typename T2, typename T3>
  10275. class CartesianProductGenerator3
  10276. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3> > {
  10277. public:
  10278. typedef ::std::tuple<T1, T2, T3> ParamType;
  10279. CartesianProductGenerator3(const ParamGenerator<T1>& g1,
  10280. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
  10281. : g1_(g1), g2_(g2), g3_(g3) {}
  10282. ~CartesianProductGenerator3() override {}
  10283. ParamIteratorInterface<ParamType>* Begin() const override {
  10284. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  10285. g3_.begin());
  10286. }
  10287. ParamIteratorInterface<ParamType>* End() const override {
  10288. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());
  10289. }
  10290. private:
  10291. class Iterator : public ParamIteratorInterface<ParamType> {
  10292. public:
  10293. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10294. const ParamGenerator<T1>& g1,
  10295. const typename ParamGenerator<T1>::iterator& current1,
  10296. const ParamGenerator<T2>& g2,
  10297. const typename ParamGenerator<T2>::iterator& current2,
  10298. const ParamGenerator<T3>& g3,
  10299. const typename ParamGenerator<T3>::iterator& current3)
  10300. : base_(base),
  10301. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10302. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  10303. begin3_(g3.begin()), end3_(g3.end()), current3_(current3) {
  10304. ComputeCurrentValue();
  10305. }
  10306. ~Iterator() override {}
  10307. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10308. return base_;
  10309. }
  10310. // Advance should not be called on beyond-of-range iterators
  10311. // so no component iterators must be beyond end of range, either.
  10312. void Advance() override {
  10313. assert(!AtEnd());
  10314. ++current3_;
  10315. if (current3_ == end3_) {
  10316. current3_ = begin3_;
  10317. ++current2_;
  10318. }
  10319. if (current2_ == end2_) {
  10320. current2_ = begin2_;
  10321. ++current1_;
  10322. }
  10323. ComputeCurrentValue();
  10324. }
  10325. ParamIteratorInterface<ParamType>* Clone() const override {
  10326. return new Iterator(*this);
  10327. }
  10328. const ParamType* Current() const override { return current_value_.get(); }
  10329. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10330. // Having the same base generator guarantees that the other
  10331. // iterator is of the same type and we can downcast.
  10332. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10333. << "The program attempted to compare iterators "
  10334. << "from different generators." << std::endl;
  10335. const Iterator* typed_other =
  10336. CheckedDowncastToActualType<const Iterator>(&other);
  10337. // We must report iterators equal if they both point beyond their
  10338. // respective ranges. That can happen in a variety of fashions,
  10339. // so we have to consult AtEnd().
  10340. return (AtEnd() && typed_other->AtEnd()) ||
  10341. (
  10342. current1_ == typed_other->current1_ &&
  10343. current2_ == typed_other->current2_ &&
  10344. current3_ == typed_other->current3_);
  10345. }
  10346. private:
  10347. Iterator(const Iterator& other)
  10348. : base_(other.base_),
  10349. begin1_(other.begin1_),
  10350. end1_(other.end1_),
  10351. current1_(other.current1_),
  10352. begin2_(other.begin2_),
  10353. end2_(other.end2_),
  10354. current2_(other.current2_),
  10355. begin3_(other.begin3_),
  10356. end3_(other.end3_),
  10357. current3_(other.current3_) {
  10358. ComputeCurrentValue();
  10359. }
  10360. void ComputeCurrentValue() {
  10361. if (!AtEnd())
  10362. current_value_.reset(new ParamType(*current1_, *current2_, *current3_));
  10363. }
  10364. bool AtEnd() const {
  10365. // We must report iterator past the end of the range when either of the
  10366. // component iterators has reached the end of its range.
  10367. return
  10368. current1_ == end1_ ||
  10369. current2_ == end2_ ||
  10370. current3_ == end3_;
  10371. }
  10372. // No implementation - assignment is unsupported.
  10373. void operator=(const Iterator& other);
  10374. const ParamGeneratorInterface<ParamType>* const base_;
  10375. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  10376. // current[i]_ is the actual traversing iterator.
  10377. const typename ParamGenerator<T1>::iterator begin1_;
  10378. const typename ParamGenerator<T1>::iterator end1_;
  10379. typename ParamGenerator<T1>::iterator current1_;
  10380. const typename ParamGenerator<T2>::iterator begin2_;
  10381. const typename ParamGenerator<T2>::iterator end2_;
  10382. typename ParamGenerator<T2>::iterator current2_;
  10383. const typename ParamGenerator<T3>::iterator begin3_;
  10384. const typename ParamGenerator<T3>::iterator end3_;
  10385. typename ParamGenerator<T3>::iterator current3_;
  10386. std::shared_ptr<ParamType> current_value_;
  10387. }; // class CartesianProductGenerator3::Iterator
  10388. // No implementation - assignment is unsupported.
  10389. void operator=(const CartesianProductGenerator3& other);
  10390. const ParamGenerator<T1> g1_;
  10391. const ParamGenerator<T2> g2_;
  10392. const ParamGenerator<T3> g3_;
  10393. }; // class CartesianProductGenerator3
  10394. template <typename T1, typename T2, typename T3, typename T4>
  10395. class CartesianProductGenerator4
  10396. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4> > {
  10397. public:
  10398. typedef ::std::tuple<T1, T2, T3, T4> ParamType;
  10399. CartesianProductGenerator4(const ParamGenerator<T1>& g1,
  10400. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  10401. const ParamGenerator<T4>& g4)
  10402. : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
  10403. ~CartesianProductGenerator4() override {}
  10404. ParamIteratorInterface<ParamType>* Begin() const override {
  10405. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  10406. g3_.begin(), g4_, g4_.begin());
  10407. }
  10408. ParamIteratorInterface<ParamType>* End() const override {
  10409. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  10410. g4_, g4_.end());
  10411. }
  10412. private:
  10413. class Iterator : public ParamIteratorInterface<ParamType> {
  10414. public:
  10415. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10416. const ParamGenerator<T1>& g1,
  10417. const typename ParamGenerator<T1>::iterator& current1,
  10418. const ParamGenerator<T2>& g2,
  10419. const typename ParamGenerator<T2>::iterator& current2,
  10420. const ParamGenerator<T3>& g3,
  10421. const typename ParamGenerator<T3>::iterator& current3,
  10422. const ParamGenerator<T4>& g4,
  10423. const typename ParamGenerator<T4>::iterator& current4)
  10424. : base_(base),
  10425. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10426. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  10427. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  10428. begin4_(g4.begin()), end4_(g4.end()), current4_(current4) {
  10429. ComputeCurrentValue();
  10430. }
  10431. ~Iterator() override {}
  10432. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10433. return base_;
  10434. }
  10435. // Advance should not be called on beyond-of-range iterators
  10436. // so no component iterators must be beyond end of range, either.
  10437. void Advance() override {
  10438. assert(!AtEnd());
  10439. ++current4_;
  10440. if (current4_ == end4_) {
  10441. current4_ = begin4_;
  10442. ++current3_;
  10443. }
  10444. if (current3_ == end3_) {
  10445. current3_ = begin3_;
  10446. ++current2_;
  10447. }
  10448. if (current2_ == end2_) {
  10449. current2_ = begin2_;
  10450. ++current1_;
  10451. }
  10452. ComputeCurrentValue();
  10453. }
  10454. ParamIteratorInterface<ParamType>* Clone() const override {
  10455. return new Iterator(*this);
  10456. }
  10457. const ParamType* Current() const override { return current_value_.get(); }
  10458. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10459. // Having the same base generator guarantees that the other
  10460. // iterator is of the same type and we can downcast.
  10461. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10462. << "The program attempted to compare iterators "
  10463. << "from different generators." << std::endl;
  10464. const Iterator* typed_other =
  10465. CheckedDowncastToActualType<const Iterator>(&other);
  10466. // We must report iterators equal if they both point beyond their
  10467. // respective ranges. That can happen in a variety of fashions,
  10468. // so we have to consult AtEnd().
  10469. return (AtEnd() && typed_other->AtEnd()) ||
  10470. (
  10471. current1_ == typed_other->current1_ &&
  10472. current2_ == typed_other->current2_ &&
  10473. current3_ == typed_other->current3_ &&
  10474. current4_ == typed_other->current4_);
  10475. }
  10476. private:
  10477. Iterator(const Iterator& other)
  10478. : base_(other.base_),
  10479. begin1_(other.begin1_),
  10480. end1_(other.end1_),
  10481. current1_(other.current1_),
  10482. begin2_(other.begin2_),
  10483. end2_(other.end2_),
  10484. current2_(other.current2_),
  10485. begin3_(other.begin3_),
  10486. end3_(other.end3_),
  10487. current3_(other.current3_),
  10488. begin4_(other.begin4_),
  10489. end4_(other.end4_),
  10490. current4_(other.current4_) {
  10491. ComputeCurrentValue();
  10492. }
  10493. void ComputeCurrentValue() {
  10494. if (!AtEnd())
  10495. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  10496. *current4_));
  10497. }
  10498. bool AtEnd() const {
  10499. // We must report iterator past the end of the range when either of the
  10500. // component iterators has reached the end of its range.
  10501. return
  10502. current1_ == end1_ ||
  10503. current2_ == end2_ ||
  10504. current3_ == end3_ ||
  10505. current4_ == end4_;
  10506. }
  10507. // No implementation - assignment is unsupported.
  10508. void operator=(const Iterator& other);
  10509. const ParamGeneratorInterface<ParamType>* const base_;
  10510. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  10511. // current[i]_ is the actual traversing iterator.
  10512. const typename ParamGenerator<T1>::iterator begin1_;
  10513. const typename ParamGenerator<T1>::iterator end1_;
  10514. typename ParamGenerator<T1>::iterator current1_;
  10515. const typename ParamGenerator<T2>::iterator begin2_;
  10516. const typename ParamGenerator<T2>::iterator end2_;
  10517. typename ParamGenerator<T2>::iterator current2_;
  10518. const typename ParamGenerator<T3>::iterator begin3_;
  10519. const typename ParamGenerator<T3>::iterator end3_;
  10520. typename ParamGenerator<T3>::iterator current3_;
  10521. const typename ParamGenerator<T4>::iterator begin4_;
  10522. const typename ParamGenerator<T4>::iterator end4_;
  10523. typename ParamGenerator<T4>::iterator current4_;
  10524. std::shared_ptr<ParamType> current_value_;
  10525. }; // class CartesianProductGenerator4::Iterator
  10526. // No implementation - assignment is unsupported.
  10527. void operator=(const CartesianProductGenerator4& other);
  10528. const ParamGenerator<T1> g1_;
  10529. const ParamGenerator<T2> g2_;
  10530. const ParamGenerator<T3> g3_;
  10531. const ParamGenerator<T4> g4_;
  10532. }; // class CartesianProductGenerator4
  10533. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  10534. class CartesianProductGenerator5
  10535. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5> > {
  10536. public:
  10537. typedef ::std::tuple<T1, T2, T3, T4, T5> ParamType;
  10538. CartesianProductGenerator5(const ParamGenerator<T1>& g1,
  10539. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  10540. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)
  10541. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
  10542. ~CartesianProductGenerator5() override {}
  10543. ParamIteratorInterface<ParamType>* Begin() const override {
  10544. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  10545. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());
  10546. }
  10547. ParamIteratorInterface<ParamType>* End() const override {
  10548. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  10549. g4_, g4_.end(), g5_, g5_.end());
  10550. }
  10551. private:
  10552. class Iterator : public ParamIteratorInterface<ParamType> {
  10553. public:
  10554. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10555. const ParamGenerator<T1>& g1,
  10556. const typename ParamGenerator<T1>::iterator& current1,
  10557. const ParamGenerator<T2>& g2,
  10558. const typename ParamGenerator<T2>::iterator& current2,
  10559. const ParamGenerator<T3>& g3,
  10560. const typename ParamGenerator<T3>::iterator& current3,
  10561. const ParamGenerator<T4>& g4,
  10562. const typename ParamGenerator<T4>::iterator& current4,
  10563. const ParamGenerator<T5>& g5,
  10564. const typename ParamGenerator<T5>::iterator& current5)
  10565. : base_(base),
  10566. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10567. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  10568. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  10569. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  10570. begin5_(g5.begin()), end5_(g5.end()), current5_(current5) {
  10571. ComputeCurrentValue();
  10572. }
  10573. ~Iterator() override {}
  10574. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10575. return base_;
  10576. }
  10577. // Advance should not be called on beyond-of-range iterators
  10578. // so no component iterators must be beyond end of range, either.
  10579. void Advance() override {
  10580. assert(!AtEnd());
  10581. ++current5_;
  10582. if (current5_ == end5_) {
  10583. current5_ = begin5_;
  10584. ++current4_;
  10585. }
  10586. if (current4_ == end4_) {
  10587. current4_ = begin4_;
  10588. ++current3_;
  10589. }
  10590. if (current3_ == end3_) {
  10591. current3_ = begin3_;
  10592. ++current2_;
  10593. }
  10594. if (current2_ == end2_) {
  10595. current2_ = begin2_;
  10596. ++current1_;
  10597. }
  10598. ComputeCurrentValue();
  10599. }
  10600. ParamIteratorInterface<ParamType>* Clone() const override {
  10601. return new Iterator(*this);
  10602. }
  10603. const ParamType* Current() const override { return current_value_.get(); }
  10604. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10605. // Having the same base generator guarantees that the other
  10606. // iterator is of the same type and we can downcast.
  10607. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10608. << "The program attempted to compare iterators "
  10609. << "from different generators." << std::endl;
  10610. const Iterator* typed_other =
  10611. CheckedDowncastToActualType<const Iterator>(&other);
  10612. // We must report iterators equal if they both point beyond their
  10613. // respective ranges. That can happen in a variety of fashions,
  10614. // so we have to consult AtEnd().
  10615. return (AtEnd() && typed_other->AtEnd()) ||
  10616. (
  10617. current1_ == typed_other->current1_ &&
  10618. current2_ == typed_other->current2_ &&
  10619. current3_ == typed_other->current3_ &&
  10620. current4_ == typed_other->current4_ &&
  10621. current5_ == typed_other->current5_);
  10622. }
  10623. private:
  10624. Iterator(const Iterator& other)
  10625. : base_(other.base_),
  10626. begin1_(other.begin1_),
  10627. end1_(other.end1_),
  10628. current1_(other.current1_),
  10629. begin2_(other.begin2_),
  10630. end2_(other.end2_),
  10631. current2_(other.current2_),
  10632. begin3_(other.begin3_),
  10633. end3_(other.end3_),
  10634. current3_(other.current3_),
  10635. begin4_(other.begin4_),
  10636. end4_(other.end4_),
  10637. current4_(other.current4_),
  10638. begin5_(other.begin5_),
  10639. end5_(other.end5_),
  10640. current5_(other.current5_) {
  10641. ComputeCurrentValue();
  10642. }
  10643. void ComputeCurrentValue() {
  10644. if (!AtEnd())
  10645. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  10646. *current4_, *current5_));
  10647. }
  10648. bool AtEnd() const {
  10649. // We must report iterator past the end of the range when either of the
  10650. // component iterators has reached the end of its range.
  10651. return
  10652. current1_ == end1_ ||
  10653. current2_ == end2_ ||
  10654. current3_ == end3_ ||
  10655. current4_ == end4_ ||
  10656. current5_ == end5_;
  10657. }
  10658. // No implementation - assignment is unsupported.
  10659. void operator=(const Iterator& other);
  10660. const ParamGeneratorInterface<ParamType>* const base_;
  10661. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  10662. // current[i]_ is the actual traversing iterator.
  10663. const typename ParamGenerator<T1>::iterator begin1_;
  10664. const typename ParamGenerator<T1>::iterator end1_;
  10665. typename ParamGenerator<T1>::iterator current1_;
  10666. const typename ParamGenerator<T2>::iterator begin2_;
  10667. const typename ParamGenerator<T2>::iterator end2_;
  10668. typename ParamGenerator<T2>::iterator current2_;
  10669. const typename ParamGenerator<T3>::iterator begin3_;
  10670. const typename ParamGenerator<T3>::iterator end3_;
  10671. typename ParamGenerator<T3>::iterator current3_;
  10672. const typename ParamGenerator<T4>::iterator begin4_;
  10673. const typename ParamGenerator<T4>::iterator end4_;
  10674. typename ParamGenerator<T4>::iterator current4_;
  10675. const typename ParamGenerator<T5>::iterator begin5_;
  10676. const typename ParamGenerator<T5>::iterator end5_;
  10677. typename ParamGenerator<T5>::iterator current5_;
  10678. std::shared_ptr<ParamType> current_value_;
  10679. }; // class CartesianProductGenerator5::Iterator
  10680. // No implementation - assignment is unsupported.
  10681. void operator=(const CartesianProductGenerator5& other);
  10682. const ParamGenerator<T1> g1_;
  10683. const ParamGenerator<T2> g2_;
  10684. const ParamGenerator<T3> g3_;
  10685. const ParamGenerator<T4> g4_;
  10686. const ParamGenerator<T5> g5_;
  10687. }; // class CartesianProductGenerator5
  10688. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  10689. typename T6>
  10690. class CartesianProductGenerator6
  10691. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6> > {
  10692. public:
  10693. typedef ::std::tuple<T1, T2, T3, T4, T5, T6> ParamType;
  10694. CartesianProductGenerator6(const ParamGenerator<T1>& g1,
  10695. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  10696. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
  10697. const ParamGenerator<T6>& g6)
  10698. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
  10699. ~CartesianProductGenerator6() override {}
  10700. ParamIteratorInterface<ParamType>* Begin() const override {
  10701. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  10702. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());
  10703. }
  10704. ParamIteratorInterface<ParamType>* End() const override {
  10705. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  10706. g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());
  10707. }
  10708. private:
  10709. class Iterator : public ParamIteratorInterface<ParamType> {
  10710. public:
  10711. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10712. const ParamGenerator<T1>& g1,
  10713. const typename ParamGenerator<T1>::iterator& current1,
  10714. const ParamGenerator<T2>& g2,
  10715. const typename ParamGenerator<T2>::iterator& current2,
  10716. const ParamGenerator<T3>& g3,
  10717. const typename ParamGenerator<T3>::iterator& current3,
  10718. const ParamGenerator<T4>& g4,
  10719. const typename ParamGenerator<T4>::iterator& current4,
  10720. const ParamGenerator<T5>& g5,
  10721. const typename ParamGenerator<T5>::iterator& current5,
  10722. const ParamGenerator<T6>& g6,
  10723. const typename ParamGenerator<T6>::iterator& current6)
  10724. : base_(base),
  10725. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10726. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  10727. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  10728. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  10729. begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
  10730. begin6_(g6.begin()), end6_(g6.end()), current6_(current6) {
  10731. ComputeCurrentValue();
  10732. }
  10733. ~Iterator() override {}
  10734. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10735. return base_;
  10736. }
  10737. // Advance should not be called on beyond-of-range iterators
  10738. // so no component iterators must be beyond end of range, either.
  10739. void Advance() override {
  10740. assert(!AtEnd());
  10741. ++current6_;
  10742. if (current6_ == end6_) {
  10743. current6_ = begin6_;
  10744. ++current5_;
  10745. }
  10746. if (current5_ == end5_) {
  10747. current5_ = begin5_;
  10748. ++current4_;
  10749. }
  10750. if (current4_ == end4_) {
  10751. current4_ = begin4_;
  10752. ++current3_;
  10753. }
  10754. if (current3_ == end3_) {
  10755. current3_ = begin3_;
  10756. ++current2_;
  10757. }
  10758. if (current2_ == end2_) {
  10759. current2_ = begin2_;
  10760. ++current1_;
  10761. }
  10762. ComputeCurrentValue();
  10763. }
  10764. ParamIteratorInterface<ParamType>* Clone() const override {
  10765. return new Iterator(*this);
  10766. }
  10767. const ParamType* Current() const override { return current_value_.get(); }
  10768. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10769. // Having the same base generator guarantees that the other
  10770. // iterator is of the same type and we can downcast.
  10771. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10772. << "The program attempted to compare iterators "
  10773. << "from different generators." << std::endl;
  10774. const Iterator* typed_other =
  10775. CheckedDowncastToActualType<const Iterator>(&other);
  10776. // We must report iterators equal if they both point beyond their
  10777. // respective ranges. That can happen in a variety of fashions,
  10778. // so we have to consult AtEnd().
  10779. return (AtEnd() && typed_other->AtEnd()) ||
  10780. (
  10781. current1_ == typed_other->current1_ &&
  10782. current2_ == typed_other->current2_ &&
  10783. current3_ == typed_other->current3_ &&
  10784. current4_ == typed_other->current4_ &&
  10785. current5_ == typed_other->current5_ &&
  10786. current6_ == typed_other->current6_);
  10787. }
  10788. private:
  10789. Iterator(const Iterator& other)
  10790. : base_(other.base_),
  10791. begin1_(other.begin1_),
  10792. end1_(other.end1_),
  10793. current1_(other.current1_),
  10794. begin2_(other.begin2_),
  10795. end2_(other.end2_),
  10796. current2_(other.current2_),
  10797. begin3_(other.begin3_),
  10798. end3_(other.end3_),
  10799. current3_(other.current3_),
  10800. begin4_(other.begin4_),
  10801. end4_(other.end4_),
  10802. current4_(other.current4_),
  10803. begin5_(other.begin5_),
  10804. end5_(other.end5_),
  10805. current5_(other.current5_),
  10806. begin6_(other.begin6_),
  10807. end6_(other.end6_),
  10808. current6_(other.current6_) {
  10809. ComputeCurrentValue();
  10810. }
  10811. void ComputeCurrentValue() {
  10812. if (!AtEnd())
  10813. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  10814. *current4_, *current5_, *current6_));
  10815. }
  10816. bool AtEnd() const {
  10817. // We must report iterator past the end of the range when either of the
  10818. // component iterators has reached the end of its range.
  10819. return
  10820. current1_ == end1_ ||
  10821. current2_ == end2_ ||
  10822. current3_ == end3_ ||
  10823. current4_ == end4_ ||
  10824. current5_ == end5_ ||
  10825. current6_ == end6_;
  10826. }
  10827. // No implementation - assignment is unsupported.
  10828. void operator=(const Iterator& other);
  10829. const ParamGeneratorInterface<ParamType>* const base_;
  10830. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  10831. // current[i]_ is the actual traversing iterator.
  10832. const typename ParamGenerator<T1>::iterator begin1_;
  10833. const typename ParamGenerator<T1>::iterator end1_;
  10834. typename ParamGenerator<T1>::iterator current1_;
  10835. const typename ParamGenerator<T2>::iterator begin2_;
  10836. const typename ParamGenerator<T2>::iterator end2_;
  10837. typename ParamGenerator<T2>::iterator current2_;
  10838. const typename ParamGenerator<T3>::iterator begin3_;
  10839. const typename ParamGenerator<T3>::iterator end3_;
  10840. typename ParamGenerator<T3>::iterator current3_;
  10841. const typename ParamGenerator<T4>::iterator begin4_;
  10842. const typename ParamGenerator<T4>::iterator end4_;
  10843. typename ParamGenerator<T4>::iterator current4_;
  10844. const typename ParamGenerator<T5>::iterator begin5_;
  10845. const typename ParamGenerator<T5>::iterator end5_;
  10846. typename ParamGenerator<T5>::iterator current5_;
  10847. const typename ParamGenerator<T6>::iterator begin6_;
  10848. const typename ParamGenerator<T6>::iterator end6_;
  10849. typename ParamGenerator<T6>::iterator current6_;
  10850. std::shared_ptr<ParamType> current_value_;
  10851. }; // class CartesianProductGenerator6::Iterator
  10852. // No implementation - assignment is unsupported.
  10853. void operator=(const CartesianProductGenerator6& other);
  10854. const ParamGenerator<T1> g1_;
  10855. const ParamGenerator<T2> g2_;
  10856. const ParamGenerator<T3> g3_;
  10857. const ParamGenerator<T4> g4_;
  10858. const ParamGenerator<T5> g5_;
  10859. const ParamGenerator<T6> g6_;
  10860. }; // class CartesianProductGenerator6
  10861. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  10862. typename T6, typename T7>
  10863. class CartesianProductGenerator7
  10864. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6,
  10865. T7> > {
  10866. public:
  10867. typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
  10868. CartesianProductGenerator7(const ParamGenerator<T1>& g1,
  10869. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  10870. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
  10871. const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)
  10872. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
  10873. ~CartesianProductGenerator7() override {}
  10874. ParamIteratorInterface<ParamType>* Begin() const override {
  10875. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  10876. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
  10877. g7_.begin());
  10878. }
  10879. ParamIteratorInterface<ParamType>* End() const override {
  10880. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  10881. g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());
  10882. }
  10883. private:
  10884. class Iterator : public ParamIteratorInterface<ParamType> {
  10885. public:
  10886. Iterator(const ParamGeneratorInterface<ParamType>* base,
  10887. const ParamGenerator<T1>& g1,
  10888. const typename ParamGenerator<T1>::iterator& current1,
  10889. const ParamGenerator<T2>& g2,
  10890. const typename ParamGenerator<T2>::iterator& current2,
  10891. const ParamGenerator<T3>& g3,
  10892. const typename ParamGenerator<T3>::iterator& current3,
  10893. const ParamGenerator<T4>& g4,
  10894. const typename ParamGenerator<T4>::iterator& current4,
  10895. const ParamGenerator<T5>& g5,
  10896. const typename ParamGenerator<T5>::iterator& current5,
  10897. const ParamGenerator<T6>& g6,
  10898. const typename ParamGenerator<T6>::iterator& current6,
  10899. const ParamGenerator<T7>& g7,
  10900. const typename ParamGenerator<T7>::iterator& current7)
  10901. : base_(base),
  10902. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  10903. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  10904. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  10905. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  10906. begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
  10907. begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
  10908. begin7_(g7.begin()), end7_(g7.end()), current7_(current7) {
  10909. ComputeCurrentValue();
  10910. }
  10911. ~Iterator() override {}
  10912. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  10913. return base_;
  10914. }
  10915. // Advance should not be called on beyond-of-range iterators
  10916. // so no component iterators must be beyond end of range, either.
  10917. void Advance() override {
  10918. assert(!AtEnd());
  10919. ++current7_;
  10920. if (current7_ == end7_) {
  10921. current7_ = begin7_;
  10922. ++current6_;
  10923. }
  10924. if (current6_ == end6_) {
  10925. current6_ = begin6_;
  10926. ++current5_;
  10927. }
  10928. if (current5_ == end5_) {
  10929. current5_ = begin5_;
  10930. ++current4_;
  10931. }
  10932. if (current4_ == end4_) {
  10933. current4_ = begin4_;
  10934. ++current3_;
  10935. }
  10936. if (current3_ == end3_) {
  10937. current3_ = begin3_;
  10938. ++current2_;
  10939. }
  10940. if (current2_ == end2_) {
  10941. current2_ = begin2_;
  10942. ++current1_;
  10943. }
  10944. ComputeCurrentValue();
  10945. }
  10946. ParamIteratorInterface<ParamType>* Clone() const override {
  10947. return new Iterator(*this);
  10948. }
  10949. const ParamType* Current() const override { return current_value_.get(); }
  10950. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  10951. // Having the same base generator guarantees that the other
  10952. // iterator is of the same type and we can downcast.
  10953. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  10954. << "The program attempted to compare iterators "
  10955. << "from different generators." << std::endl;
  10956. const Iterator* typed_other =
  10957. CheckedDowncastToActualType<const Iterator>(&other);
  10958. // We must report iterators equal if they both point beyond their
  10959. // respective ranges. That can happen in a variety of fashions,
  10960. // so we have to consult AtEnd().
  10961. return (AtEnd() && typed_other->AtEnd()) ||
  10962. (
  10963. current1_ == typed_other->current1_ &&
  10964. current2_ == typed_other->current2_ &&
  10965. current3_ == typed_other->current3_ &&
  10966. current4_ == typed_other->current4_ &&
  10967. current5_ == typed_other->current5_ &&
  10968. current6_ == typed_other->current6_ &&
  10969. current7_ == typed_other->current7_);
  10970. }
  10971. private:
  10972. Iterator(const Iterator& other)
  10973. : base_(other.base_),
  10974. begin1_(other.begin1_),
  10975. end1_(other.end1_),
  10976. current1_(other.current1_),
  10977. begin2_(other.begin2_),
  10978. end2_(other.end2_),
  10979. current2_(other.current2_),
  10980. begin3_(other.begin3_),
  10981. end3_(other.end3_),
  10982. current3_(other.current3_),
  10983. begin4_(other.begin4_),
  10984. end4_(other.end4_),
  10985. current4_(other.current4_),
  10986. begin5_(other.begin5_),
  10987. end5_(other.end5_),
  10988. current5_(other.current5_),
  10989. begin6_(other.begin6_),
  10990. end6_(other.end6_),
  10991. current6_(other.current6_),
  10992. begin7_(other.begin7_),
  10993. end7_(other.end7_),
  10994. current7_(other.current7_) {
  10995. ComputeCurrentValue();
  10996. }
  10997. void ComputeCurrentValue() {
  10998. if (!AtEnd())
  10999. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  11000. *current4_, *current5_, *current6_, *current7_));
  11001. }
  11002. bool AtEnd() const {
  11003. // We must report iterator past the end of the range when either of the
  11004. // component iterators has reached the end of its range.
  11005. return
  11006. current1_ == end1_ ||
  11007. current2_ == end2_ ||
  11008. current3_ == end3_ ||
  11009. current4_ == end4_ ||
  11010. current5_ == end5_ ||
  11011. current6_ == end6_ ||
  11012. current7_ == end7_;
  11013. }
  11014. // No implementation - assignment is unsupported.
  11015. void operator=(const Iterator& other);
  11016. const ParamGeneratorInterface<ParamType>* const base_;
  11017. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  11018. // current[i]_ is the actual traversing iterator.
  11019. const typename ParamGenerator<T1>::iterator begin1_;
  11020. const typename ParamGenerator<T1>::iterator end1_;
  11021. typename ParamGenerator<T1>::iterator current1_;
  11022. const typename ParamGenerator<T2>::iterator begin2_;
  11023. const typename ParamGenerator<T2>::iterator end2_;
  11024. typename ParamGenerator<T2>::iterator current2_;
  11025. const typename ParamGenerator<T3>::iterator begin3_;
  11026. const typename ParamGenerator<T3>::iterator end3_;
  11027. typename ParamGenerator<T3>::iterator current3_;
  11028. const typename ParamGenerator<T4>::iterator begin4_;
  11029. const typename ParamGenerator<T4>::iterator end4_;
  11030. typename ParamGenerator<T4>::iterator current4_;
  11031. const typename ParamGenerator<T5>::iterator begin5_;
  11032. const typename ParamGenerator<T5>::iterator end5_;
  11033. typename ParamGenerator<T5>::iterator current5_;
  11034. const typename ParamGenerator<T6>::iterator begin6_;
  11035. const typename ParamGenerator<T6>::iterator end6_;
  11036. typename ParamGenerator<T6>::iterator current6_;
  11037. const typename ParamGenerator<T7>::iterator begin7_;
  11038. const typename ParamGenerator<T7>::iterator end7_;
  11039. typename ParamGenerator<T7>::iterator current7_;
  11040. std::shared_ptr<ParamType> current_value_;
  11041. }; // class CartesianProductGenerator7::Iterator
  11042. // No implementation - assignment is unsupported.
  11043. void operator=(const CartesianProductGenerator7& other);
  11044. const ParamGenerator<T1> g1_;
  11045. const ParamGenerator<T2> g2_;
  11046. const ParamGenerator<T3> g3_;
  11047. const ParamGenerator<T4> g4_;
  11048. const ParamGenerator<T5> g5_;
  11049. const ParamGenerator<T6> g6_;
  11050. const ParamGenerator<T7> g7_;
  11051. }; // class CartesianProductGenerator7
  11052. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11053. typename T6, typename T7, typename T8>
  11054. class CartesianProductGenerator8
  11055. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
  11056. T8> > {
  11057. public:
  11058. typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
  11059. CartesianProductGenerator8(const ParamGenerator<T1>& g1,
  11060. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  11061. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
  11062. const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
  11063. const ParamGenerator<T8>& g8)
  11064. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
  11065. g8_(g8) {}
  11066. ~CartesianProductGenerator8() override {}
  11067. ParamIteratorInterface<ParamType>* Begin() const override {
  11068. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  11069. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
  11070. g7_.begin(), g8_, g8_.begin());
  11071. }
  11072. ParamIteratorInterface<ParamType>* End() const override {
  11073. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  11074. g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
  11075. g8_.end());
  11076. }
  11077. private:
  11078. class Iterator : public ParamIteratorInterface<ParamType> {
  11079. public:
  11080. Iterator(const ParamGeneratorInterface<ParamType>* base,
  11081. const ParamGenerator<T1>& g1,
  11082. const typename ParamGenerator<T1>::iterator& current1,
  11083. const ParamGenerator<T2>& g2,
  11084. const typename ParamGenerator<T2>::iterator& current2,
  11085. const ParamGenerator<T3>& g3,
  11086. const typename ParamGenerator<T3>::iterator& current3,
  11087. const ParamGenerator<T4>& g4,
  11088. const typename ParamGenerator<T4>::iterator& current4,
  11089. const ParamGenerator<T5>& g5,
  11090. const typename ParamGenerator<T5>::iterator& current5,
  11091. const ParamGenerator<T6>& g6,
  11092. const typename ParamGenerator<T6>::iterator& current6,
  11093. const ParamGenerator<T7>& g7,
  11094. const typename ParamGenerator<T7>::iterator& current7,
  11095. const ParamGenerator<T8>& g8,
  11096. const typename ParamGenerator<T8>::iterator& current8)
  11097. : base_(base),
  11098. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  11099. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  11100. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  11101. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  11102. begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
  11103. begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
  11104. begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
  11105. begin8_(g8.begin()), end8_(g8.end()), current8_(current8) {
  11106. ComputeCurrentValue();
  11107. }
  11108. ~Iterator() override {}
  11109. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  11110. return base_;
  11111. }
  11112. // Advance should not be called on beyond-of-range iterators
  11113. // so no component iterators must be beyond end of range, either.
  11114. void Advance() override {
  11115. assert(!AtEnd());
  11116. ++current8_;
  11117. if (current8_ == end8_) {
  11118. current8_ = begin8_;
  11119. ++current7_;
  11120. }
  11121. if (current7_ == end7_) {
  11122. current7_ = begin7_;
  11123. ++current6_;
  11124. }
  11125. if (current6_ == end6_) {
  11126. current6_ = begin6_;
  11127. ++current5_;
  11128. }
  11129. if (current5_ == end5_) {
  11130. current5_ = begin5_;
  11131. ++current4_;
  11132. }
  11133. if (current4_ == end4_) {
  11134. current4_ = begin4_;
  11135. ++current3_;
  11136. }
  11137. if (current3_ == end3_) {
  11138. current3_ = begin3_;
  11139. ++current2_;
  11140. }
  11141. if (current2_ == end2_) {
  11142. current2_ = begin2_;
  11143. ++current1_;
  11144. }
  11145. ComputeCurrentValue();
  11146. }
  11147. ParamIteratorInterface<ParamType>* Clone() const override {
  11148. return new Iterator(*this);
  11149. }
  11150. const ParamType* Current() const override { return current_value_.get(); }
  11151. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  11152. // Having the same base generator guarantees that the other
  11153. // iterator is of the same type and we can downcast.
  11154. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  11155. << "The program attempted to compare iterators "
  11156. << "from different generators." << std::endl;
  11157. const Iterator* typed_other =
  11158. CheckedDowncastToActualType<const Iterator>(&other);
  11159. // We must report iterators equal if they both point beyond their
  11160. // respective ranges. That can happen in a variety of fashions,
  11161. // so we have to consult AtEnd().
  11162. return (AtEnd() && typed_other->AtEnd()) ||
  11163. (
  11164. current1_ == typed_other->current1_ &&
  11165. current2_ == typed_other->current2_ &&
  11166. current3_ == typed_other->current3_ &&
  11167. current4_ == typed_other->current4_ &&
  11168. current5_ == typed_other->current5_ &&
  11169. current6_ == typed_other->current6_ &&
  11170. current7_ == typed_other->current7_ &&
  11171. current8_ == typed_other->current8_);
  11172. }
  11173. private:
  11174. Iterator(const Iterator& other)
  11175. : base_(other.base_),
  11176. begin1_(other.begin1_),
  11177. end1_(other.end1_),
  11178. current1_(other.current1_),
  11179. begin2_(other.begin2_),
  11180. end2_(other.end2_),
  11181. current2_(other.current2_),
  11182. begin3_(other.begin3_),
  11183. end3_(other.end3_),
  11184. current3_(other.current3_),
  11185. begin4_(other.begin4_),
  11186. end4_(other.end4_),
  11187. current4_(other.current4_),
  11188. begin5_(other.begin5_),
  11189. end5_(other.end5_),
  11190. current5_(other.current5_),
  11191. begin6_(other.begin6_),
  11192. end6_(other.end6_),
  11193. current6_(other.current6_),
  11194. begin7_(other.begin7_),
  11195. end7_(other.end7_),
  11196. current7_(other.current7_),
  11197. begin8_(other.begin8_),
  11198. end8_(other.end8_),
  11199. current8_(other.current8_) {
  11200. ComputeCurrentValue();
  11201. }
  11202. void ComputeCurrentValue() {
  11203. if (!AtEnd())
  11204. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  11205. *current4_, *current5_, *current6_, *current7_, *current8_));
  11206. }
  11207. bool AtEnd() const {
  11208. // We must report iterator past the end of the range when either of the
  11209. // component iterators has reached the end of its range.
  11210. return
  11211. current1_ == end1_ ||
  11212. current2_ == end2_ ||
  11213. current3_ == end3_ ||
  11214. current4_ == end4_ ||
  11215. current5_ == end5_ ||
  11216. current6_ == end6_ ||
  11217. current7_ == end7_ ||
  11218. current8_ == end8_;
  11219. }
  11220. // No implementation - assignment is unsupported.
  11221. void operator=(const Iterator& other);
  11222. const ParamGeneratorInterface<ParamType>* const base_;
  11223. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  11224. // current[i]_ is the actual traversing iterator.
  11225. const typename ParamGenerator<T1>::iterator begin1_;
  11226. const typename ParamGenerator<T1>::iterator end1_;
  11227. typename ParamGenerator<T1>::iterator current1_;
  11228. const typename ParamGenerator<T2>::iterator begin2_;
  11229. const typename ParamGenerator<T2>::iterator end2_;
  11230. typename ParamGenerator<T2>::iterator current2_;
  11231. const typename ParamGenerator<T3>::iterator begin3_;
  11232. const typename ParamGenerator<T3>::iterator end3_;
  11233. typename ParamGenerator<T3>::iterator current3_;
  11234. const typename ParamGenerator<T4>::iterator begin4_;
  11235. const typename ParamGenerator<T4>::iterator end4_;
  11236. typename ParamGenerator<T4>::iterator current4_;
  11237. const typename ParamGenerator<T5>::iterator begin5_;
  11238. const typename ParamGenerator<T5>::iterator end5_;
  11239. typename ParamGenerator<T5>::iterator current5_;
  11240. const typename ParamGenerator<T6>::iterator begin6_;
  11241. const typename ParamGenerator<T6>::iterator end6_;
  11242. typename ParamGenerator<T6>::iterator current6_;
  11243. const typename ParamGenerator<T7>::iterator begin7_;
  11244. const typename ParamGenerator<T7>::iterator end7_;
  11245. typename ParamGenerator<T7>::iterator current7_;
  11246. const typename ParamGenerator<T8>::iterator begin8_;
  11247. const typename ParamGenerator<T8>::iterator end8_;
  11248. typename ParamGenerator<T8>::iterator current8_;
  11249. std::shared_ptr<ParamType> current_value_;
  11250. }; // class CartesianProductGenerator8::Iterator
  11251. // No implementation - assignment is unsupported.
  11252. void operator=(const CartesianProductGenerator8& other);
  11253. const ParamGenerator<T1> g1_;
  11254. const ParamGenerator<T2> g2_;
  11255. const ParamGenerator<T3> g3_;
  11256. const ParamGenerator<T4> g4_;
  11257. const ParamGenerator<T5> g5_;
  11258. const ParamGenerator<T6> g6_;
  11259. const ParamGenerator<T7> g7_;
  11260. const ParamGenerator<T8> g8_;
  11261. }; // class CartesianProductGenerator8
  11262. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11263. typename T6, typename T7, typename T8, typename T9>
  11264. class CartesianProductGenerator9
  11265. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
  11266. T8, T9> > {
  11267. public:
  11268. typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
  11269. CartesianProductGenerator9(const ParamGenerator<T1>& g1,
  11270. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  11271. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
  11272. const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
  11273. const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)
  11274. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
  11275. g9_(g9) {}
  11276. ~CartesianProductGenerator9() override {}
  11277. ParamIteratorInterface<ParamType>* Begin() const override {
  11278. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  11279. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
  11280. g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());
  11281. }
  11282. ParamIteratorInterface<ParamType>* End() const override {
  11283. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  11284. g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
  11285. g8_.end(), g9_, g9_.end());
  11286. }
  11287. private:
  11288. class Iterator : public ParamIteratorInterface<ParamType> {
  11289. public:
  11290. Iterator(const ParamGeneratorInterface<ParamType>* base,
  11291. const ParamGenerator<T1>& g1,
  11292. const typename ParamGenerator<T1>::iterator& current1,
  11293. const ParamGenerator<T2>& g2,
  11294. const typename ParamGenerator<T2>::iterator& current2,
  11295. const ParamGenerator<T3>& g3,
  11296. const typename ParamGenerator<T3>::iterator& current3,
  11297. const ParamGenerator<T4>& g4,
  11298. const typename ParamGenerator<T4>::iterator& current4,
  11299. const ParamGenerator<T5>& g5,
  11300. const typename ParamGenerator<T5>::iterator& current5,
  11301. const ParamGenerator<T6>& g6,
  11302. const typename ParamGenerator<T6>::iterator& current6,
  11303. const ParamGenerator<T7>& g7,
  11304. const typename ParamGenerator<T7>::iterator& current7,
  11305. const ParamGenerator<T8>& g8,
  11306. const typename ParamGenerator<T8>::iterator& current8,
  11307. const ParamGenerator<T9>& g9,
  11308. const typename ParamGenerator<T9>::iterator& current9)
  11309. : base_(base),
  11310. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  11311. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  11312. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  11313. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  11314. begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
  11315. begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
  11316. begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
  11317. begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
  11318. begin9_(g9.begin()), end9_(g9.end()), current9_(current9) {
  11319. ComputeCurrentValue();
  11320. }
  11321. ~Iterator() override {}
  11322. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  11323. return base_;
  11324. }
  11325. // Advance should not be called on beyond-of-range iterators
  11326. // so no component iterators must be beyond end of range, either.
  11327. void Advance() override {
  11328. assert(!AtEnd());
  11329. ++current9_;
  11330. if (current9_ == end9_) {
  11331. current9_ = begin9_;
  11332. ++current8_;
  11333. }
  11334. if (current8_ == end8_) {
  11335. current8_ = begin8_;
  11336. ++current7_;
  11337. }
  11338. if (current7_ == end7_) {
  11339. current7_ = begin7_;
  11340. ++current6_;
  11341. }
  11342. if (current6_ == end6_) {
  11343. current6_ = begin6_;
  11344. ++current5_;
  11345. }
  11346. if (current5_ == end5_) {
  11347. current5_ = begin5_;
  11348. ++current4_;
  11349. }
  11350. if (current4_ == end4_) {
  11351. current4_ = begin4_;
  11352. ++current3_;
  11353. }
  11354. if (current3_ == end3_) {
  11355. current3_ = begin3_;
  11356. ++current2_;
  11357. }
  11358. if (current2_ == end2_) {
  11359. current2_ = begin2_;
  11360. ++current1_;
  11361. }
  11362. ComputeCurrentValue();
  11363. }
  11364. ParamIteratorInterface<ParamType>* Clone() const override {
  11365. return new Iterator(*this);
  11366. }
  11367. const ParamType* Current() const override { return current_value_.get(); }
  11368. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  11369. // Having the same base generator guarantees that the other
  11370. // iterator is of the same type and we can downcast.
  11371. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  11372. << "The program attempted to compare iterators "
  11373. << "from different generators." << std::endl;
  11374. const Iterator* typed_other =
  11375. CheckedDowncastToActualType<const Iterator>(&other);
  11376. // We must report iterators equal if they both point beyond their
  11377. // respective ranges. That can happen in a variety of fashions,
  11378. // so we have to consult AtEnd().
  11379. return (AtEnd() && typed_other->AtEnd()) ||
  11380. (
  11381. current1_ == typed_other->current1_ &&
  11382. current2_ == typed_other->current2_ &&
  11383. current3_ == typed_other->current3_ &&
  11384. current4_ == typed_other->current4_ &&
  11385. current5_ == typed_other->current5_ &&
  11386. current6_ == typed_other->current6_ &&
  11387. current7_ == typed_other->current7_ &&
  11388. current8_ == typed_other->current8_ &&
  11389. current9_ == typed_other->current9_);
  11390. }
  11391. private:
  11392. Iterator(const Iterator& other)
  11393. : base_(other.base_),
  11394. begin1_(other.begin1_),
  11395. end1_(other.end1_),
  11396. current1_(other.current1_),
  11397. begin2_(other.begin2_),
  11398. end2_(other.end2_),
  11399. current2_(other.current2_),
  11400. begin3_(other.begin3_),
  11401. end3_(other.end3_),
  11402. current3_(other.current3_),
  11403. begin4_(other.begin4_),
  11404. end4_(other.end4_),
  11405. current4_(other.current4_),
  11406. begin5_(other.begin5_),
  11407. end5_(other.end5_),
  11408. current5_(other.current5_),
  11409. begin6_(other.begin6_),
  11410. end6_(other.end6_),
  11411. current6_(other.current6_),
  11412. begin7_(other.begin7_),
  11413. end7_(other.end7_),
  11414. current7_(other.current7_),
  11415. begin8_(other.begin8_),
  11416. end8_(other.end8_),
  11417. current8_(other.current8_),
  11418. begin9_(other.begin9_),
  11419. end9_(other.end9_),
  11420. current9_(other.current9_) {
  11421. ComputeCurrentValue();
  11422. }
  11423. void ComputeCurrentValue() {
  11424. if (!AtEnd())
  11425. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  11426. *current4_, *current5_, *current6_, *current7_, *current8_,
  11427. *current9_));
  11428. }
  11429. bool AtEnd() const {
  11430. // We must report iterator past the end of the range when either of the
  11431. // component iterators has reached the end of its range.
  11432. return
  11433. current1_ == end1_ ||
  11434. current2_ == end2_ ||
  11435. current3_ == end3_ ||
  11436. current4_ == end4_ ||
  11437. current5_ == end5_ ||
  11438. current6_ == end6_ ||
  11439. current7_ == end7_ ||
  11440. current8_ == end8_ ||
  11441. current9_ == end9_;
  11442. }
  11443. // No implementation - assignment is unsupported.
  11444. void operator=(const Iterator& other);
  11445. const ParamGeneratorInterface<ParamType>* const base_;
  11446. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  11447. // current[i]_ is the actual traversing iterator.
  11448. const typename ParamGenerator<T1>::iterator begin1_;
  11449. const typename ParamGenerator<T1>::iterator end1_;
  11450. typename ParamGenerator<T1>::iterator current1_;
  11451. const typename ParamGenerator<T2>::iterator begin2_;
  11452. const typename ParamGenerator<T2>::iterator end2_;
  11453. typename ParamGenerator<T2>::iterator current2_;
  11454. const typename ParamGenerator<T3>::iterator begin3_;
  11455. const typename ParamGenerator<T3>::iterator end3_;
  11456. typename ParamGenerator<T3>::iterator current3_;
  11457. const typename ParamGenerator<T4>::iterator begin4_;
  11458. const typename ParamGenerator<T4>::iterator end4_;
  11459. typename ParamGenerator<T4>::iterator current4_;
  11460. const typename ParamGenerator<T5>::iterator begin5_;
  11461. const typename ParamGenerator<T5>::iterator end5_;
  11462. typename ParamGenerator<T5>::iterator current5_;
  11463. const typename ParamGenerator<T6>::iterator begin6_;
  11464. const typename ParamGenerator<T6>::iterator end6_;
  11465. typename ParamGenerator<T6>::iterator current6_;
  11466. const typename ParamGenerator<T7>::iterator begin7_;
  11467. const typename ParamGenerator<T7>::iterator end7_;
  11468. typename ParamGenerator<T7>::iterator current7_;
  11469. const typename ParamGenerator<T8>::iterator begin8_;
  11470. const typename ParamGenerator<T8>::iterator end8_;
  11471. typename ParamGenerator<T8>::iterator current8_;
  11472. const typename ParamGenerator<T9>::iterator begin9_;
  11473. const typename ParamGenerator<T9>::iterator end9_;
  11474. typename ParamGenerator<T9>::iterator current9_;
  11475. std::shared_ptr<ParamType> current_value_;
  11476. }; // class CartesianProductGenerator9::Iterator
  11477. // No implementation - assignment is unsupported.
  11478. void operator=(const CartesianProductGenerator9& other);
  11479. const ParamGenerator<T1> g1_;
  11480. const ParamGenerator<T2> g2_;
  11481. const ParamGenerator<T3> g3_;
  11482. const ParamGenerator<T4> g4_;
  11483. const ParamGenerator<T5> g5_;
  11484. const ParamGenerator<T6> g6_;
  11485. const ParamGenerator<T7> g7_;
  11486. const ParamGenerator<T8> g8_;
  11487. const ParamGenerator<T9> g9_;
  11488. }; // class CartesianProductGenerator9
  11489. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11490. typename T6, typename T7, typename T8, typename T9, typename T10>
  11491. class CartesianProductGenerator10
  11492. : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
  11493. T8, T9, T10> > {
  11494. public:
  11495. typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
  11496. CartesianProductGenerator10(const ParamGenerator<T1>& g1,
  11497. const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
  11498. const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,
  11499. const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,
  11500. const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,
  11501. const ParamGenerator<T10>& g10)
  11502. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
  11503. g9_(g9), g10_(g10) {}
  11504. ~CartesianProductGenerator10() override {}
  11505. ParamIteratorInterface<ParamType>* Begin() const override {
  11506. return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,
  11507. g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,
  11508. g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());
  11509. }
  11510. ParamIteratorInterface<ParamType>* End() const override {
  11511. return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),
  11512. g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,
  11513. g8_.end(), g9_, g9_.end(), g10_, g10_.end());
  11514. }
  11515. private:
  11516. class Iterator : public ParamIteratorInterface<ParamType> {
  11517. public:
  11518. Iterator(const ParamGeneratorInterface<ParamType>* base,
  11519. const ParamGenerator<T1>& g1,
  11520. const typename ParamGenerator<T1>::iterator& current1,
  11521. const ParamGenerator<T2>& g2,
  11522. const typename ParamGenerator<T2>::iterator& current2,
  11523. const ParamGenerator<T3>& g3,
  11524. const typename ParamGenerator<T3>::iterator& current3,
  11525. const ParamGenerator<T4>& g4,
  11526. const typename ParamGenerator<T4>::iterator& current4,
  11527. const ParamGenerator<T5>& g5,
  11528. const typename ParamGenerator<T5>::iterator& current5,
  11529. const ParamGenerator<T6>& g6,
  11530. const typename ParamGenerator<T6>::iterator& current6,
  11531. const ParamGenerator<T7>& g7,
  11532. const typename ParamGenerator<T7>::iterator& current7,
  11533. const ParamGenerator<T8>& g8,
  11534. const typename ParamGenerator<T8>::iterator& current8,
  11535. const ParamGenerator<T9>& g9,
  11536. const typename ParamGenerator<T9>::iterator& current9,
  11537. const ParamGenerator<T10>& g10,
  11538. const typename ParamGenerator<T10>::iterator& current10)
  11539. : base_(base),
  11540. begin1_(g1.begin()), end1_(g1.end()), current1_(current1),
  11541. begin2_(g2.begin()), end2_(g2.end()), current2_(current2),
  11542. begin3_(g3.begin()), end3_(g3.end()), current3_(current3),
  11543. begin4_(g4.begin()), end4_(g4.end()), current4_(current4),
  11544. begin5_(g5.begin()), end5_(g5.end()), current5_(current5),
  11545. begin6_(g6.begin()), end6_(g6.end()), current6_(current6),
  11546. begin7_(g7.begin()), end7_(g7.end()), current7_(current7),
  11547. begin8_(g8.begin()), end8_(g8.end()), current8_(current8),
  11548. begin9_(g9.begin()), end9_(g9.end()), current9_(current9),
  11549. begin10_(g10.begin()), end10_(g10.end()), current10_(current10) {
  11550. ComputeCurrentValue();
  11551. }
  11552. ~Iterator() override {}
  11553. const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
  11554. return base_;
  11555. }
  11556. // Advance should not be called on beyond-of-range iterators
  11557. // so no component iterators must be beyond end of range, either.
  11558. void Advance() override {
  11559. assert(!AtEnd());
  11560. ++current10_;
  11561. if (current10_ == end10_) {
  11562. current10_ = begin10_;
  11563. ++current9_;
  11564. }
  11565. if (current9_ == end9_) {
  11566. current9_ = begin9_;
  11567. ++current8_;
  11568. }
  11569. if (current8_ == end8_) {
  11570. current8_ = begin8_;
  11571. ++current7_;
  11572. }
  11573. if (current7_ == end7_) {
  11574. current7_ = begin7_;
  11575. ++current6_;
  11576. }
  11577. if (current6_ == end6_) {
  11578. current6_ = begin6_;
  11579. ++current5_;
  11580. }
  11581. if (current5_ == end5_) {
  11582. current5_ = begin5_;
  11583. ++current4_;
  11584. }
  11585. if (current4_ == end4_) {
  11586. current4_ = begin4_;
  11587. ++current3_;
  11588. }
  11589. if (current3_ == end3_) {
  11590. current3_ = begin3_;
  11591. ++current2_;
  11592. }
  11593. if (current2_ == end2_) {
  11594. current2_ = begin2_;
  11595. ++current1_;
  11596. }
  11597. ComputeCurrentValue();
  11598. }
  11599. ParamIteratorInterface<ParamType>* Clone() const override {
  11600. return new Iterator(*this);
  11601. }
  11602. const ParamType* Current() const override { return current_value_.get(); }
  11603. bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
  11604. // Having the same base generator guarantees that the other
  11605. // iterator is of the same type and we can downcast.
  11606. GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
  11607. << "The program attempted to compare iterators "
  11608. << "from different generators." << std::endl;
  11609. const Iterator* typed_other =
  11610. CheckedDowncastToActualType<const Iterator>(&other);
  11611. // We must report iterators equal if they both point beyond their
  11612. // respective ranges. That can happen in a variety of fashions,
  11613. // so we have to consult AtEnd().
  11614. return (AtEnd() && typed_other->AtEnd()) ||
  11615. (
  11616. current1_ == typed_other->current1_ &&
  11617. current2_ == typed_other->current2_ &&
  11618. current3_ == typed_other->current3_ &&
  11619. current4_ == typed_other->current4_ &&
  11620. current5_ == typed_other->current5_ &&
  11621. current6_ == typed_other->current6_ &&
  11622. current7_ == typed_other->current7_ &&
  11623. current8_ == typed_other->current8_ &&
  11624. current9_ == typed_other->current9_ &&
  11625. current10_ == typed_other->current10_);
  11626. }
  11627. private:
  11628. Iterator(const Iterator& other)
  11629. : base_(other.base_),
  11630. begin1_(other.begin1_),
  11631. end1_(other.end1_),
  11632. current1_(other.current1_),
  11633. begin2_(other.begin2_),
  11634. end2_(other.end2_),
  11635. current2_(other.current2_),
  11636. begin3_(other.begin3_),
  11637. end3_(other.end3_),
  11638. current3_(other.current3_),
  11639. begin4_(other.begin4_),
  11640. end4_(other.end4_),
  11641. current4_(other.current4_),
  11642. begin5_(other.begin5_),
  11643. end5_(other.end5_),
  11644. current5_(other.current5_),
  11645. begin6_(other.begin6_),
  11646. end6_(other.end6_),
  11647. current6_(other.current6_),
  11648. begin7_(other.begin7_),
  11649. end7_(other.end7_),
  11650. current7_(other.current7_),
  11651. begin8_(other.begin8_),
  11652. end8_(other.end8_),
  11653. current8_(other.current8_),
  11654. begin9_(other.begin9_),
  11655. end9_(other.end9_),
  11656. current9_(other.current9_),
  11657. begin10_(other.begin10_),
  11658. end10_(other.end10_),
  11659. current10_(other.current10_) {
  11660. ComputeCurrentValue();
  11661. }
  11662. void ComputeCurrentValue() {
  11663. if (!AtEnd())
  11664. current_value_.reset(new ParamType(*current1_, *current2_, *current3_,
  11665. *current4_, *current5_, *current6_, *current7_, *current8_,
  11666. *current9_, *current10_));
  11667. }
  11668. bool AtEnd() const {
  11669. // We must report iterator past the end of the range when either of the
  11670. // component iterators has reached the end of its range.
  11671. return
  11672. current1_ == end1_ ||
  11673. current2_ == end2_ ||
  11674. current3_ == end3_ ||
  11675. current4_ == end4_ ||
  11676. current5_ == end5_ ||
  11677. current6_ == end6_ ||
  11678. current7_ == end7_ ||
  11679. current8_ == end8_ ||
  11680. current9_ == end9_ ||
  11681. current10_ == end10_;
  11682. }
  11683. // No implementation - assignment is unsupported.
  11684. void operator=(const Iterator& other);
  11685. const ParamGeneratorInterface<ParamType>* const base_;
  11686. // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.
  11687. // current[i]_ is the actual traversing iterator.
  11688. const typename ParamGenerator<T1>::iterator begin1_;
  11689. const typename ParamGenerator<T1>::iterator end1_;
  11690. typename ParamGenerator<T1>::iterator current1_;
  11691. const typename ParamGenerator<T2>::iterator begin2_;
  11692. const typename ParamGenerator<T2>::iterator end2_;
  11693. typename ParamGenerator<T2>::iterator current2_;
  11694. const typename ParamGenerator<T3>::iterator begin3_;
  11695. const typename ParamGenerator<T3>::iterator end3_;
  11696. typename ParamGenerator<T3>::iterator current3_;
  11697. const typename ParamGenerator<T4>::iterator begin4_;
  11698. const typename ParamGenerator<T4>::iterator end4_;
  11699. typename ParamGenerator<T4>::iterator current4_;
  11700. const typename ParamGenerator<T5>::iterator begin5_;
  11701. const typename ParamGenerator<T5>::iterator end5_;
  11702. typename ParamGenerator<T5>::iterator current5_;
  11703. const typename ParamGenerator<T6>::iterator begin6_;
  11704. const typename ParamGenerator<T6>::iterator end6_;
  11705. typename ParamGenerator<T6>::iterator current6_;
  11706. const typename ParamGenerator<T7>::iterator begin7_;
  11707. const typename ParamGenerator<T7>::iterator end7_;
  11708. typename ParamGenerator<T7>::iterator current7_;
  11709. const typename ParamGenerator<T8>::iterator begin8_;
  11710. const typename ParamGenerator<T8>::iterator end8_;
  11711. typename ParamGenerator<T8>::iterator current8_;
  11712. const typename ParamGenerator<T9>::iterator begin9_;
  11713. const typename ParamGenerator<T9>::iterator end9_;
  11714. typename ParamGenerator<T9>::iterator current9_;
  11715. const typename ParamGenerator<T10>::iterator begin10_;
  11716. const typename ParamGenerator<T10>::iterator end10_;
  11717. typename ParamGenerator<T10>::iterator current10_;
  11718. std::shared_ptr<ParamType> current_value_;
  11719. }; // class CartesianProductGenerator10::Iterator
  11720. // No implementation - assignment is unsupported.
  11721. void operator=(const CartesianProductGenerator10& other);
  11722. const ParamGenerator<T1> g1_;
  11723. const ParamGenerator<T2> g2_;
  11724. const ParamGenerator<T3> g3_;
  11725. const ParamGenerator<T4> g4_;
  11726. const ParamGenerator<T5> g5_;
  11727. const ParamGenerator<T6> g6_;
  11728. const ParamGenerator<T7> g7_;
  11729. const ParamGenerator<T8> g8_;
  11730. const ParamGenerator<T9> g9_;
  11731. const ParamGenerator<T10> g10_;
  11732. }; // class CartesianProductGenerator10
  11733. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  11734. //
  11735. // Helper classes providing Combine() with polymorphic features. They allow
  11736. // casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is
  11737. // convertible to U.
  11738. //
  11739. template <class Generator1, class Generator2>
  11740. class CartesianProductHolder2 {
  11741. public:
  11742. CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
  11743. : g1_(g1), g2_(g2) {}
  11744. template <typename T1, typename T2>
  11745. operator ParamGenerator< ::std::tuple<T1, T2> >() const {
  11746. return ParamGenerator< ::std::tuple<T1, T2> >(
  11747. new CartesianProductGenerator2<T1, T2>(
  11748. static_cast<ParamGenerator<T1> >(g1_),
  11749. static_cast<ParamGenerator<T2> >(g2_)));
  11750. }
  11751. private:
  11752. // No implementation - assignment is unsupported.
  11753. void operator=(const CartesianProductHolder2& other);
  11754. const Generator1 g1_;
  11755. const Generator2 g2_;
  11756. }; // class CartesianProductHolder2
  11757. template <class Generator1, class Generator2, class Generator3>
  11758. class CartesianProductHolder3 {
  11759. public:
  11760. CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
  11761. const Generator3& g3)
  11762. : g1_(g1), g2_(g2), g3_(g3) {}
  11763. template <typename T1, typename T2, typename T3>
  11764. operator ParamGenerator< ::std::tuple<T1, T2, T3> >() const {
  11765. return ParamGenerator< ::std::tuple<T1, T2, T3> >(
  11766. new CartesianProductGenerator3<T1, T2, T3>(
  11767. static_cast<ParamGenerator<T1> >(g1_),
  11768. static_cast<ParamGenerator<T2> >(g2_),
  11769. static_cast<ParamGenerator<T3> >(g3_)));
  11770. }
  11771. private:
  11772. // No implementation - assignment is unsupported.
  11773. void operator=(const CartesianProductHolder3& other);
  11774. const Generator1 g1_;
  11775. const Generator2 g2_;
  11776. const Generator3 g3_;
  11777. }; // class CartesianProductHolder3
  11778. template <class Generator1, class Generator2, class Generator3,
  11779. class Generator4>
  11780. class CartesianProductHolder4 {
  11781. public:
  11782. CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
  11783. const Generator3& g3, const Generator4& g4)
  11784. : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
  11785. template <typename T1, typename T2, typename T3, typename T4>
  11786. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4> >() const {
  11787. return ParamGenerator< ::std::tuple<T1, T2, T3, T4> >(
  11788. new CartesianProductGenerator4<T1, T2, T3, T4>(
  11789. static_cast<ParamGenerator<T1> >(g1_),
  11790. static_cast<ParamGenerator<T2> >(g2_),
  11791. static_cast<ParamGenerator<T3> >(g3_),
  11792. static_cast<ParamGenerator<T4> >(g4_)));
  11793. }
  11794. private:
  11795. // No implementation - assignment is unsupported.
  11796. void operator=(const CartesianProductHolder4& other);
  11797. const Generator1 g1_;
  11798. const Generator2 g2_;
  11799. const Generator3 g3_;
  11800. const Generator4 g4_;
  11801. }; // class CartesianProductHolder4
  11802. template <class Generator1, class Generator2, class Generator3,
  11803. class Generator4, class Generator5>
  11804. class CartesianProductHolder5 {
  11805. public:
  11806. CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
  11807. const Generator3& g3, const Generator4& g4, const Generator5& g5)
  11808. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
  11809. template <typename T1, typename T2, typename T3, typename T4, typename T5>
  11810. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >() const {
  11811. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >(
  11812. new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
  11813. static_cast<ParamGenerator<T1> >(g1_),
  11814. static_cast<ParamGenerator<T2> >(g2_),
  11815. static_cast<ParamGenerator<T3> >(g3_),
  11816. static_cast<ParamGenerator<T4> >(g4_),
  11817. static_cast<ParamGenerator<T5> >(g5_)));
  11818. }
  11819. private:
  11820. // No implementation - assignment is unsupported.
  11821. void operator=(const CartesianProductHolder5& other);
  11822. const Generator1 g1_;
  11823. const Generator2 g2_;
  11824. const Generator3 g3_;
  11825. const Generator4 g4_;
  11826. const Generator5 g5_;
  11827. }; // class CartesianProductHolder5
  11828. template <class Generator1, class Generator2, class Generator3,
  11829. class Generator4, class Generator5, class Generator6>
  11830. class CartesianProductHolder6 {
  11831. public:
  11832. CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
  11833. const Generator3& g3, const Generator4& g4, const Generator5& g5,
  11834. const Generator6& g6)
  11835. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
  11836. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11837. typename T6>
  11838. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >() const {
  11839. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >(
  11840. new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
  11841. static_cast<ParamGenerator<T1> >(g1_),
  11842. static_cast<ParamGenerator<T2> >(g2_),
  11843. static_cast<ParamGenerator<T3> >(g3_),
  11844. static_cast<ParamGenerator<T4> >(g4_),
  11845. static_cast<ParamGenerator<T5> >(g5_),
  11846. static_cast<ParamGenerator<T6> >(g6_)));
  11847. }
  11848. private:
  11849. // No implementation - assignment is unsupported.
  11850. void operator=(const CartesianProductHolder6& other);
  11851. const Generator1 g1_;
  11852. const Generator2 g2_;
  11853. const Generator3 g3_;
  11854. const Generator4 g4_;
  11855. const Generator5 g5_;
  11856. const Generator6 g6_;
  11857. }; // class CartesianProductHolder6
  11858. template <class Generator1, class Generator2, class Generator3,
  11859. class Generator4, class Generator5, class Generator6, class Generator7>
  11860. class CartesianProductHolder7 {
  11861. public:
  11862. CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
  11863. const Generator3& g3, const Generator4& g4, const Generator5& g5,
  11864. const Generator6& g6, const Generator7& g7)
  11865. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
  11866. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11867. typename T6, typename T7>
  11868. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >() const {
  11869. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >(
  11870. new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(
  11871. static_cast<ParamGenerator<T1> >(g1_),
  11872. static_cast<ParamGenerator<T2> >(g2_),
  11873. static_cast<ParamGenerator<T3> >(g3_),
  11874. static_cast<ParamGenerator<T4> >(g4_),
  11875. static_cast<ParamGenerator<T5> >(g5_),
  11876. static_cast<ParamGenerator<T6> >(g6_),
  11877. static_cast<ParamGenerator<T7> >(g7_)));
  11878. }
  11879. private:
  11880. // No implementation - assignment is unsupported.
  11881. void operator=(const CartesianProductHolder7& other);
  11882. const Generator1 g1_;
  11883. const Generator2 g2_;
  11884. const Generator3 g3_;
  11885. const Generator4 g4_;
  11886. const Generator5 g5_;
  11887. const Generator6 g6_;
  11888. const Generator7 g7_;
  11889. }; // class CartesianProductHolder7
  11890. template <class Generator1, class Generator2, class Generator3,
  11891. class Generator4, class Generator5, class Generator6, class Generator7,
  11892. class Generator8>
  11893. class CartesianProductHolder8 {
  11894. public:
  11895. CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
  11896. const Generator3& g3, const Generator4& g4, const Generator5& g5,
  11897. const Generator6& g6, const Generator7& g7, const Generator8& g8)
  11898. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),
  11899. g8_(g8) {}
  11900. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11901. typename T6, typename T7, typename T8>
  11902. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
  11903. T8> >() const {
  11904. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
  11905. new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(
  11906. static_cast<ParamGenerator<T1> >(g1_),
  11907. static_cast<ParamGenerator<T2> >(g2_),
  11908. static_cast<ParamGenerator<T3> >(g3_),
  11909. static_cast<ParamGenerator<T4> >(g4_),
  11910. static_cast<ParamGenerator<T5> >(g5_),
  11911. static_cast<ParamGenerator<T6> >(g6_),
  11912. static_cast<ParamGenerator<T7> >(g7_),
  11913. static_cast<ParamGenerator<T8> >(g8_)));
  11914. }
  11915. private:
  11916. // No implementation - assignment is unsupported.
  11917. void operator=(const CartesianProductHolder8& other);
  11918. const Generator1 g1_;
  11919. const Generator2 g2_;
  11920. const Generator3 g3_;
  11921. const Generator4 g4_;
  11922. const Generator5 g5_;
  11923. const Generator6 g6_;
  11924. const Generator7 g7_;
  11925. const Generator8 g8_;
  11926. }; // class CartesianProductHolder8
  11927. template <class Generator1, class Generator2, class Generator3,
  11928. class Generator4, class Generator5, class Generator6, class Generator7,
  11929. class Generator8, class Generator9>
  11930. class CartesianProductHolder9 {
  11931. public:
  11932. CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
  11933. const Generator3& g3, const Generator4& g4, const Generator5& g5,
  11934. const Generator6& g6, const Generator7& g7, const Generator8& g8,
  11935. const Generator9& g9)
  11936. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
  11937. g9_(g9) {}
  11938. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11939. typename T6, typename T7, typename T8, typename T9>
  11940. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
  11941. T9> >() const {
  11942. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >(
  11943. new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
  11944. static_cast<ParamGenerator<T1> >(g1_),
  11945. static_cast<ParamGenerator<T2> >(g2_),
  11946. static_cast<ParamGenerator<T3> >(g3_),
  11947. static_cast<ParamGenerator<T4> >(g4_),
  11948. static_cast<ParamGenerator<T5> >(g5_),
  11949. static_cast<ParamGenerator<T6> >(g6_),
  11950. static_cast<ParamGenerator<T7> >(g7_),
  11951. static_cast<ParamGenerator<T8> >(g8_),
  11952. static_cast<ParamGenerator<T9> >(g9_)));
  11953. }
  11954. private:
  11955. // No implementation - assignment is unsupported.
  11956. void operator=(const CartesianProductHolder9& other);
  11957. const Generator1 g1_;
  11958. const Generator2 g2_;
  11959. const Generator3 g3_;
  11960. const Generator4 g4_;
  11961. const Generator5 g5_;
  11962. const Generator6 g6_;
  11963. const Generator7 g7_;
  11964. const Generator8 g8_;
  11965. const Generator9 g9_;
  11966. }; // class CartesianProductHolder9
  11967. template <class Generator1, class Generator2, class Generator3,
  11968. class Generator4, class Generator5, class Generator6, class Generator7,
  11969. class Generator8, class Generator9, class Generator10>
  11970. class CartesianProductHolder10 {
  11971. public:
  11972. CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
  11973. const Generator3& g3, const Generator4& g4, const Generator5& g5,
  11974. const Generator6& g6, const Generator7& g7, const Generator8& g8,
  11975. const Generator9& g9, const Generator10& g10)
  11976. : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),
  11977. g9_(g9), g10_(g10) {}
  11978. template <typename T1, typename T2, typename T3, typename T4, typename T5,
  11979. typename T6, typename T7, typename T8, typename T9, typename T10>
  11980. operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
  11981. T10> >() const {
  11982. return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
  11983. T10> >(
  11984. new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
  11985. T10>(
  11986. static_cast<ParamGenerator<T1> >(g1_),
  11987. static_cast<ParamGenerator<T2> >(g2_),
  11988. static_cast<ParamGenerator<T3> >(g3_),
  11989. static_cast<ParamGenerator<T4> >(g4_),
  11990. static_cast<ParamGenerator<T5> >(g5_),
  11991. static_cast<ParamGenerator<T6> >(g6_),
  11992. static_cast<ParamGenerator<T7> >(g7_),
  11993. static_cast<ParamGenerator<T8> >(g8_),
  11994. static_cast<ParamGenerator<T9> >(g9_),
  11995. static_cast<ParamGenerator<T10> >(g10_)));
  11996. }
  11997. private:
  11998. // No implementation - assignment is unsupported.
  11999. void operator=(const CartesianProductHolder10& other);
  12000. const Generator1 g1_;
  12001. const Generator2 g2_;
  12002. const Generator3 g3_;
  12003. const Generator4 g4_;
  12004. const Generator5 g5_;
  12005. const Generator6 g6_;
  12006. const Generator7 g7_;
  12007. const Generator8 g8_;
  12008. const Generator9 g9_;
  12009. const Generator10 g10_;
  12010. }; // class CartesianProductHolder10
  12011. } // namespace internal
  12012. } // namespace testing
  12013. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
  12014. namespace testing {
  12015. // Functions producing parameter generators.
  12016. //
  12017. // Google Test uses these generators to produce parameters for value-
  12018. // parameterized tests. When a parameterized test suite is instantiated
  12019. // with a particular generator, Google Test creates and runs tests
  12020. // for each element in the sequence produced by the generator.
  12021. //
  12022. // In the following sample, tests from test suite FooTest are instantiated
  12023. // each three times with parameter values 3, 5, and 8:
  12024. //
  12025. // class FooTest : public TestWithParam<int> { ... };
  12026. //
  12027. // TEST_P(FooTest, TestThis) {
  12028. // }
  12029. // TEST_P(FooTest, TestThat) {
  12030. // }
  12031. // INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8));
  12032. //
  12033. // Range() returns generators providing sequences of values in a range.
  12034. //
  12035. // Synopsis:
  12036. // Range(start, end)
  12037. // - returns a generator producing a sequence of values {start, start+1,
  12038. // start+2, ..., }.
  12039. // Range(start, end, step)
  12040. // - returns a generator producing a sequence of values {start, start+step,
  12041. // start+step+step, ..., }.
  12042. // Notes:
  12043. // * The generated sequences never include end. For example, Range(1, 5)
  12044. // returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
  12045. // returns a generator producing {1, 3, 5, 7}.
  12046. // * start and end must have the same type. That type may be any integral or
  12047. // floating-point type or a user defined type satisfying these conditions:
  12048. // * It must be assignable (have operator=() defined).
  12049. // * It must have operator+() (operator+(int-compatible type) for
  12050. // two-operand version).
  12051. // * It must have operator<() defined.
  12052. // Elements in the resulting sequences will also have that type.
  12053. // * Condition start < end must be satisfied in order for resulting sequences
  12054. // to contain any elements.
  12055. //
  12056. template <typename T, typename IncrementT>
  12057. internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
  12058. return internal::ParamGenerator<T>(
  12059. new internal::RangeGenerator<T, IncrementT>(start, end, step));
  12060. }
  12061. template <typename T>
  12062. internal::ParamGenerator<T> Range(T start, T end) {
  12063. return Range(start, end, 1);
  12064. }
  12065. // ValuesIn() function allows generation of tests with parameters coming from
  12066. // a container.
  12067. //
  12068. // Synopsis:
  12069. // ValuesIn(const T (&array)[N])
  12070. // - returns a generator producing sequences with elements from
  12071. // a C-style array.
  12072. // ValuesIn(const Container& container)
  12073. // - returns a generator producing sequences with elements from
  12074. // an STL-style container.
  12075. // ValuesIn(Iterator begin, Iterator end)
  12076. // - returns a generator producing sequences with elements from
  12077. // a range [begin, end) defined by a pair of STL-style iterators. These
  12078. // iterators can also be plain C pointers.
  12079. //
  12080. // Please note that ValuesIn copies the values from the containers
  12081. // passed in and keeps them to generate tests in RUN_ALL_TESTS().
  12082. //
  12083. // Examples:
  12084. //
  12085. // This instantiates tests from test suite StringTest
  12086. // each with C-string values of "foo", "bar", and "baz":
  12087. //
  12088. // const char* strings[] = {"foo", "bar", "baz"};
  12089. // INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));
  12090. //
  12091. // This instantiates tests from test suite StlStringTest
  12092. // each with STL strings with values "a" and "b":
  12093. //
  12094. // ::std::vector< ::std::string> GetParameterStrings() {
  12095. // ::std::vector< ::std::string> v;
  12096. // v.push_back("a");
  12097. // v.push_back("b");
  12098. // return v;
  12099. // }
  12100. //
  12101. // INSTANTIATE_TEST_SUITE_P(CharSequence,
  12102. // StlStringTest,
  12103. // ValuesIn(GetParameterStrings()));
  12104. //
  12105. //
  12106. // This will also instantiate tests from CharTest
  12107. // each with parameter values 'a' and 'b':
  12108. //
  12109. // ::std::list<char> GetParameterChars() {
  12110. // ::std::list<char> list;
  12111. // list.push_back('a');
  12112. // list.push_back('b');
  12113. // return list;
  12114. // }
  12115. // ::std::list<char> l = GetParameterChars();
  12116. // INSTANTIATE_TEST_SUITE_P(CharSequence2,
  12117. // CharTest,
  12118. // ValuesIn(l.begin(), l.end()));
  12119. //
  12120. template <typename ForwardIterator>
  12121. internal::ParamGenerator<
  12122. typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>
  12123. ValuesIn(ForwardIterator begin, ForwardIterator end) {
  12124. typedef typename ::testing::internal::IteratorTraits<ForwardIterator>
  12125. ::value_type ParamType;
  12126. return internal::ParamGenerator<ParamType>(
  12127. new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
  12128. }
  12129. template <typename T, size_t N>
  12130. internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
  12131. return ValuesIn(array, array + N);
  12132. }
  12133. template <class Container>
  12134. internal::ParamGenerator<typename Container::value_type> ValuesIn(
  12135. const Container& container) {
  12136. return ValuesIn(container.begin(), container.end());
  12137. }
  12138. // Values() allows generating tests from explicitly specified list of
  12139. // parameters.
  12140. //
  12141. // Synopsis:
  12142. // Values(T v1, T v2, ..., T vN)
  12143. // - returns a generator producing sequences with elements v1, v2, ..., vN.
  12144. //
  12145. // For example, this instantiates tests from test suite BarTest each
  12146. // with values "one", "two", and "three":
  12147. //
  12148. // INSTANTIATE_TEST_SUITE_P(NumSequence,
  12149. // BarTest,
  12150. // Values("one", "two", "three"));
  12151. //
  12152. // This instantiates tests from test suite BazTest each with values 1, 2, 3.5.
  12153. // The exact type of values will depend on the type of parameter in BazTest.
  12154. //
  12155. // INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
  12156. //
  12157. //
  12158. template <typename... T>
  12159. internal::ValueArray<T...> Values(T... v) {
  12160. return internal::ValueArray<T...>(std::move(v)...);
  12161. }
  12162. // Bool() allows generating tests with parameters in a set of (false, true).
  12163. //
  12164. // Synopsis:
  12165. // Bool()
  12166. // - returns a generator producing sequences with elements {false, true}.
  12167. //
  12168. // It is useful when testing code that depends on Boolean flags. Combinations
  12169. // of multiple flags can be tested when several Bool()'s are combined using
  12170. // Combine() function.
  12171. //
  12172. // In the following example all tests in the test suite FlagDependentTest
  12173. // will be instantiated twice with parameters false and true.
  12174. //
  12175. // class FlagDependentTest : public testing::TestWithParam<bool> {
  12176. // virtual void SetUp() {
  12177. // external_flag = GetParam();
  12178. // }
  12179. // }
  12180. // INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
  12181. //
  12182. inline internal::ParamGenerator<bool> Bool() {
  12183. return Values(false, true);
  12184. }
  12185. // Combine() allows the user to combine two or more sequences to produce
  12186. // values of a Cartesian product of those sequences' elements.
  12187. //
  12188. // Synopsis:
  12189. // Combine(gen1, gen2, ..., genN)
  12190. // - returns a generator producing sequences with elements coming from
  12191. // the Cartesian product of elements from the sequences generated by
  12192. // gen1, gen2, ..., genN. The sequence elements will have a type of
  12193. // std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
  12194. // of elements from sequences produces by gen1, gen2, ..., genN.
  12195. //
  12196. // Combine can have up to 10 arguments.
  12197. //
  12198. // Example:
  12199. //
  12200. // This will instantiate tests in test suite AnimalTest each one with
  12201. // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
  12202. // tuple("dog", BLACK), and tuple("dog", WHITE):
  12203. //
  12204. // enum Color { BLACK, GRAY, WHITE };
  12205. // class AnimalTest
  12206. // : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
  12207. //
  12208. // TEST_P(AnimalTest, AnimalLooksNice) {...}
  12209. //
  12210. // INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
  12211. // Combine(Values("cat", "dog"),
  12212. // Values(BLACK, WHITE)));
  12213. //
  12214. // This will instantiate tests in FlagDependentTest with all variations of two
  12215. // Boolean flags:
  12216. //
  12217. // class FlagDependentTest
  12218. // : public testing::TestWithParam<std::tuple<bool, bool> > {
  12219. // virtual void SetUp() {
  12220. // // Assigns external_flag_1 and external_flag_2 values from the tuple.
  12221. // std::tie(external_flag_1, external_flag_2) = GetParam();
  12222. // }
  12223. // };
  12224. //
  12225. // TEST_P(FlagDependentTest, TestFeature1) {
  12226. // // Test your code using external_flag_1 and external_flag_2 here.
  12227. // }
  12228. // INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,
  12229. // Combine(Bool(), Bool()));
  12230. //
  12231. template <typename Generator1, typename Generator2>
  12232. internal::CartesianProductHolder2<Generator1, Generator2> Combine(
  12233. const Generator1& g1, const Generator2& g2) {
  12234. return internal::CartesianProductHolder2<Generator1, Generator2>(
  12235. g1, g2);
  12236. }
  12237. template <typename Generator1, typename Generator2, typename Generator3>
  12238. internal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(
  12239. const Generator1& g1, const Generator2& g2, const Generator3& g3) {
  12240. return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
  12241. g1, g2, g3);
  12242. }
  12243. template <typename Generator1, typename Generator2, typename Generator3,
  12244. typename Generator4>
  12245. internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
  12246. Generator4> Combine(
  12247. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12248. const Generator4& g4) {
  12249. return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,
  12250. Generator4>(
  12251. g1, g2, g3, g4);
  12252. }
  12253. template <typename Generator1, typename Generator2, typename Generator3,
  12254. typename Generator4, typename Generator5>
  12255. internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
  12256. Generator4, Generator5> Combine(
  12257. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12258. const Generator4& g4, const Generator5& g5) {
  12259. return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,
  12260. Generator4, Generator5>(
  12261. g1, g2, g3, g4, g5);
  12262. }
  12263. template <typename Generator1, typename Generator2, typename Generator3,
  12264. typename Generator4, typename Generator5, typename Generator6>
  12265. internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
  12266. Generator4, Generator5, Generator6> Combine(
  12267. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12268. const Generator4& g4, const Generator5& g5, const Generator6& g6) {
  12269. return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,
  12270. Generator4, Generator5, Generator6>(
  12271. g1, g2, g3, g4, g5, g6);
  12272. }
  12273. template <typename Generator1, typename Generator2, typename Generator3,
  12274. typename Generator4, typename Generator5, typename Generator6,
  12275. typename Generator7>
  12276. internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
  12277. Generator4, Generator5, Generator6, Generator7> Combine(
  12278. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12279. const Generator4& g4, const Generator5& g5, const Generator6& g6,
  12280. const Generator7& g7) {
  12281. return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,
  12282. Generator4, Generator5, Generator6, Generator7>(
  12283. g1, g2, g3, g4, g5, g6, g7);
  12284. }
  12285. template <typename Generator1, typename Generator2, typename Generator3,
  12286. typename Generator4, typename Generator5, typename Generator6,
  12287. typename Generator7, typename Generator8>
  12288. internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
  12289. Generator4, Generator5, Generator6, Generator7, Generator8> Combine(
  12290. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12291. const Generator4& g4, const Generator5& g5, const Generator6& g6,
  12292. const Generator7& g7, const Generator8& g8) {
  12293. return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,
  12294. Generator4, Generator5, Generator6, Generator7, Generator8>(
  12295. g1, g2, g3, g4, g5, g6, g7, g8);
  12296. }
  12297. template <typename Generator1, typename Generator2, typename Generator3,
  12298. typename Generator4, typename Generator5, typename Generator6,
  12299. typename Generator7, typename Generator8, typename Generator9>
  12300. internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
  12301. Generator4, Generator5, Generator6, Generator7, Generator8,
  12302. Generator9> Combine(
  12303. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12304. const Generator4& g4, const Generator5& g5, const Generator6& g6,
  12305. const Generator7& g7, const Generator8& g8, const Generator9& g9) {
  12306. return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,
  12307. Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(
  12308. g1, g2, g3, g4, g5, g6, g7, g8, g9);
  12309. }
  12310. template <typename Generator1, typename Generator2, typename Generator3,
  12311. typename Generator4, typename Generator5, typename Generator6,
  12312. typename Generator7, typename Generator8, typename Generator9,
  12313. typename Generator10>
  12314. internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
  12315. Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
  12316. Generator10> Combine(
  12317. const Generator1& g1, const Generator2& g2, const Generator3& g3,
  12318. const Generator4& g4, const Generator5& g5, const Generator6& g6,
  12319. const Generator7& g7, const Generator8& g8, const Generator9& g9,
  12320. const Generator10& g10) {
  12321. return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
  12322. Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,
  12323. Generator10>(
  12324. g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
  12325. }
  12326. #define TEST_P(test_suite_name, test_name) \
  12327. class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
  12328. : public test_suite_name { \
  12329. public: \
  12330. GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
  12331. virtual void TestBody(); \
  12332. \
  12333. private: \
  12334. static int AddToRegistry() { \
  12335. ::testing::UnitTest::GetInstance() \
  12336. ->parameterized_test_registry() \
  12337. .GetTestSuitePatternHolder<test_suite_name>( \
  12338. #test_suite_name, \
  12339. ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
  12340. ->AddTestPattern( \
  12341. GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
  12342. new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
  12343. test_suite_name, test_name)>()); \
  12344. return 0; \
  12345. } \
  12346. static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
  12347. GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
  12348. test_name)); \
  12349. }; \
  12350. int GTEST_TEST_CLASS_NAME_(test_suite_name, \
  12351. test_name)::gtest_registering_dummy_ = \
  12352. GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
  12353. void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
  12354. // The optional last argument to INSTANTIATE_TEST_SUITE_P allows the user
  12355. // to specify a function or functor that generates custom test name suffixes
  12356. // based on the test parameters. The function should accept one argument of
  12357. // type testing::TestParamInfo<class ParamType>, and return std::string.
  12358. //
  12359. // testing::PrintToStringParamName is a builtin test suffix generator that
  12360. // returns the value of testing::PrintToString(GetParam()).
  12361. //
  12362. // Note: test names must be non-empty, unique, and may only contain ASCII
  12363. // alphanumeric characters or underscore. Because PrintToString adds quotes
  12364. // to std::string and C strings, it won't work for these types.
  12365. #define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, generator, ...) \
  12366. static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
  12367. gtest_##prefix##test_suite_name##_EvalGenerator_() { \
  12368. return generator; \
  12369. } \
  12370. static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
  12371. const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
  12372. return ::testing::internal::GetParamNameGen<test_suite_name::ParamType>( \
  12373. __VA_ARGS__)(info); \
  12374. } \
  12375. static int gtest_##prefix##test_suite_name##_dummy_ \
  12376. GTEST_ATTRIBUTE_UNUSED_ = \
  12377. ::testing::UnitTest::GetInstance() \
  12378. ->parameterized_test_registry() \
  12379. .GetTestSuitePatternHolder<test_suite_name>( \
  12380. #test_suite_name, \
  12381. ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
  12382. ->AddTestSuiteInstantiation( \
  12383. #prefix, &gtest_##prefix##test_suite_name##_EvalGenerator_, \
  12384. &gtest_##prefix##test_suite_name##_EvalGenerateName_, \
  12385. __FILE__, __LINE__)
  12386. // Legacy API is deprecated but still available
  12387. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12388. #define INSTANTIATE_TEST_CASE_P INSTANTIATE_TEST_SUITE_P
  12389. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12390. } // namespace testing
  12391. #endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
  12392. // Copyright 2006, Google Inc.
  12393. // All rights reserved.
  12394. //
  12395. // Redistribution and use in source and binary forms, with or without
  12396. // modification, are permitted provided that the following conditions are
  12397. // met:
  12398. //
  12399. // * Redistributions of source code must retain the above copyright
  12400. // notice, this list of conditions and the following disclaimer.
  12401. // * Redistributions in binary form must reproduce the above
  12402. // copyright notice, this list of conditions and the following disclaimer
  12403. // in the documentation and/or other materials provided with the
  12404. // distribution.
  12405. // * Neither the name of Google Inc. nor the names of its
  12406. // contributors may be used to endorse or promote products derived from
  12407. // this software without specific prior written permission.
  12408. //
  12409. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  12410. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  12411. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  12412. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  12413. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12414. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12415. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12416. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12417. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12418. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  12419. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12420. //
  12421. // Google C++ Testing and Mocking Framework definitions useful in production code.
  12422. // GOOGLETEST_CM0003 DO NOT DELETE
  12423. #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
  12424. #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
  12425. // When you need to test the private or protected members of a class,
  12426. // use the FRIEND_TEST macro to declare your tests as friends of the
  12427. // class. For example:
  12428. //
  12429. // class MyClass {
  12430. // private:
  12431. // void PrivateMethod();
  12432. // FRIEND_TEST(MyClassTest, PrivateMethodWorks);
  12433. // };
  12434. //
  12435. // class MyClassTest : public testing::Test {
  12436. // // ...
  12437. // };
  12438. //
  12439. // TEST_F(MyClassTest, PrivateMethodWorks) {
  12440. // // Can call MyClass::PrivateMethod() here.
  12441. // }
  12442. //
  12443. // Note: The test class must be in the same namespace as the class being tested.
  12444. // For example, putting MyClassTest in an anonymous namespace will not work.
  12445. #define FRIEND_TEST(test_case_name, test_name)\
  12446. friend class test_case_name##_##test_name##_Test
  12447. #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_
  12448. // Copyright 2008, Google Inc.
  12449. // All rights reserved.
  12450. //
  12451. // Redistribution and use in source and binary forms, with or without
  12452. // modification, are permitted provided that the following conditions are
  12453. // met:
  12454. //
  12455. // * Redistributions of source code must retain the above copyright
  12456. // notice, this list of conditions and the following disclaimer.
  12457. // * Redistributions in binary form must reproduce the above
  12458. // copyright notice, this list of conditions and the following disclaimer
  12459. // in the documentation and/or other materials provided with the
  12460. // distribution.
  12461. // * Neither the name of Google Inc. nor the names of its
  12462. // contributors may be used to endorse or promote products derived from
  12463. // this software without specific prior written permission.
  12464. //
  12465. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  12466. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  12467. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  12468. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  12469. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12470. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12471. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12472. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12473. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12474. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  12475. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12476. //
  12477. // GOOGLETEST_CM0001 DO NOT DELETE
  12478. #ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
  12479. #define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
  12480. #include <iosfwd>
  12481. #include <vector>
  12482. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  12483. /* class A needs to have dll-interface to be used by clients of class B */)
  12484. namespace testing {
  12485. // A copyable object representing the result of a test part (i.e. an
  12486. // assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).
  12487. //
  12488. // Don't inherit from TestPartResult as its destructor is not virtual.
  12489. class GTEST_API_ TestPartResult {
  12490. public:
  12491. // The possible outcomes of a test part (i.e. an assertion or an
  12492. // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).
  12493. enum Type {
  12494. kSuccess, // Succeeded.
  12495. kNonFatalFailure, // Failed but the test can continue.
  12496. kFatalFailure, // Failed and the test should be terminated.
  12497. kSkip // Skipped.
  12498. };
  12499. // C'tor. TestPartResult does NOT have a default constructor.
  12500. // Always use this constructor (with parameters) to create a
  12501. // TestPartResult object.
  12502. TestPartResult(Type a_type, const char* a_file_name, int a_line_number,
  12503. const char* a_message)
  12504. : type_(a_type),
  12505. file_name_(a_file_name == nullptr ? "" : a_file_name),
  12506. line_number_(a_line_number),
  12507. summary_(ExtractSummary(a_message)),
  12508. message_(a_message) {}
  12509. // Gets the outcome of the test part.
  12510. Type type() const { return type_; }
  12511. // Gets the name of the source file where the test part took place, or
  12512. // NULL if it's unknown.
  12513. const char* file_name() const {
  12514. return file_name_.empty() ? nullptr : file_name_.c_str();
  12515. }
  12516. // Gets the line in the source file where the test part took place,
  12517. // or -1 if it's unknown.
  12518. int line_number() const { return line_number_; }
  12519. // Gets the summary of the failure message.
  12520. const char* summary() const { return summary_.c_str(); }
  12521. // Gets the message associated with the test part.
  12522. const char* message() const { return message_.c_str(); }
  12523. // Returns true iff the test part was skipped.
  12524. bool skipped() const { return type_ == kSkip; }
  12525. // Returns true iff the test part passed.
  12526. bool passed() const { return type_ == kSuccess; }
  12527. // Returns true iff the test part non-fatally failed.
  12528. bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
  12529. // Returns true iff the test part fatally failed.
  12530. bool fatally_failed() const { return type_ == kFatalFailure; }
  12531. // Returns true iff the test part failed.
  12532. bool failed() const { return fatally_failed() || nonfatally_failed(); }
  12533. private:
  12534. Type type_;
  12535. // Gets the summary of the failure message by omitting the stack
  12536. // trace in it.
  12537. static std::string ExtractSummary(const char* message);
  12538. // The name of the source file where the test part took place, or
  12539. // "" if the source file is unknown.
  12540. std::string file_name_;
  12541. // The line in the source file where the test part took place, or -1
  12542. // if the line number is unknown.
  12543. int line_number_;
  12544. std::string summary_; // The test failure summary.
  12545. std::string message_; // The test failure message.
  12546. };
  12547. // Prints a TestPartResult object.
  12548. std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
  12549. // An array of TestPartResult objects.
  12550. //
  12551. // Don't inherit from TestPartResultArray as its destructor is not
  12552. // virtual.
  12553. class GTEST_API_ TestPartResultArray {
  12554. public:
  12555. TestPartResultArray() {}
  12556. // Appends the given TestPartResult to the array.
  12557. void Append(const TestPartResult& result);
  12558. // Returns the TestPartResult at the given index (0-based).
  12559. const TestPartResult& GetTestPartResult(int index) const;
  12560. // Returns the number of TestPartResult objects in the array.
  12561. int size() const;
  12562. private:
  12563. std::vector<TestPartResult> array_;
  12564. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
  12565. };
  12566. // This interface knows how to report a test part result.
  12567. class GTEST_API_ TestPartResultReporterInterface {
  12568. public:
  12569. virtual ~TestPartResultReporterInterface() {}
  12570. virtual void ReportTestPartResult(const TestPartResult& result) = 0;
  12571. };
  12572. namespace internal {
  12573. // This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a
  12574. // statement generates new fatal failures. To do so it registers itself as the
  12575. // current test part result reporter. Besides checking if fatal failures were
  12576. // reported, it only delegates the reporting to the former result reporter.
  12577. // The original result reporter is restored in the destructor.
  12578. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  12579. class GTEST_API_ HasNewFatalFailureHelper
  12580. : public TestPartResultReporterInterface {
  12581. public:
  12582. HasNewFatalFailureHelper();
  12583. ~HasNewFatalFailureHelper() override;
  12584. void ReportTestPartResult(const TestPartResult& result) override;
  12585. bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
  12586. private:
  12587. bool has_new_fatal_failure_;
  12588. TestPartResultReporterInterface* original_reporter_;
  12589. GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
  12590. };
  12591. } // namespace internal
  12592. } // namespace testing
  12593. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  12594. #endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
  12595. // Copyright 2008 Google Inc.
  12596. // All Rights Reserved.
  12597. //
  12598. // Redistribution and use in source and binary forms, with or without
  12599. // modification, are permitted provided that the following conditions are
  12600. // met:
  12601. //
  12602. // * Redistributions of source code must retain the above copyright
  12603. // notice, this list of conditions and the following disclaimer.
  12604. // * Redistributions in binary form must reproduce the above
  12605. // copyright notice, this list of conditions and the following disclaimer
  12606. // in the documentation and/or other materials provided with the
  12607. // distribution.
  12608. // * Neither the name of Google Inc. nor the names of its
  12609. // contributors may be used to endorse or promote products derived from
  12610. // this software without specific prior written permission.
  12611. //
  12612. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  12613. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  12614. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  12615. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  12616. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12617. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12618. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12619. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12620. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12621. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  12622. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12623. // GOOGLETEST_CM0001 DO NOT DELETE
  12624. #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
  12625. #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
  12626. // This header implements typed tests and type-parameterized tests.
  12627. // Typed (aka type-driven) tests repeat the same test for types in a
  12628. // list. You must know which types you want to test with when writing
  12629. // typed tests. Here's how you do it:
  12630. #if 0
  12631. // First, define a fixture class template. It should be parameterized
  12632. // by a type. Remember to derive it from testing::Test.
  12633. template <typename T>
  12634. class FooTest : public testing::Test {
  12635. public:
  12636. ...
  12637. typedef std::list<T> List;
  12638. static T shared_;
  12639. T value_;
  12640. };
  12641. // Next, associate a list of types with the test suite, which will be
  12642. // repeated for each type in the list. The typedef is necessary for
  12643. // the macro to parse correctly.
  12644. typedef testing::Types<char, int, unsigned int> MyTypes;
  12645. TYPED_TEST_SUITE(FooTest, MyTypes);
  12646. // If the type list contains only one type, you can write that type
  12647. // directly without Types<...>:
  12648. // TYPED_TEST_SUITE(FooTest, int);
  12649. // Then, use TYPED_TEST() instead of TEST_F() to define as many typed
  12650. // tests for this test suite as you want.
  12651. TYPED_TEST(FooTest, DoesBlah) {
  12652. // Inside a test, refer to TypeParam to get the type parameter.
  12653. // Since we are inside a derived class template, C++ requires use to
  12654. // visit the members of FooTest via 'this'.
  12655. TypeParam n = this->value_;
  12656. // To visit static members of the fixture, add the TestFixture::
  12657. // prefix.
  12658. n += TestFixture::shared_;
  12659. // To refer to typedefs in the fixture, add the "typename
  12660. // TestFixture::" prefix.
  12661. typename TestFixture::List values;
  12662. values.push_back(n);
  12663. ...
  12664. }
  12665. TYPED_TEST(FooTest, HasPropertyA) { ... }
  12666. // TYPED_TEST_SUITE takes an optional third argument which allows to specify a
  12667. // class that generates custom test name suffixes based on the type. This should
  12668. // be a class which has a static template function GetName(int index) returning
  12669. // a string for each type. The provided integer index equals the index of the
  12670. // type in the provided type list. In many cases the index can be ignored.
  12671. //
  12672. // For example:
  12673. // class MyTypeNames {
  12674. // public:
  12675. // template <typename T>
  12676. // static std::string GetName(int) {
  12677. // if (std::is_same<T, char>()) return "char";
  12678. // if (std::is_same<T, int>()) return "int";
  12679. // if (std::is_same<T, unsigned int>()) return "unsignedInt";
  12680. // }
  12681. // };
  12682. // TYPED_TEST_SUITE(FooTest, MyTypes, MyTypeNames);
  12683. #endif // 0
  12684. // Type-parameterized tests are abstract test patterns parameterized
  12685. // by a type. Compared with typed tests, type-parameterized tests
  12686. // allow you to define the test pattern without knowing what the type
  12687. // parameters are. The defined pattern can be instantiated with
  12688. // different types any number of times, in any number of translation
  12689. // units.
  12690. //
  12691. // If you are designing an interface or concept, you can define a
  12692. // suite of type-parameterized tests to verify properties that any
  12693. // valid implementation of the interface/concept should have. Then,
  12694. // each implementation can easily instantiate the test suite to verify
  12695. // that it conforms to the requirements, without having to write
  12696. // similar tests repeatedly. Here's an example:
  12697. #if 0
  12698. // First, define a fixture class template. It should be parameterized
  12699. // by a type. Remember to derive it from testing::Test.
  12700. template <typename T>
  12701. class FooTest : public testing::Test {
  12702. ...
  12703. };
  12704. // Next, declare that you will define a type-parameterized test suite
  12705. // (the _P suffix is for "parameterized" or "pattern", whichever you
  12706. // prefer):
  12707. TYPED_TEST_SUITE_P(FooTest);
  12708. // Then, use TYPED_TEST_P() to define as many type-parameterized tests
  12709. // for this type-parameterized test suite as you want.
  12710. TYPED_TEST_P(FooTest, DoesBlah) {
  12711. // Inside a test, refer to TypeParam to get the type parameter.
  12712. TypeParam n = 0;
  12713. ...
  12714. }
  12715. TYPED_TEST_P(FooTest, HasPropertyA) { ... }
  12716. // Now the tricky part: you need to register all test patterns before
  12717. // you can instantiate them. The first argument of the macro is the
  12718. // test suite name; the rest are the names of the tests in this test
  12719. // case.
  12720. REGISTER_TYPED_TEST_SUITE_P(FooTest,
  12721. DoesBlah, HasPropertyA);
  12722. // Finally, you are free to instantiate the pattern with the types you
  12723. // want. If you put the above code in a header file, you can #include
  12724. // it in multiple C++ source files and instantiate it multiple times.
  12725. //
  12726. // To distinguish different instances of the pattern, the first
  12727. // argument to the INSTANTIATE_* macro is a prefix that will be added
  12728. // to the actual test suite name. Remember to pick unique prefixes for
  12729. // different instances.
  12730. typedef testing::Types<char, int, unsigned int> MyTypes;
  12731. INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
  12732. // If the type list contains only one type, you can write that type
  12733. // directly without Types<...>:
  12734. // INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int);
  12735. //
  12736. // Similar to the optional argument of TYPED_TEST_SUITE above,
  12737. // INSTANTIATE_TEST_SUITE_P takes an optional fourth argument which allows to
  12738. // generate custom names.
  12739. // INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes, MyTypeNames);
  12740. #endif // 0
  12741. // Implements typed tests.
  12742. #if GTEST_HAS_TYPED_TEST
  12743. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  12744. //
  12745. // Expands to the name of the typedef for the type parameters of the
  12746. // given test suite.
  12747. #define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_
  12748. // Expands to the name of the typedef for the NameGenerator, responsible for
  12749. // creating the suffixes of the name.
  12750. #define GTEST_NAME_GENERATOR_(TestSuiteName) \
  12751. gtest_type_params_##TestSuiteName##_NameGenerator
  12752. // The 'Types' template argument below must have spaces around it
  12753. // since some compilers may choke on '>>' when passing a template
  12754. // instance (e.g. Types<int>)
  12755. #define TYPED_TEST_SUITE(CaseName, Types, ...) \
  12756. typedef ::testing::internal::TypeList<Types>::type GTEST_TYPE_PARAMS_( \
  12757. CaseName); \
  12758. typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
  12759. GTEST_NAME_GENERATOR_(CaseName)
  12760. # define TYPED_TEST(CaseName, TestName) \
  12761. template <typename gtest_TypeParam_> \
  12762. class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
  12763. : public CaseName<gtest_TypeParam_> { \
  12764. private: \
  12765. typedef CaseName<gtest_TypeParam_> TestFixture; \
  12766. typedef gtest_TypeParam_ TypeParam; \
  12767. virtual void TestBody(); \
  12768. }; \
  12769. static bool gtest_##CaseName##_##TestName##_registered_ \
  12770. GTEST_ATTRIBUTE_UNUSED_ = \
  12771. ::testing::internal::TypeParameterizedTest< \
  12772. CaseName, \
  12773. ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
  12774. TestName)>, \
  12775. GTEST_TYPE_PARAMS_( \
  12776. CaseName)>::Register("", \
  12777. ::testing::internal::CodeLocation( \
  12778. __FILE__, __LINE__), \
  12779. #CaseName, #TestName, 0, \
  12780. ::testing::internal::GenerateNames< \
  12781. GTEST_NAME_GENERATOR_(CaseName), \
  12782. GTEST_TYPE_PARAMS_(CaseName)>()); \
  12783. template <typename gtest_TypeParam_> \
  12784. void GTEST_TEST_CLASS_NAME_(CaseName, \
  12785. TestName)<gtest_TypeParam_>::TestBody()
  12786. // Legacy API is deprecated but still available
  12787. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12788. #define TYPED_TEST_CASE TYPED_TEST_SUITE
  12789. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12790. #endif // GTEST_HAS_TYPED_TEST
  12791. // Implements type-parameterized tests.
  12792. #if GTEST_HAS_TYPED_TEST_P
  12793. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  12794. //
  12795. // Expands to the namespace name that the type-parameterized tests for
  12796. // the given type-parameterized test suite are defined in. The exact
  12797. // name of the namespace is subject to change without notice.
  12798. #define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_
  12799. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  12800. //
  12801. // Expands to the name of the variable used to remember the names of
  12802. // the defined tests in the given test suite.
  12803. #define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \
  12804. gtest_typed_test_suite_p_state_##TestSuiteName##_
  12805. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.
  12806. //
  12807. // Expands to the name of the variable used to remember the names of
  12808. // the registered tests in the given test suite.
  12809. #define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \
  12810. gtest_registered_test_names_##TestSuiteName##_
  12811. // The variables defined in the type-parameterized test macros are
  12812. // static as typically these macros are used in a .h file that can be
  12813. // #included in multiple translation units linked together.
  12814. #define TYPED_TEST_SUITE_P(SuiteName) \
  12815. static ::testing::internal::TypedTestSuitePState \
  12816. GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
  12817. // Legacy API is deprecated but still available
  12818. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12819. #define TYPED_TEST_CASE_P TYPED_TEST_SUITE_P
  12820. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12821. #define TYPED_TEST_P(SuiteName, TestName) \
  12822. namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
  12823. template <typename gtest_TypeParam_> \
  12824. class TestName : public SuiteName<gtest_TypeParam_> { \
  12825. private: \
  12826. typedef SuiteName<gtest_TypeParam_> TestFixture; \
  12827. typedef gtest_TypeParam_ TypeParam; \
  12828. virtual void TestBody(); \
  12829. }; \
  12830. static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
  12831. GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
  12832. __FILE__, __LINE__, #SuiteName, #TestName); \
  12833. } \
  12834. template <typename gtest_TypeParam_> \
  12835. void GTEST_SUITE_NAMESPACE_( \
  12836. SuiteName)::TestName<gtest_TypeParam_>::TestBody()
  12837. #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
  12838. namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
  12839. typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
  12840. } \
  12841. static const char* const GTEST_REGISTERED_TEST_NAMES_( \
  12842. SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
  12843. GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
  12844. __FILE__, __LINE__, #__VA_ARGS__)
  12845. // Legacy API is deprecated but still available
  12846. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12847. #define REGISTER_TYPED_TEST_CASE_P REGISTER_TYPED_TEST_SUITE_P
  12848. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12849. // The 'Types' template argument below must have spaces around it
  12850. // since some compilers may choke on '>>' when passing a template
  12851. // instance (e.g. Types<int>)
  12852. #define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
  12853. static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
  12854. ::testing::internal::TypeParameterizedTestSuite< \
  12855. SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
  12856. ::testing::internal::TypeList<Types>::type>:: \
  12857. Register(#Prefix, \
  12858. ::testing::internal::CodeLocation(__FILE__, __LINE__), \
  12859. &GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \
  12860. GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
  12861. ::testing::internal::GenerateNames< \
  12862. ::testing::internal::NameGeneratorSelector< \
  12863. __VA_ARGS__>::type, \
  12864. ::testing::internal::TypeList<Types>::type>())
  12865. // Legacy API is deprecated but still available
  12866. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12867. #define INSTANTIATE_TYPED_TEST_CASE_P INSTANTIATE_TYPED_TEST_SUITE_P
  12868. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12869. #endif // GTEST_HAS_TYPED_TEST_P
  12870. #endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
  12871. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
  12872. /* class A needs to have dll-interface to be used by clients of class B */)
  12873. // Depending on the platform, different string classes are available.
  12874. // On Linux, in addition to ::std::string, Google also makes use of
  12875. // class ::string, which has the same interface as ::std::string, but
  12876. // has a different implementation.
  12877. //
  12878. // You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
  12879. // ::string is available AND is a distinct type to ::std::string, or
  12880. // define it to 0 to indicate otherwise.
  12881. //
  12882. // If ::std::string and ::string are the same class on your platform
  12883. // due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0.
  12884. //
  12885. // If you do not define GTEST_HAS_GLOBAL_STRING, it is defined
  12886. // heuristically.
  12887. namespace testing {
  12888. // Silence C4100 (unreferenced formal parameter) and 4805
  12889. // unsafe mix of type 'const int' and type 'const bool'
  12890. #ifdef _MSC_VER
  12891. # pragma warning(push)
  12892. # pragma warning(disable:4805)
  12893. # pragma warning(disable:4100)
  12894. #endif
  12895. // Declares the flags.
  12896. // This flag temporary enables the disabled tests.
  12897. GTEST_DECLARE_bool_(also_run_disabled_tests);
  12898. // This flag brings the debugger on an assertion failure.
  12899. GTEST_DECLARE_bool_(break_on_failure);
  12900. // This flag controls whether Google Test catches all test-thrown exceptions
  12901. // and logs them as failures.
  12902. GTEST_DECLARE_bool_(catch_exceptions);
  12903. // This flag enables using colors in terminal output. Available values are
  12904. // "yes" to enable colors, "no" (disable colors), or "auto" (the default)
  12905. // to let Google Test decide.
  12906. GTEST_DECLARE_string_(color);
  12907. // This flag sets up the filter to select by name using a glob pattern
  12908. // the tests to run. If the filter is not given all tests are executed.
  12909. GTEST_DECLARE_string_(filter);
  12910. // This flag controls whether Google Test installs a signal handler that dumps
  12911. // debugging information when fatal signals are raised.
  12912. GTEST_DECLARE_bool_(install_failure_signal_handler);
  12913. // This flag causes the Google Test to list tests. None of the tests listed
  12914. // are actually run if the flag is provided.
  12915. GTEST_DECLARE_bool_(list_tests);
  12916. // This flag controls whether Google Test emits a detailed XML report to a file
  12917. // in addition to its normal textual output.
  12918. GTEST_DECLARE_string_(output);
  12919. // This flags control whether Google Test prints the elapsed time for each
  12920. // test.
  12921. GTEST_DECLARE_bool_(print_time);
  12922. // This flags control whether Google Test prints UTF8 characters as text.
  12923. GTEST_DECLARE_bool_(print_utf8);
  12924. // This flag specifies the random number seed.
  12925. GTEST_DECLARE_int32_(random_seed);
  12926. // This flag sets how many times the tests are repeated. The default value
  12927. // is 1. If the value is -1 the tests are repeating forever.
  12928. GTEST_DECLARE_int32_(repeat);
  12929. // This flag controls whether Google Test includes Google Test internal
  12930. // stack frames in failure stack traces.
  12931. GTEST_DECLARE_bool_(show_internal_stack_frames);
  12932. // When this flag is specified, tests' order is randomized on every iteration.
  12933. GTEST_DECLARE_bool_(shuffle);
  12934. // This flag specifies the maximum number of stack frames to be
  12935. // printed in a failure message.
  12936. GTEST_DECLARE_int32_(stack_trace_depth);
  12937. // When this flag is specified, a failed assertion will throw an
  12938. // exception if exceptions are enabled, or exit the program with a
  12939. // non-zero code otherwise. For use with an external test framework.
  12940. GTEST_DECLARE_bool_(throw_on_failure);
  12941. // When this flag is set with a "host:port" string, on supported
  12942. // platforms test results are streamed to the specified port on
  12943. // the specified host machine.
  12944. GTEST_DECLARE_string_(stream_result_to);
  12945. #if GTEST_USE_OWN_FLAGFILE_FLAG_
  12946. GTEST_DECLARE_string_(flagfile);
  12947. #endif // GTEST_USE_OWN_FLAGFILE_FLAG_
  12948. // The upper limit for valid stack trace depths.
  12949. const int kMaxStackTraceDepth = 100;
  12950. namespace internal {
  12951. class AssertHelper;
  12952. class DefaultGlobalTestPartResultReporter;
  12953. class ExecDeathTest;
  12954. class NoExecDeathTest;
  12955. class FinalSuccessChecker;
  12956. class GTestFlagSaver;
  12957. class StreamingListenerTest;
  12958. class TestResultAccessor;
  12959. class TestEventListenersAccessor;
  12960. class TestEventRepeater;
  12961. class UnitTestRecordPropertyTestHelper;
  12962. class WindowsDeathTest;
  12963. class FuchsiaDeathTest;
  12964. class UnitTestImpl* GetUnitTestImpl();
  12965. void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
  12966. const std::string& message);
  12967. } // namespace internal
  12968. // The friend relationship of some of these classes is cyclic.
  12969. // If we don't forward declare them the compiler might confuse the classes
  12970. // in friendship clauses with same named classes on the scope.
  12971. class Test;
  12972. class TestSuite;
  12973. // Old API is still available but deprecated
  12974. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  12975. using TestCase = TestSuite;
  12976. #endif
  12977. class TestInfo;
  12978. class UnitTest;
  12979. // A class for indicating whether an assertion was successful. When
  12980. // the assertion wasn't successful, the AssertionResult object
  12981. // remembers a non-empty message that describes how it failed.
  12982. //
  12983. // To create an instance of this class, use one of the factory functions
  12984. // (AssertionSuccess() and AssertionFailure()).
  12985. //
  12986. // This class is useful for two purposes:
  12987. // 1. Defining predicate functions to be used with Boolean test assertions
  12988. // EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts
  12989. // 2. Defining predicate-format functions to be
  12990. // used with predicate assertions (ASSERT_PRED_FORMAT*, etc).
  12991. //
  12992. // For example, if you define IsEven predicate:
  12993. //
  12994. // testing::AssertionResult IsEven(int n) {
  12995. // if ((n % 2) == 0)
  12996. // return testing::AssertionSuccess();
  12997. // else
  12998. // return testing::AssertionFailure() << n << " is odd";
  12999. // }
  13000. //
  13001. // Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))
  13002. // will print the message
  13003. //
  13004. // Value of: IsEven(Fib(5))
  13005. // Actual: false (5 is odd)
  13006. // Expected: true
  13007. //
  13008. // instead of a more opaque
  13009. //
  13010. // Value of: IsEven(Fib(5))
  13011. // Actual: false
  13012. // Expected: true
  13013. //
  13014. // in case IsEven is a simple Boolean predicate.
  13015. //
  13016. // If you expect your predicate to be reused and want to support informative
  13017. // messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up
  13018. // about half as often as positive ones in our tests), supply messages for
  13019. // both success and failure cases:
  13020. //
  13021. // testing::AssertionResult IsEven(int n) {
  13022. // if ((n % 2) == 0)
  13023. // return testing::AssertionSuccess() << n << " is even";
  13024. // else
  13025. // return testing::AssertionFailure() << n << " is odd";
  13026. // }
  13027. //
  13028. // Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print
  13029. //
  13030. // Value of: IsEven(Fib(6))
  13031. // Actual: true (8 is even)
  13032. // Expected: false
  13033. //
  13034. // NB: Predicates that support negative Boolean assertions have reduced
  13035. // performance in positive ones so be careful not to use them in tests
  13036. // that have lots (tens of thousands) of positive Boolean assertions.
  13037. //
  13038. // To use this class with EXPECT_PRED_FORMAT assertions such as:
  13039. //
  13040. // // Verifies that Foo() returns an even number.
  13041. // EXPECT_PRED_FORMAT1(IsEven, Foo());
  13042. //
  13043. // you need to define:
  13044. //
  13045. // testing::AssertionResult IsEven(const char* expr, int n) {
  13046. // if ((n % 2) == 0)
  13047. // return testing::AssertionSuccess();
  13048. // else
  13049. // return testing::AssertionFailure()
  13050. // << "Expected: " << expr << " is even\n Actual: it's " << n;
  13051. // }
  13052. //
  13053. // If Foo() returns 5, you will see the following message:
  13054. //
  13055. // Expected: Foo() is even
  13056. // Actual: it's 5
  13057. //
  13058. class GTEST_API_ AssertionResult {
  13059. public:
  13060. // Copy constructor.
  13061. // Used in EXPECT_TRUE/FALSE(assertion_result).
  13062. AssertionResult(const AssertionResult& other);
  13063. #if defined(_MSC_VER) && _MSC_VER < 1910
  13064. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
  13065. #endif
  13066. // Used in the EXPECT_TRUE/FALSE(bool_expression).
  13067. //
  13068. // T must be contextually convertible to bool.
  13069. //
  13070. // The second parameter prevents this overload from being considered if
  13071. // the argument is implicitly convertible to AssertionResult. In that case
  13072. // we want AssertionResult's copy constructor to be used.
  13073. template <typename T>
  13074. explicit AssertionResult(
  13075. const T& success,
  13076. typename internal::EnableIf<
  13077. !internal::ImplicitlyConvertible<T, AssertionResult>::value>::type*
  13078. /*enabler*/
  13079. = nullptr)
  13080. : success_(success) {}
  13081. #if defined(_MSC_VER) && _MSC_VER < 1910
  13082. GTEST_DISABLE_MSC_WARNINGS_POP_()
  13083. #endif
  13084. // Assignment operator.
  13085. AssertionResult& operator=(AssertionResult other) {
  13086. swap(other);
  13087. return *this;
  13088. }
  13089. // Returns true iff the assertion succeeded.
  13090. operator bool() const { return success_; } // NOLINT
  13091. // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
  13092. AssertionResult operator!() const;
  13093. // Returns the text streamed into this AssertionResult. Test assertions
  13094. // use it when they fail (i.e., the predicate's outcome doesn't match the
  13095. // assertion's expectation). When nothing has been streamed into the
  13096. // object, returns an empty string.
  13097. const char* message() const {
  13098. return message_.get() != nullptr ? message_->c_str() : "";
  13099. }
  13100. // Deprecated; please use message() instead.
  13101. const char* failure_message() const { return message(); }
  13102. // Streams a custom failure message into this object.
  13103. template <typename T> AssertionResult& operator<<(const T& value) {
  13104. AppendMessage(Message() << value);
  13105. return *this;
  13106. }
  13107. // Allows streaming basic output manipulators such as endl or flush into
  13108. // this object.
  13109. AssertionResult& operator<<(
  13110. ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
  13111. AppendMessage(Message() << basic_manipulator);
  13112. return *this;
  13113. }
  13114. private:
  13115. // Appends the contents of message to message_.
  13116. void AppendMessage(const Message& a_message) {
  13117. if (message_.get() == nullptr) message_.reset(new ::std::string);
  13118. message_->append(a_message.GetString().c_str());
  13119. }
  13120. // Swap the contents of this AssertionResult with other.
  13121. void swap(AssertionResult& other);
  13122. // Stores result of the assertion predicate.
  13123. bool success_;
  13124. // Stores the message describing the condition in case the expectation
  13125. // construct is not satisfied with the predicate's outcome.
  13126. // Referenced via a pointer to avoid taking too much stack frame space
  13127. // with test assertions.
  13128. std::unique_ptr< ::std::string> message_;
  13129. };
  13130. // Makes a successful assertion result.
  13131. GTEST_API_ AssertionResult AssertionSuccess();
  13132. // Makes a failed assertion result.
  13133. GTEST_API_ AssertionResult AssertionFailure();
  13134. // Makes a failed assertion result with the given failure message.
  13135. // Deprecated; use AssertionFailure() << msg.
  13136. GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
  13137. } // namespace testing
  13138. // Includes the auto-generated header that implements a family of generic
  13139. // predicate assertion macros. This include comes late because it relies on
  13140. // APIs declared above.
  13141. // Copyright 2006, Google Inc.
  13142. // All rights reserved.
  13143. //
  13144. // Redistribution and use in source and binary forms, with or without
  13145. // modification, are permitted provided that the following conditions are
  13146. // met:
  13147. //
  13148. // * Redistributions of source code must retain the above copyright
  13149. // notice, this list of conditions and the following disclaimer.
  13150. // * Redistributions in binary form must reproduce the above
  13151. // copyright notice, this list of conditions and the following disclaimer
  13152. // in the documentation and/or other materials provided with the
  13153. // distribution.
  13154. // * Neither the name of Google Inc. nor the names of its
  13155. // contributors may be used to endorse or promote products derived from
  13156. // this software without specific prior written permission.
  13157. //
  13158. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  13159. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  13160. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  13161. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  13162. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  13163. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13164. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13165. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13166. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13167. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13168. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13169. // This file is AUTOMATICALLY GENERATED on 01/02/2019 by command
  13170. // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
  13171. //
  13172. // Implements a family of generic predicate assertion macros.
  13173. // GOOGLETEST_CM0001 DO NOT DELETE
  13174. #ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
  13175. #define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
  13176. namespace testing {
  13177. // This header implements a family of generic predicate assertion
  13178. // macros:
  13179. //
  13180. // ASSERT_PRED_FORMAT1(pred_format, v1)
  13181. // ASSERT_PRED_FORMAT2(pred_format, v1, v2)
  13182. // ...
  13183. //
  13184. // where pred_format is a function or functor that takes n (in the
  13185. // case of ASSERT_PRED_FORMATn) values and their source expression
  13186. // text, and returns a testing::AssertionResult. See the definition
  13187. // of ASSERT_EQ in gtest.h for an example.
  13188. //
  13189. // If you don't care about formatting, you can use the more
  13190. // restrictive version:
  13191. //
  13192. // ASSERT_PRED1(pred, v1)
  13193. // ASSERT_PRED2(pred, v1, v2)
  13194. // ...
  13195. //
  13196. // where pred is an n-ary function or functor that returns bool,
  13197. // and the values v1, v2, ..., must support the << operator for
  13198. // streaming to std::ostream.
  13199. //
  13200. // We also define the EXPECT_* variations.
  13201. //
  13202. // For now we only support predicates whose arity is at most 5.
  13203. // Please email googletestframework@googlegroups.com if you need
  13204. // support for higher arities.
  13205. // GTEST_ASSERT_ is the basic statement to which all of the assertions
  13206. // in this file reduce. Don't use this in your code.
  13207. #define GTEST_ASSERT_(expression, on_failure) \
  13208. GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
  13209. if (const ::testing::AssertionResult gtest_ar = (expression)) \
  13210. ; \
  13211. else \
  13212. on_failure(gtest_ar.failure_message())
  13213. // Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
  13214. // this in your code.
  13215. template <typename Pred,
  13216. typename T1>
  13217. AssertionResult AssertPred1Helper(const char* pred_text,
  13218. const char* e1,
  13219. Pred pred,
  13220. const T1& v1) {
  13221. if (pred(v1)) return AssertionSuccess();
  13222. return AssertionFailure()
  13223. << pred_text << "(" << e1 << ") evaluates to false, where"
  13224. << "\n"
  13225. << e1 << " evaluates to " << ::testing::PrintToString(v1);
  13226. }
  13227. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.
  13228. // Don't use this in your code.
  13229. #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
  13230. GTEST_ASSERT_(pred_format(#v1, v1), \
  13231. on_failure)
  13232. // Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use
  13233. // this in your code.
  13234. #define GTEST_PRED1_(pred, v1, on_failure)\
  13235. GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
  13236. #v1, \
  13237. pred, \
  13238. v1), on_failure)
  13239. // Unary predicate assertion macros.
  13240. #define EXPECT_PRED_FORMAT1(pred_format, v1) \
  13241. GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
  13242. #define EXPECT_PRED1(pred, v1) \
  13243. GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
  13244. #define ASSERT_PRED_FORMAT1(pred_format, v1) \
  13245. GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
  13246. #define ASSERT_PRED1(pred, v1) \
  13247. GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
  13248. // Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
  13249. // this in your code.
  13250. template <typename Pred,
  13251. typename T1,
  13252. typename T2>
  13253. AssertionResult AssertPred2Helper(const char* pred_text,
  13254. const char* e1,
  13255. const char* e2,
  13256. Pred pred,
  13257. const T1& v1,
  13258. const T2& v2) {
  13259. if (pred(v1, v2)) return AssertionSuccess();
  13260. return AssertionFailure()
  13261. << pred_text << "(" << e1 << ", " << e2
  13262. << ") evaluates to false, where"
  13263. << "\n"
  13264. << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
  13265. << e2 << " evaluates to " << ::testing::PrintToString(v2);
  13266. }
  13267. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.
  13268. // Don't use this in your code.
  13269. #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
  13270. GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
  13271. on_failure)
  13272. // Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use
  13273. // this in your code.
  13274. #define GTEST_PRED2_(pred, v1, v2, on_failure)\
  13275. GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
  13276. #v1, \
  13277. #v2, \
  13278. pred, \
  13279. v1, \
  13280. v2), on_failure)
  13281. // Binary predicate assertion macros.
  13282. #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
  13283. GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  13284. #define EXPECT_PRED2(pred, v1, v2) \
  13285. GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
  13286. #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
  13287. GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
  13288. #define ASSERT_PRED2(pred, v1, v2) \
  13289. GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
  13290. // Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
  13291. // this in your code.
  13292. template <typename Pred,
  13293. typename T1,
  13294. typename T2,
  13295. typename T3>
  13296. AssertionResult AssertPred3Helper(const char* pred_text,
  13297. const char* e1,
  13298. const char* e2,
  13299. const char* e3,
  13300. Pred pred,
  13301. const T1& v1,
  13302. const T2& v2,
  13303. const T3& v3) {
  13304. if (pred(v1, v2, v3)) return AssertionSuccess();
  13305. return AssertionFailure()
  13306. << pred_text << "(" << e1 << ", " << e2 << ", " << e3
  13307. << ") evaluates to false, where"
  13308. << "\n"
  13309. << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
  13310. << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
  13311. << e3 << " evaluates to " << ::testing::PrintToString(v3);
  13312. }
  13313. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.
  13314. // Don't use this in your code.
  13315. #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
  13316. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
  13317. on_failure)
  13318. // Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use
  13319. // this in your code.
  13320. #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
  13321. GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
  13322. #v1, \
  13323. #v2, \
  13324. #v3, \
  13325. pred, \
  13326. v1, \
  13327. v2, \
  13328. v3), on_failure)
  13329. // Ternary predicate assertion macros.
  13330. #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
  13331. GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
  13332. #define EXPECT_PRED3(pred, v1, v2, v3) \
  13333. GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
  13334. #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
  13335. GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
  13336. #define ASSERT_PRED3(pred, v1, v2, v3) \
  13337. GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
  13338. // Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
  13339. // this in your code.
  13340. template <typename Pred,
  13341. typename T1,
  13342. typename T2,
  13343. typename T3,
  13344. typename T4>
  13345. AssertionResult AssertPred4Helper(const char* pred_text,
  13346. const char* e1,
  13347. const char* e2,
  13348. const char* e3,
  13349. const char* e4,
  13350. Pred pred,
  13351. const T1& v1,
  13352. const T2& v2,
  13353. const T3& v3,
  13354. const T4& v4) {
  13355. if (pred(v1, v2, v3, v4)) return AssertionSuccess();
  13356. return AssertionFailure()
  13357. << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
  13358. << ") evaluates to false, where"
  13359. << "\n"
  13360. << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
  13361. << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
  13362. << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
  13363. << e4 << " evaluates to " << ::testing::PrintToString(v4);
  13364. }
  13365. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.
  13366. // Don't use this in your code.
  13367. #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
  13368. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
  13369. on_failure)
  13370. // Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use
  13371. // this in your code.
  13372. #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
  13373. GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
  13374. #v1, \
  13375. #v2, \
  13376. #v3, \
  13377. #v4, \
  13378. pred, \
  13379. v1, \
  13380. v2, \
  13381. v3, \
  13382. v4), on_failure)
  13383. // 4-ary predicate assertion macros.
  13384. #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
  13385. GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
  13386. #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
  13387. GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
  13388. #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
  13389. GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
  13390. #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
  13391. GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
  13392. // Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
  13393. // this in your code.
  13394. template <typename Pred,
  13395. typename T1,
  13396. typename T2,
  13397. typename T3,
  13398. typename T4,
  13399. typename T5>
  13400. AssertionResult AssertPred5Helper(const char* pred_text,
  13401. const char* e1,
  13402. const char* e2,
  13403. const char* e3,
  13404. const char* e4,
  13405. const char* e5,
  13406. Pred pred,
  13407. const T1& v1,
  13408. const T2& v2,
  13409. const T3& v3,
  13410. const T4& v4,
  13411. const T5& v5) {
  13412. if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
  13413. return AssertionFailure()
  13414. << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
  13415. << ", " << e5 << ") evaluates to false, where"
  13416. << "\n"
  13417. << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
  13418. << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
  13419. << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
  13420. << e4 << " evaluates to " << ::testing::PrintToString(v4) << "\n"
  13421. << e5 << " evaluates to " << ::testing::PrintToString(v5);
  13422. }
  13423. // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.
  13424. // Don't use this in your code.
  13425. #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
  13426. GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
  13427. on_failure)
  13428. // Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use
  13429. // this in your code.
  13430. #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
  13431. GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
  13432. #v1, \
  13433. #v2, \
  13434. #v3, \
  13435. #v4, \
  13436. #v5, \
  13437. pred, \
  13438. v1, \
  13439. v2, \
  13440. v3, \
  13441. v4, \
  13442. v5), on_failure)
  13443. // 5-ary predicate assertion macros.
  13444. #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
  13445. GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
  13446. #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
  13447. GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
  13448. #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
  13449. GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
  13450. #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
  13451. GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
  13452. } // namespace testing
  13453. #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
  13454. namespace testing {
  13455. // The abstract class that all tests inherit from.
  13456. //
  13457. // In Google Test, a unit test program contains one or many TestSuites, and
  13458. // each TestSuite contains one or many Tests.
  13459. //
  13460. // When you define a test using the TEST macro, you don't need to
  13461. // explicitly derive from Test - the TEST macro automatically does
  13462. // this for you.
  13463. //
  13464. // The only time you derive from Test is when defining a test fixture
  13465. // to be used in a TEST_F. For example:
  13466. //
  13467. // class FooTest : public testing::Test {
  13468. // protected:
  13469. // void SetUp() override { ... }
  13470. // void TearDown() override { ... }
  13471. // ...
  13472. // };
  13473. //
  13474. // TEST_F(FooTest, Bar) { ... }
  13475. // TEST_F(FooTest, Baz) { ... }
  13476. //
  13477. // Test is not copyable.
  13478. class GTEST_API_ Test {
  13479. public:
  13480. friend class TestInfo;
  13481. // The d'tor is virtual as we intend to inherit from Test.
  13482. virtual ~Test();
  13483. // Sets up the stuff shared by all tests in this test case.
  13484. //
  13485. // Google Test will call Foo::SetUpTestSuite() before running the first
  13486. // test in test case Foo. Hence a sub-class can define its own
  13487. // SetUpTestSuite() method to shadow the one defined in the super
  13488. // class.
  13489. static void SetUpTestSuite() {}
  13490. // Tears down the stuff shared by all tests in this test case.
  13491. //
  13492. // Google Test will call Foo::TearDownTestSuite() after running the last
  13493. // test in test case Foo. Hence a sub-class can define its own
  13494. // TearDownTestSuite() method to shadow the one defined in the super
  13495. // class.
  13496. static void TearDownTestSuite() {}
  13497. // Legacy API is deprecated but still available
  13498. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  13499. static void TearDownTestCase() {}
  13500. static void SetUpTestCase() {}
  13501. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  13502. // Returns true iff the current test has a fatal failure.
  13503. static bool HasFatalFailure();
  13504. // Returns true iff the current test has a non-fatal failure.
  13505. static bool HasNonfatalFailure();
  13506. // Returns true iff the current test was skipped.
  13507. static bool IsSkipped();
  13508. // Returns true iff the current test has a (either fatal or
  13509. // non-fatal) failure.
  13510. static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
  13511. // Logs a property for the current test, test suite, or for the entire
  13512. // invocation of the test program when used outside of the context of a
  13513. // test suite. Only the last value for a given key is remembered. These
  13514. // are public static so they can be called from utility functions that are
  13515. // not members of the test fixture. Calls to RecordProperty made during
  13516. // lifespan of the test (from the moment its constructor starts to the
  13517. // moment its destructor finishes) will be output in XML as attributes of
  13518. // the <testcase> element. Properties recorded from fixture's
  13519. // SetUpTestSuite or TearDownTestSuite are logged as attributes of the
  13520. // corresponding <testsuite> element. Calls to RecordProperty made in the
  13521. // global context (before or after invocation of RUN_ALL_TESTS and from
  13522. // SetUp/TearDown method of Environment objects registered with Google
  13523. // Test) will be output as attributes of the <testsuites> element.
  13524. static void RecordProperty(const std::string& key, const std::string& value);
  13525. static void RecordProperty(const std::string& key, int value);
  13526. protected:
  13527. // Creates a Test object.
  13528. Test();
  13529. // Sets up the test fixture.
  13530. virtual void SetUp();
  13531. // Tears down the test fixture.
  13532. virtual void TearDown();
  13533. private:
  13534. // Returns true iff the current test has the same fixture class as
  13535. // the first test in the current test suite.
  13536. static bool HasSameFixtureClass();
  13537. // Runs the test after the test fixture has been set up.
  13538. //
  13539. // A sub-class must implement this to define the test logic.
  13540. //
  13541. // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.
  13542. // Instead, use the TEST or TEST_F macro.
  13543. virtual void TestBody() = 0;
  13544. // Sets up, executes, and tears down the test.
  13545. void Run();
  13546. // Deletes self. We deliberately pick an unusual name for this
  13547. // internal method to avoid clashing with names used in user TESTs.
  13548. void DeleteSelf_() { delete this; }
  13549. const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
  13550. // Often a user misspells SetUp() as Setup() and spends a long time
  13551. // wondering why it is never called by Google Test. The declaration of
  13552. // the following method is solely for catching such an error at
  13553. // compile time:
  13554. //
  13555. // - The return type is deliberately chosen to be not void, so it
  13556. // will be a conflict if void Setup() is declared in the user's
  13557. // test fixture.
  13558. //
  13559. // - This method is private, so it will be another compiler error
  13560. // if the method is called from the user's test fixture.
  13561. //
  13562. // DO NOT OVERRIDE THIS FUNCTION.
  13563. //
  13564. // If you see an error about overriding the following function or
  13565. // about it being private, you have mis-spelled SetUp() as Setup().
  13566. struct Setup_should_be_spelled_SetUp {};
  13567. virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
  13568. // We disallow copying Tests.
  13569. GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
  13570. };
  13571. typedef internal::TimeInMillis TimeInMillis;
  13572. // A copyable object representing a user specified test property which can be
  13573. // output as a key/value string pair.
  13574. //
  13575. // Don't inherit from TestProperty as its destructor is not virtual.
  13576. class TestProperty {
  13577. public:
  13578. // C'tor. TestProperty does NOT have a default constructor.
  13579. // Always use this constructor (with parameters) to create a
  13580. // TestProperty object.
  13581. TestProperty(const std::string& a_key, const std::string& a_value) :
  13582. key_(a_key), value_(a_value) {
  13583. }
  13584. // Gets the user supplied key.
  13585. const char* key() const {
  13586. return key_.c_str();
  13587. }
  13588. // Gets the user supplied value.
  13589. const char* value() const {
  13590. return value_.c_str();
  13591. }
  13592. // Sets a new value, overriding the one supplied in the constructor.
  13593. void SetValue(const std::string& new_value) {
  13594. value_ = new_value;
  13595. }
  13596. private:
  13597. // The key supplied by the user.
  13598. std::string key_;
  13599. // The value supplied by the user.
  13600. std::string value_;
  13601. };
  13602. // The result of a single Test. This includes a list of
  13603. // TestPartResults, a list of TestProperties, a count of how many
  13604. // death tests there are in the Test, and how much time it took to run
  13605. // the Test.
  13606. //
  13607. // TestResult is not copyable.
  13608. class GTEST_API_ TestResult {
  13609. public:
  13610. // Creates an empty TestResult.
  13611. TestResult();
  13612. // D'tor. Do not inherit from TestResult.
  13613. ~TestResult();
  13614. // Gets the number of all test parts. This is the sum of the number
  13615. // of successful test parts and the number of failed test parts.
  13616. int total_part_count() const;
  13617. // Returns the number of the test properties.
  13618. int test_property_count() const;
  13619. // Returns true iff the test passed (i.e. no test part failed).
  13620. bool Passed() const { return !Skipped() && !Failed(); }
  13621. // Returns true iff the test was skipped.
  13622. bool Skipped() const;
  13623. // Returns true iff the test failed.
  13624. bool Failed() const;
  13625. // Returns true iff the test fatally failed.
  13626. bool HasFatalFailure() const;
  13627. // Returns true iff the test has a non-fatal failure.
  13628. bool HasNonfatalFailure() const;
  13629. // Returns the elapsed time, in milliseconds.
  13630. TimeInMillis elapsed_time() const { return elapsed_time_; }
  13631. // Returns the i-th test part result among all the results. i can range from 0
  13632. // to total_part_count() - 1. If i is not in that range, aborts the program.
  13633. const TestPartResult& GetTestPartResult(int i) const;
  13634. // Returns the i-th test property. i can range from 0 to
  13635. // test_property_count() - 1. If i is not in that range, aborts the
  13636. // program.
  13637. const TestProperty& GetTestProperty(int i) const;
  13638. private:
  13639. friend class TestInfo;
  13640. friend class TestSuite;
  13641. friend class UnitTest;
  13642. friend class internal::DefaultGlobalTestPartResultReporter;
  13643. friend class internal::ExecDeathTest;
  13644. friend class internal::TestResultAccessor;
  13645. friend class internal::UnitTestImpl;
  13646. friend class internal::WindowsDeathTest;
  13647. friend class internal::FuchsiaDeathTest;
  13648. // Gets the vector of TestPartResults.
  13649. const std::vector<TestPartResult>& test_part_results() const {
  13650. return test_part_results_;
  13651. }
  13652. // Gets the vector of TestProperties.
  13653. const std::vector<TestProperty>& test_properties() const {
  13654. return test_properties_;
  13655. }
  13656. // Sets the elapsed time.
  13657. void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
  13658. // Adds a test property to the list. The property is validated and may add
  13659. // a non-fatal failure if invalid (e.g., if it conflicts with reserved
  13660. // key names). If a property is already recorded for the same key, the
  13661. // value will be updated, rather than storing multiple values for the same
  13662. // key. xml_element specifies the element for which the property is being
  13663. // recorded and is used for validation.
  13664. void RecordProperty(const std::string& xml_element,
  13665. const TestProperty& test_property);
  13666. // Adds a failure if the key is a reserved attribute of Google Test
  13667. // testsuite tags. Returns true if the property is valid.
  13668. // FIXME: Validate attribute names are legal and human readable.
  13669. static bool ValidateTestProperty(const std::string& xml_element,
  13670. const TestProperty& test_property);
  13671. // Adds a test part result to the list.
  13672. void AddTestPartResult(const TestPartResult& test_part_result);
  13673. // Returns the death test count.
  13674. int death_test_count() const { return death_test_count_; }
  13675. // Increments the death test count, returning the new count.
  13676. int increment_death_test_count() { return ++death_test_count_; }
  13677. // Clears the test part results.
  13678. void ClearTestPartResults();
  13679. // Clears the object.
  13680. void Clear();
  13681. // Protects mutable state of the property vector and of owned
  13682. // properties, whose values may be updated.
  13683. internal::Mutex test_properites_mutex_;
  13684. // The vector of TestPartResults
  13685. std::vector<TestPartResult> test_part_results_;
  13686. // The vector of TestProperties
  13687. std::vector<TestProperty> test_properties_;
  13688. // Running count of death tests.
  13689. int death_test_count_;
  13690. // The elapsed time, in milliseconds.
  13691. TimeInMillis elapsed_time_;
  13692. // We disallow copying TestResult.
  13693. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
  13694. }; // class TestResult
  13695. // A TestInfo object stores the following information about a test:
  13696. //
  13697. // Test suite name
  13698. // Test name
  13699. // Whether the test should be run
  13700. // A function pointer that creates the test object when invoked
  13701. // Test result
  13702. //
  13703. // The constructor of TestInfo registers itself with the UnitTest
  13704. // singleton such that the RUN_ALL_TESTS() macro knows which tests to
  13705. // run.
  13706. class GTEST_API_ TestInfo {
  13707. public:
  13708. // Destructs a TestInfo object. This function is not virtual, so
  13709. // don't inherit from TestInfo.
  13710. ~TestInfo();
  13711. // Returns the test suite name.
  13712. const char* test_suite_name() const { return test_suite_name_.c_str(); }
  13713. // Legacy API is deprecated but still available
  13714. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  13715. const char* test_case_name() const { return test_suite_name(); }
  13716. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  13717. // Returns the test name.
  13718. const char* name() const { return name_.c_str(); }
  13719. // Returns the name of the parameter type, or NULL if this is not a typed
  13720. // or a type-parameterized test.
  13721. const char* type_param() const {
  13722. if (type_param_.get() != nullptr) return type_param_->c_str();
  13723. return nullptr;
  13724. }
  13725. // Returns the text representation of the value parameter, or NULL if this
  13726. // is not a value-parameterized test.
  13727. const char* value_param() const {
  13728. if (value_param_.get() != nullptr) return value_param_->c_str();
  13729. return nullptr;
  13730. }
  13731. // Returns the file name where this test is defined.
  13732. const char* file() const { return location_.file.c_str(); }
  13733. // Returns the line where this test is defined.
  13734. int line() const { return location_.line; }
  13735. // Return true if this test should not be run because it's in another shard.
  13736. bool is_in_another_shard() const { return is_in_another_shard_; }
  13737. // Returns true if this test should run, that is if the test is not
  13738. // disabled (or it is disabled but the also_run_disabled_tests flag has
  13739. // been specified) and its full name matches the user-specified filter.
  13740. //
  13741. // Google Test allows the user to filter the tests by their full names.
  13742. // The full name of a test Bar in test suite Foo is defined as
  13743. // "Foo.Bar". Only the tests that match the filter will run.
  13744. //
  13745. // A filter is a colon-separated list of glob (not regex) patterns,
  13746. // optionally followed by a '-' and a colon-separated list of
  13747. // negative patterns (tests to exclude). A test is run if it
  13748. // matches one of the positive patterns and does not match any of
  13749. // the negative patterns.
  13750. //
  13751. // For example, *A*:Foo.* is a filter that matches any string that
  13752. // contains the character 'A' or starts with "Foo.".
  13753. bool should_run() const { return should_run_; }
  13754. // Returns true iff this test will appear in the XML report.
  13755. bool is_reportable() const {
  13756. // The XML report includes tests matching the filter, excluding those
  13757. // run in other shards.
  13758. return matches_filter_ && !is_in_another_shard_;
  13759. }
  13760. // Returns the result of the test.
  13761. const TestResult* result() const { return &result_; }
  13762. private:
  13763. #if GTEST_HAS_DEATH_TEST
  13764. friend class internal::DefaultDeathTestFactory;
  13765. #endif // GTEST_HAS_DEATH_TEST
  13766. friend class Test;
  13767. friend class TestSuite;
  13768. friend class internal::UnitTestImpl;
  13769. friend class internal::StreamingListenerTest;
  13770. friend TestInfo* internal::MakeAndRegisterTestInfo(
  13771. const char* test_suite_name, const char* name, const char* type_param,
  13772. const char* value_param, internal::CodeLocation code_location,
  13773. internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
  13774. internal::TearDownTestSuiteFunc tear_down_tc,
  13775. internal::TestFactoryBase* factory);
  13776. // Constructs a TestInfo object. The newly constructed instance assumes
  13777. // ownership of the factory object.
  13778. TestInfo(const std::string& test_suite_name, const std::string& name,
  13779. const char* a_type_param, // NULL if not a type-parameterized test
  13780. const char* a_value_param, // NULL if not a value-parameterized test
  13781. internal::CodeLocation a_code_location,
  13782. internal::TypeId fixture_class_id,
  13783. internal::TestFactoryBase* factory);
  13784. // Increments the number of death tests encountered in this test so
  13785. // far.
  13786. int increment_death_test_count() {
  13787. return result_.increment_death_test_count();
  13788. }
  13789. // Creates the test object, runs it, records its result, and then
  13790. // deletes it.
  13791. void Run();
  13792. static void ClearTestResult(TestInfo* test_info) {
  13793. test_info->result_.Clear();
  13794. }
  13795. // These fields are immutable properties of the test.
  13796. const std::string test_suite_name_; // test suite name
  13797. const std::string name_; // Test name
  13798. // Name of the parameter type, or NULL if this is not a typed or a
  13799. // type-parameterized test.
  13800. const std::unique_ptr<const ::std::string> type_param_;
  13801. // Text representation of the value parameter, or NULL if this is not a
  13802. // value-parameterized test.
  13803. const std::unique_ptr<const ::std::string> value_param_;
  13804. internal::CodeLocation location_;
  13805. const internal::TypeId fixture_class_id_; // ID of the test fixture class
  13806. bool should_run_; // True iff this test should run
  13807. bool is_disabled_; // True iff this test is disabled
  13808. bool matches_filter_; // True if this test matches the
  13809. // user-specified filter.
  13810. bool is_in_another_shard_; // Will be run in another shard.
  13811. internal::TestFactoryBase* const factory_; // The factory that creates
  13812. // the test object
  13813. // This field is mutable and needs to be reset before running the
  13814. // test for the second time.
  13815. TestResult result_;
  13816. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
  13817. };
  13818. // A test suite, which consists of a vector of TestInfos.
  13819. //
  13820. // TestSuite is not copyable.
  13821. class GTEST_API_ TestSuite {
  13822. public:
  13823. // Creates a TestSuite with the given name.
  13824. //
  13825. // TestSuite does NOT have a default constructor. Always use this
  13826. // constructor to create a TestSuite object.
  13827. //
  13828. // Arguments:
  13829. //
  13830. // name: name of the test suite
  13831. // a_type_param: the name of the test's type parameter, or NULL if
  13832. // this is not a type-parameterized test.
  13833. // set_up_tc: pointer to the function that sets up the test suite
  13834. // tear_down_tc: pointer to the function that tears down the test suite
  13835. TestSuite(const char* name, const char* a_type_param,
  13836. internal::SetUpTestSuiteFunc set_up_tc,
  13837. internal::TearDownTestSuiteFunc tear_down_tc);
  13838. // Destructor of TestSuite.
  13839. virtual ~TestSuite();
  13840. // Gets the name of the TestSuite.
  13841. const char* name() const { return name_.c_str(); }
  13842. // Returns the name of the parameter type, or NULL if this is not a
  13843. // type-parameterized test suite.
  13844. const char* type_param() const {
  13845. if (type_param_.get() != nullptr) return type_param_->c_str();
  13846. return nullptr;
  13847. }
  13848. // Returns true if any test in this test suite should run.
  13849. bool should_run() const { return should_run_; }
  13850. // Gets the number of successful tests in this test suite.
  13851. int successful_test_count() const;
  13852. // Gets the number of skipped tests in this test suite.
  13853. int skipped_test_count() const;
  13854. // Gets the number of failed tests in this test suite.
  13855. int failed_test_count() const;
  13856. // Gets the number of disabled tests that will be reported in the XML report.
  13857. int reportable_disabled_test_count() const;
  13858. // Gets the number of disabled tests in this test suite.
  13859. int disabled_test_count() const;
  13860. // Gets the number of tests to be printed in the XML report.
  13861. int reportable_test_count() const;
  13862. // Get the number of tests in this test suite that should run.
  13863. int test_to_run_count() const;
  13864. // Gets the number of all tests in this test suite.
  13865. int total_test_count() const;
  13866. // Returns true iff the test suite passed.
  13867. bool Passed() const { return !Failed(); }
  13868. // Returns true iff the test suite failed.
  13869. bool Failed() const { return failed_test_count() > 0; }
  13870. // Returns the elapsed time, in milliseconds.
  13871. TimeInMillis elapsed_time() const { return elapsed_time_; }
  13872. // Returns the i-th test among all the tests. i can range from 0 to
  13873. // total_test_count() - 1. If i is not in that range, returns NULL.
  13874. const TestInfo* GetTestInfo(int i) const;
  13875. // Returns the TestResult that holds test properties recorded during
  13876. // execution of SetUpTestSuite and TearDownTestSuite.
  13877. const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
  13878. private:
  13879. friend class Test;
  13880. friend class internal::UnitTestImpl;
  13881. // Gets the (mutable) vector of TestInfos in this TestSuite.
  13882. std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
  13883. // Gets the (immutable) vector of TestInfos in this TestSuite.
  13884. const std::vector<TestInfo*>& test_info_list() const {
  13885. return test_info_list_;
  13886. }
  13887. // Returns the i-th test among all the tests. i can range from 0 to
  13888. // total_test_count() - 1. If i is not in that range, returns NULL.
  13889. TestInfo* GetMutableTestInfo(int i);
  13890. // Sets the should_run member.
  13891. void set_should_run(bool should) { should_run_ = should; }
  13892. // Adds a TestInfo to this test suite. Will delete the TestInfo upon
  13893. // destruction of the TestSuite object.
  13894. void AddTestInfo(TestInfo * test_info);
  13895. // Clears the results of all tests in this test suite.
  13896. void ClearResult();
  13897. // Clears the results of all tests in the given test suite.
  13898. static void ClearTestSuiteResult(TestSuite* test_suite) {
  13899. test_suite->ClearResult();
  13900. }
  13901. // Runs every test in this TestSuite.
  13902. void Run();
  13903. // Runs SetUpTestSuite() for this TestSuite. This wrapper is needed
  13904. // for catching exceptions thrown from SetUpTestSuite().
  13905. void RunSetUpTestSuite() {
  13906. if (set_up_tc_ != nullptr) {
  13907. (*set_up_tc_)();
  13908. }
  13909. }
  13910. // Runs TearDownTestSuite() for this TestSuite. This wrapper is
  13911. // needed for catching exceptions thrown from TearDownTestSuite().
  13912. void RunTearDownTestSuite() {
  13913. if (tear_down_tc_ != nullptr) {
  13914. (*tear_down_tc_)();
  13915. }
  13916. }
  13917. // Returns true iff test passed.
  13918. static bool TestPassed(const TestInfo* test_info) {
  13919. return test_info->should_run() && test_info->result()->Passed();
  13920. }
  13921. // Returns true iff test skipped.
  13922. static bool TestSkipped(const TestInfo* test_info) {
  13923. return test_info->should_run() && test_info->result()->Skipped();
  13924. }
  13925. // Returns true iff test failed.
  13926. static bool TestFailed(const TestInfo* test_info) {
  13927. return test_info->should_run() && test_info->result()->Failed();
  13928. }
  13929. // Returns true iff the test is disabled and will be reported in the XML
  13930. // report.
  13931. static bool TestReportableDisabled(const TestInfo* test_info) {
  13932. return test_info->is_reportable() && test_info->is_disabled_;
  13933. }
  13934. // Returns true iff test is disabled.
  13935. static bool TestDisabled(const TestInfo* test_info) {
  13936. return test_info->is_disabled_;
  13937. }
  13938. // Returns true iff this test will appear in the XML report.
  13939. static bool TestReportable(const TestInfo* test_info) {
  13940. return test_info->is_reportable();
  13941. }
  13942. // Returns true if the given test should run.
  13943. static bool ShouldRunTest(const TestInfo* test_info) {
  13944. return test_info->should_run();
  13945. }
  13946. // Shuffles the tests in this test suite.
  13947. void ShuffleTests(internal::Random* random);
  13948. // Restores the test order to before the first shuffle.
  13949. void UnshuffleTests();
  13950. // Name of the test suite.
  13951. std::string name_;
  13952. // Name of the parameter type, or NULL if this is not a typed or a
  13953. // type-parameterized test.
  13954. const std::unique_ptr<const ::std::string> type_param_;
  13955. // The vector of TestInfos in their original order. It owns the
  13956. // elements in the vector.
  13957. std::vector<TestInfo*> test_info_list_;
  13958. // Provides a level of indirection for the test list to allow easy
  13959. // shuffling and restoring the test order. The i-th element in this
  13960. // vector is the index of the i-th test in the shuffled test list.
  13961. std::vector<int> test_indices_;
  13962. // Pointer to the function that sets up the test suite.
  13963. internal::SetUpTestSuiteFunc set_up_tc_;
  13964. // Pointer to the function that tears down the test suite.
  13965. internal::TearDownTestSuiteFunc tear_down_tc_;
  13966. // True iff any test in this test suite should run.
  13967. bool should_run_;
  13968. // Elapsed time, in milliseconds.
  13969. TimeInMillis elapsed_time_;
  13970. // Holds test properties recorded during execution of SetUpTestSuite and
  13971. // TearDownTestSuite.
  13972. TestResult ad_hoc_test_result_;
  13973. // We disallow copying TestSuites.
  13974. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
  13975. };
  13976. // An Environment object is capable of setting up and tearing down an
  13977. // environment. You should subclass this to define your own
  13978. // environment(s).
  13979. //
  13980. // An Environment object does the set-up and tear-down in virtual
  13981. // methods SetUp() and TearDown() instead of the constructor and the
  13982. // destructor, as:
  13983. //
  13984. // 1. You cannot safely throw from a destructor. This is a problem
  13985. // as in some cases Google Test is used where exceptions are enabled, and
  13986. // we may want to implement ASSERT_* using exceptions where they are
  13987. // available.
  13988. // 2. You cannot use ASSERT_* directly in a constructor or
  13989. // destructor.
  13990. class Environment {
  13991. public:
  13992. // The d'tor is virtual as we need to subclass Environment.
  13993. virtual ~Environment() {}
  13994. // Override this to define how to set up the environment.
  13995. virtual void SetUp() {}
  13996. // Override this to define how to tear down the environment.
  13997. virtual void TearDown() {}
  13998. private:
  13999. // If you see an error about overriding the following function or
  14000. // about it being private, you have mis-spelled SetUp() as Setup().
  14001. struct Setup_should_be_spelled_SetUp {};
  14002. virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
  14003. };
  14004. #if GTEST_HAS_EXCEPTIONS
  14005. // Exception which can be thrown from TestEventListener::OnTestPartResult.
  14006. class GTEST_API_ AssertionException
  14007. : public internal::GoogleTestFailureException {
  14008. public:
  14009. explicit AssertionException(const TestPartResult& result)
  14010. : GoogleTestFailureException(result) {}
  14011. };
  14012. #endif // GTEST_HAS_EXCEPTIONS
  14013. // The interface for tracing execution of tests. The methods are organized in
  14014. // the order the corresponding events are fired.
  14015. class TestEventListener {
  14016. public:
  14017. virtual ~TestEventListener() {}
  14018. // Fired before any test activity starts.
  14019. virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
  14020. // Fired before each iteration of tests starts. There may be more than
  14021. // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration
  14022. // index, starting from 0.
  14023. virtual void OnTestIterationStart(const UnitTest& unit_test,
  14024. int iteration) = 0;
  14025. // Fired before environment set-up for each iteration of tests starts.
  14026. virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
  14027. // Fired after environment set-up for each iteration of tests ends.
  14028. virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
  14029. // Fired before the test suite starts.
  14030. virtual void OnTestSuiteStart(const TestSuite& test_suite) {}
  14031. // Legacy API is deprecated but still available
  14032. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14033. virtual void OnTestCaseStart(const TestCase& test_case) {}
  14034. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14035. // Fired before the test starts.
  14036. virtual void OnTestStart(const TestInfo& test_info) = 0;
  14037. // Fired after a failed assertion or a SUCCEED() invocation.
  14038. // If you want to throw an exception from this function to skip to the next
  14039. // TEST, it must be AssertionException defined above, or inherited from it.
  14040. virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
  14041. // Fired after the test ends.
  14042. virtual void OnTestEnd(const TestInfo& test_info) = 0;
  14043. // Fired after the test suite ends.
  14044. virtual void OnTestSuiteEnd(const TestSuite& test_suite) {}
  14045. // Legacy API is deprecated but still available
  14046. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14047. virtual void OnTestCaseEnd(const TestCase& test_case) {}
  14048. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14049. // Fired before environment tear-down for each iteration of tests starts.
  14050. virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
  14051. // Fired after environment tear-down for each iteration of tests ends.
  14052. virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
  14053. // Fired after each iteration of tests finishes.
  14054. virtual void OnTestIterationEnd(const UnitTest& unit_test,
  14055. int iteration) = 0;
  14056. // Fired after all test activities have ended.
  14057. virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
  14058. };
  14059. // The convenience class for users who need to override just one or two
  14060. // methods and are not concerned that a possible change to a signature of
  14061. // the methods they override will not be caught during the build. For
  14062. // comments about each method please see the definition of TestEventListener
  14063. // above.
  14064. class EmptyTestEventListener : public TestEventListener {
  14065. public:
  14066. void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
  14067. void OnTestIterationStart(const UnitTest& /*unit_test*/,
  14068. int /*iteration*/) override {}
  14069. void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
  14070. void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
  14071. void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}
  14072. // Legacy API is deprecated but still available
  14073. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14074. void OnTestCaseStart(const TestCase& tc /*test_suite*/) override {}
  14075. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14076. void OnTestStart(const TestInfo& /*test_info*/) override {}
  14077. void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}
  14078. void OnTestEnd(const TestInfo& /*test_info*/) override {}
  14079. void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}
  14080. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14081. void OnTestCaseEnd(const TestCase& tc /*test_suite*/) override {}
  14082. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14083. void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
  14084. void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
  14085. void OnTestIterationEnd(const UnitTest& /*unit_test*/,
  14086. int /*iteration*/) override {}
  14087. void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
  14088. };
  14089. // TestEventListeners lets users add listeners to track events in Google Test.
  14090. class GTEST_API_ TestEventListeners {
  14091. public:
  14092. TestEventListeners();
  14093. ~TestEventListeners();
  14094. // Appends an event listener to the end of the list. Google Test assumes
  14095. // the ownership of the listener (i.e. it will delete the listener when
  14096. // the test program finishes).
  14097. void Append(TestEventListener* listener);
  14098. // Removes the given event listener from the list and returns it. It then
  14099. // becomes the caller's responsibility to delete the listener. Returns
  14100. // NULL if the listener is not found in the list.
  14101. TestEventListener* Release(TestEventListener* listener);
  14102. // Returns the standard listener responsible for the default console
  14103. // output. Can be removed from the listeners list to shut down default
  14104. // console output. Note that removing this object from the listener list
  14105. // with Release transfers its ownership to the caller and makes this
  14106. // function return NULL the next time.
  14107. TestEventListener* default_result_printer() const {
  14108. return default_result_printer_;
  14109. }
  14110. // Returns the standard listener responsible for the default XML output
  14111. // controlled by the --gtest_output=xml flag. Can be removed from the
  14112. // listeners list by users who want to shut down the default XML output
  14113. // controlled by this flag and substitute it with custom one. Note that
  14114. // removing this object from the listener list with Release transfers its
  14115. // ownership to the caller and makes this function return NULL the next
  14116. // time.
  14117. TestEventListener* default_xml_generator() const {
  14118. return default_xml_generator_;
  14119. }
  14120. private:
  14121. friend class TestSuite;
  14122. friend class TestInfo;
  14123. friend class internal::DefaultGlobalTestPartResultReporter;
  14124. friend class internal::NoExecDeathTest;
  14125. friend class internal::TestEventListenersAccessor;
  14126. friend class internal::UnitTestImpl;
  14127. // Returns repeater that broadcasts the TestEventListener events to all
  14128. // subscribers.
  14129. TestEventListener* repeater();
  14130. // Sets the default_result_printer attribute to the provided listener.
  14131. // The listener is also added to the listener list and previous
  14132. // default_result_printer is removed from it and deleted. The listener can
  14133. // also be NULL in which case it will not be added to the list. Does
  14134. // nothing if the previous and the current listener objects are the same.
  14135. void SetDefaultResultPrinter(TestEventListener* listener);
  14136. // Sets the default_xml_generator attribute to the provided listener. The
  14137. // listener is also added to the listener list and previous
  14138. // default_xml_generator is removed from it and deleted. The listener can
  14139. // also be NULL in which case it will not be added to the list. Does
  14140. // nothing if the previous and the current listener objects are the same.
  14141. void SetDefaultXmlGenerator(TestEventListener* listener);
  14142. // Controls whether events will be forwarded by the repeater to the
  14143. // listeners in the list.
  14144. bool EventForwardingEnabled() const;
  14145. void SuppressEventForwarding();
  14146. // The actual list of listeners.
  14147. internal::TestEventRepeater* repeater_;
  14148. // Listener responsible for the standard result output.
  14149. TestEventListener* default_result_printer_;
  14150. // Listener responsible for the creation of the XML output file.
  14151. TestEventListener* default_xml_generator_;
  14152. // We disallow copying TestEventListeners.
  14153. GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
  14154. };
  14155. // A UnitTest consists of a vector of TestSuites.
  14156. //
  14157. // This is a singleton class. The only instance of UnitTest is
  14158. // created when UnitTest::GetInstance() is first called. This
  14159. // instance is never deleted.
  14160. //
  14161. // UnitTest is not copyable.
  14162. //
  14163. // This class is thread-safe as long as the methods are called
  14164. // according to their specification.
  14165. class GTEST_API_ UnitTest {
  14166. public:
  14167. // Gets the singleton UnitTest object. The first time this method
  14168. // is called, a UnitTest object is constructed and returned.
  14169. // Consecutive calls will return the same object.
  14170. static UnitTest* GetInstance();
  14171. // Runs all tests in this UnitTest object and prints the result.
  14172. // Returns 0 if successful, or 1 otherwise.
  14173. //
  14174. // This method can only be called from the main thread.
  14175. //
  14176. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14177. int Run() GTEST_MUST_USE_RESULT_;
  14178. // Returns the working directory when the first TEST() or TEST_F()
  14179. // was executed. The UnitTest object owns the string.
  14180. const char* original_working_dir() const;
  14181. // Returns the TestSuite object for the test that's currently running,
  14182. // or NULL if no test is running.
  14183. const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
  14184. // Legacy API is still available but deprecated
  14185. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14186. const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);
  14187. #endif
  14188. // Returns the TestInfo object for the test that's currently running,
  14189. // or NULL if no test is running.
  14190. const TestInfo* current_test_info() const
  14191. GTEST_LOCK_EXCLUDED_(mutex_);
  14192. // Returns the random seed used at the start of the current test run.
  14193. int random_seed() const;
  14194. // Returns the ParameterizedTestSuiteRegistry object used to keep track of
  14195. // value-parameterized tests and instantiate and register them.
  14196. //
  14197. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14198. internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
  14199. GTEST_LOCK_EXCLUDED_(mutex_);
  14200. // Gets the number of successful test suites.
  14201. int successful_test_suite_count() const;
  14202. // Gets the number of failed test suites.
  14203. int failed_test_suite_count() const;
  14204. // Gets the number of all test suites.
  14205. int total_test_suite_count() const;
  14206. // Gets the number of all test suites that contain at least one test
  14207. // that should run.
  14208. int test_suite_to_run_count() const;
  14209. // Legacy API is deprecated but still available
  14210. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14211. int successful_test_case_count() const;
  14212. int failed_test_case_count() const;
  14213. int total_test_case_count() const;
  14214. int test_case_to_run_count() const;
  14215. #endif // EMOVE_LEGACY_TEST_CASEAPI
  14216. // Gets the number of successful tests.
  14217. int successful_test_count() const;
  14218. // Gets the number of skipped tests.
  14219. int skipped_test_count() const;
  14220. // Gets the number of failed tests.
  14221. int failed_test_count() const;
  14222. // Gets the number of disabled tests that will be reported in the XML report.
  14223. int reportable_disabled_test_count() const;
  14224. // Gets the number of disabled tests.
  14225. int disabled_test_count() const;
  14226. // Gets the number of tests to be printed in the XML report.
  14227. int reportable_test_count() const;
  14228. // Gets the number of all tests.
  14229. int total_test_count() const;
  14230. // Gets the number of tests that should run.
  14231. int test_to_run_count() const;
  14232. // Gets the time of the test program start, in ms from the start of the
  14233. // UNIX epoch.
  14234. TimeInMillis start_timestamp() const;
  14235. // Gets the elapsed time, in milliseconds.
  14236. TimeInMillis elapsed_time() const;
  14237. // Returns true iff the unit test passed (i.e. all test suites passed).
  14238. bool Passed() const;
  14239. // Returns true iff the unit test failed (i.e. some test suite failed
  14240. // or something outside of all tests failed).
  14241. bool Failed() const;
  14242. // Gets the i-th test suite among all the test suites. i can range from 0 to
  14243. // total_test_suite_count() - 1. If i is not in that range, returns NULL.
  14244. const TestSuite* GetTestSuite(int i) const;
  14245. // Legacy API is deprecated but still available
  14246. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14247. const TestCase* GetTestCase(int i) const;
  14248. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  14249. // Returns the TestResult containing information on test failures and
  14250. // properties logged outside of individual test suites.
  14251. const TestResult& ad_hoc_test_result() const;
  14252. // Returns the list of event listeners that can be used to track events
  14253. // inside Google Test.
  14254. TestEventListeners& listeners();
  14255. private:
  14256. // Registers and returns a global test environment. When a test
  14257. // program is run, all global test environments will be set-up in
  14258. // the order they were registered. After all tests in the program
  14259. // have finished, all global test environments will be torn-down in
  14260. // the *reverse* order they were registered.
  14261. //
  14262. // The UnitTest object takes ownership of the given environment.
  14263. //
  14264. // This method can only be called from the main thread.
  14265. Environment* AddEnvironment(Environment* env);
  14266. // Adds a TestPartResult to the current TestResult object. All
  14267. // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)
  14268. // eventually call this to report their results. The user code
  14269. // should use the assertion macros instead of calling this directly.
  14270. void AddTestPartResult(TestPartResult::Type result_type,
  14271. const char* file_name,
  14272. int line_number,
  14273. const std::string& message,
  14274. const std::string& os_stack_trace)
  14275. GTEST_LOCK_EXCLUDED_(mutex_);
  14276. // Adds a TestProperty to the current TestResult object when invoked from
  14277. // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked
  14278. // from SetUpTestSuite or TearDownTestSuite, or to the global property set
  14279. // when invoked elsewhere. If the result already contains a property with
  14280. // the same key, the value will be updated.
  14281. void RecordProperty(const std::string& key, const std::string& value);
  14282. // Gets the i-th test suite among all the test suites. i can range from 0 to
  14283. // total_test_suite_count() - 1. If i is not in that range, returns NULL.
  14284. TestSuite* GetMutableTestSuite(int i);
  14285. // Accessors for the implementation object.
  14286. internal::UnitTestImpl* impl() { return impl_; }
  14287. const internal::UnitTestImpl* impl() const { return impl_; }
  14288. // These classes and functions are friends as they need to access private
  14289. // members of UnitTest.
  14290. friend class ScopedTrace;
  14291. friend class Test;
  14292. friend class internal::AssertHelper;
  14293. friend class internal::StreamingListenerTest;
  14294. friend class internal::UnitTestRecordPropertyTestHelper;
  14295. friend Environment* AddGlobalTestEnvironment(Environment* env);
  14296. friend internal::UnitTestImpl* internal::GetUnitTestImpl();
  14297. friend void internal::ReportFailureInUnknownLocation(
  14298. TestPartResult::Type result_type,
  14299. const std::string& message);
  14300. // Creates an empty UnitTest.
  14301. UnitTest();
  14302. // D'tor
  14303. virtual ~UnitTest();
  14304. // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
  14305. // Google Test trace stack.
  14306. void PushGTestTrace(const internal::TraceInfo& trace)
  14307. GTEST_LOCK_EXCLUDED_(mutex_);
  14308. // Pops a trace from the per-thread Google Test trace stack.
  14309. void PopGTestTrace()
  14310. GTEST_LOCK_EXCLUDED_(mutex_);
  14311. // Protects mutable state in *impl_. This is mutable as some const
  14312. // methods need to lock it too.
  14313. mutable internal::Mutex mutex_;
  14314. // Opaque implementation object. This field is never changed once
  14315. // the object is constructed. We don't mark it as const here, as
  14316. // doing so will cause a warning in the constructor of UnitTest.
  14317. // Mutable state in *impl_ is protected by mutex_.
  14318. internal::UnitTestImpl* impl_;
  14319. // We disallow copying UnitTest.
  14320. GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
  14321. };
  14322. // A convenient wrapper for adding an environment for the test
  14323. // program.
  14324. //
  14325. // You should call this before RUN_ALL_TESTS() is called, probably in
  14326. // main(). If you use gtest_main, you need to call this before main()
  14327. // starts for it to take effect. For example, you can define a global
  14328. // variable like this:
  14329. //
  14330. // testing::Environment* const foo_env =
  14331. // testing::AddGlobalTestEnvironment(new FooEnvironment);
  14332. //
  14333. // However, we strongly recommend you to write your own main() and
  14334. // call AddGlobalTestEnvironment() there, as relying on initialization
  14335. // of global variables makes the code harder to read and may cause
  14336. // problems when you register multiple environments from different
  14337. // translation units and the environments have dependencies among them
  14338. // (remember that the compiler doesn't guarantee the order in which
  14339. // global variables from different translation units are initialized).
  14340. inline Environment* AddGlobalTestEnvironment(Environment* env) {
  14341. return UnitTest::GetInstance()->AddEnvironment(env);
  14342. }
  14343. // Initializes Google Test. This must be called before calling
  14344. // RUN_ALL_TESTS(). In particular, it parses a command line for the
  14345. // flags that Google Test recognizes. Whenever a Google Test flag is
  14346. // seen, it is removed from argv, and *argc is decremented.
  14347. //
  14348. // No value is returned. Instead, the Google Test flag variables are
  14349. // updated.
  14350. //
  14351. // Calling the function for the second time has no user-visible effect.
  14352. GTEST_API_ void InitGoogleTest(int* argc, char** argv);
  14353. // This overloaded version can be used in Windows programs compiled in
  14354. // UNICODE mode.
  14355. GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
  14356. namespace internal {
  14357. // Separate the error generating code from the code path to reduce the stack
  14358. // frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers
  14359. // when calling EXPECT_* in a tight loop.
  14360. template <typename T1, typename T2>
  14361. AssertionResult CmpHelperEQFailure(const char* lhs_expression,
  14362. const char* rhs_expression,
  14363. const T1& lhs, const T2& rhs) {
  14364. return EqFailure(lhs_expression,
  14365. rhs_expression,
  14366. FormatForComparisonFailureMessage(lhs, rhs),
  14367. FormatForComparisonFailureMessage(rhs, lhs),
  14368. false);
  14369. }
  14370. // This block of code defines operator==/!=
  14371. // to block lexical scope lookup.
  14372. // It prevents using invalid operator==/!= defined at namespace scope.
  14373. struct faketype {};
  14374. inline bool operator==(faketype, faketype) { return true; }
  14375. inline bool operator!=(faketype, faketype) { return false; }
  14376. // The helper function for {ASSERT|EXPECT}_EQ.
  14377. template <typename T1, typename T2>
  14378. AssertionResult CmpHelperEQ(const char* lhs_expression,
  14379. const char* rhs_expression,
  14380. const T1& lhs,
  14381. const T2& rhs) {
  14382. if (lhs == rhs) {
  14383. return AssertionSuccess();
  14384. }
  14385. return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
  14386. }
  14387. // With this overloaded version, we allow anonymous enums to be used
  14388. // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
  14389. // can be implicitly cast to BiggestInt.
  14390. GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
  14391. const char* rhs_expression,
  14392. BiggestInt lhs,
  14393. BiggestInt rhs);
  14394. // The helper class for {ASSERT|EXPECT}_EQ. The template argument
  14395. // lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
  14396. // is a null pointer literal. The following default implementation is
  14397. // for lhs_is_null_literal being false.
  14398. template <bool lhs_is_null_literal>
  14399. class EqHelper {
  14400. public:
  14401. // This templatized version is for the general case.
  14402. template <typename T1, typename T2>
  14403. static AssertionResult Compare(const char* lhs_expression,
  14404. const char* rhs_expression,
  14405. const T1& lhs,
  14406. const T2& rhs) {
  14407. return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
  14408. }
  14409. // With this overloaded version, we allow anonymous enums to be used
  14410. // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous
  14411. // enums can be implicitly cast to BiggestInt.
  14412. //
  14413. // Even though its body looks the same as the above version, we
  14414. // cannot merge the two, as it will make anonymous enums unhappy.
  14415. static AssertionResult Compare(const char* lhs_expression,
  14416. const char* rhs_expression,
  14417. BiggestInt lhs,
  14418. BiggestInt rhs) {
  14419. return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
  14420. }
  14421. };
  14422. // This specialization is used when the first argument to ASSERT_EQ()
  14423. // is a null pointer literal, like NULL, false, or 0.
  14424. template <>
  14425. class EqHelper<true> {
  14426. public:
  14427. // We define two overloaded versions of Compare(). The first
  14428. // version will be picked when the second argument to ASSERT_EQ() is
  14429. // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
  14430. // EXPECT_EQ(false, a_bool).
  14431. template <typename T1, typename T2>
  14432. static AssertionResult Compare(
  14433. const char* lhs_expression, const char* rhs_expression, const T1& lhs,
  14434. const T2& rhs,
  14435. // The following line prevents this overload from being considered if T2
  14436. // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)
  14437. // expands to Compare("", "", NULL, my_ptr), which requires a conversion
  14438. // to match the Secret* in the other overload, which would otherwise make
  14439. // this template match better.
  14440. typename EnableIf<!std::is_pointer<T2>::value>::type* = nullptr) {
  14441. return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
  14442. }
  14443. // This version will be picked when the second argument to ASSERT_EQ() is a
  14444. // pointer, e.g. ASSERT_EQ(NULL, a_pointer).
  14445. template <typename T>
  14446. static AssertionResult Compare(
  14447. const char* lhs_expression,
  14448. const char* rhs_expression,
  14449. // We used to have a second template parameter instead of Secret*. That
  14450. // template parameter would deduce to 'long', making this a better match
  14451. // than the first overload even without the first overload's EnableIf.
  14452. // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
  14453. // non-pointer argument" (even a deduced integral argument), so the old
  14454. // implementation caused warnings in user code.
  14455. Secret* /* lhs (NULL) */,
  14456. T* rhs) {
  14457. // We already know that 'lhs' is a null pointer.
  14458. return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
  14459. rhs);
  14460. }
  14461. };
  14462. // Separate the error generating code from the code path to reduce the stack
  14463. // frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers
  14464. // when calling EXPECT_OP in a tight loop.
  14465. template <typename T1, typename T2>
  14466. AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
  14467. const T1& val1, const T2& val2,
  14468. const char* op) {
  14469. return AssertionFailure()
  14470. << "Expected: (" << expr1 << ") " << op << " (" << expr2
  14471. << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
  14472. << " vs " << FormatForComparisonFailureMessage(val2, val1);
  14473. }
  14474. // A macro for implementing the helper functions needed to implement
  14475. // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste
  14476. // of similar code.
  14477. //
  14478. // For each templatized helper function, we also define an overloaded
  14479. // version for BiggestInt in order to reduce code bloat and allow
  14480. // anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
  14481. // with gcc 4.
  14482. //
  14483. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14484. #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
  14485. template <typename T1, typename T2>\
  14486. AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
  14487. const T1& val1, const T2& val2) {\
  14488. if (val1 op val2) {\
  14489. return AssertionSuccess();\
  14490. } else {\
  14491. return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
  14492. }\
  14493. }\
  14494. GTEST_API_ AssertionResult CmpHelper##op_name(\
  14495. const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
  14496. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14497. // Implements the helper function for {ASSERT|EXPECT}_NE
  14498. GTEST_IMPL_CMP_HELPER_(NE, !=);
  14499. // Implements the helper function for {ASSERT|EXPECT}_LE
  14500. GTEST_IMPL_CMP_HELPER_(LE, <=);
  14501. // Implements the helper function for {ASSERT|EXPECT}_LT
  14502. GTEST_IMPL_CMP_HELPER_(LT, <);
  14503. // Implements the helper function for {ASSERT|EXPECT}_GE
  14504. GTEST_IMPL_CMP_HELPER_(GE, >=);
  14505. // Implements the helper function for {ASSERT|EXPECT}_GT
  14506. GTEST_IMPL_CMP_HELPER_(GT, >);
  14507. #undef GTEST_IMPL_CMP_HELPER_
  14508. // The helper function for {ASSERT|EXPECT}_STREQ.
  14509. //
  14510. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14511. GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
  14512. const char* s2_expression,
  14513. const char* s1,
  14514. const char* s2);
  14515. // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
  14516. //
  14517. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14518. GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
  14519. const char* s2_expression,
  14520. const char* s1,
  14521. const char* s2);
  14522. // The helper function for {ASSERT|EXPECT}_STRNE.
  14523. //
  14524. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14525. GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
  14526. const char* s2_expression,
  14527. const char* s1,
  14528. const char* s2);
  14529. // The helper function for {ASSERT|EXPECT}_STRCASENE.
  14530. //
  14531. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14532. GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
  14533. const char* s2_expression,
  14534. const char* s1,
  14535. const char* s2);
  14536. // Helper function for *_STREQ on wide strings.
  14537. //
  14538. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14539. GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
  14540. const char* s2_expression,
  14541. const wchar_t* s1,
  14542. const wchar_t* s2);
  14543. // Helper function for *_STRNE on wide strings.
  14544. //
  14545. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14546. GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
  14547. const char* s2_expression,
  14548. const wchar_t* s1,
  14549. const wchar_t* s2);
  14550. } // namespace internal
  14551. // IsSubstring() and IsNotSubstring() are intended to be used as the
  14552. // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
  14553. // themselves. They check whether needle is a substring of haystack
  14554. // (NULL is considered a substring of itself only), and return an
  14555. // appropriate error message when they fail.
  14556. //
  14557. // The {needle,haystack}_expr arguments are the stringified
  14558. // expressions that generated the two real arguments.
  14559. GTEST_API_ AssertionResult IsSubstring(
  14560. const char* needle_expr, const char* haystack_expr,
  14561. const char* needle, const char* haystack);
  14562. GTEST_API_ AssertionResult IsSubstring(
  14563. const char* needle_expr, const char* haystack_expr,
  14564. const wchar_t* needle, const wchar_t* haystack);
  14565. GTEST_API_ AssertionResult IsNotSubstring(
  14566. const char* needle_expr, const char* haystack_expr,
  14567. const char* needle, const char* haystack);
  14568. GTEST_API_ AssertionResult IsNotSubstring(
  14569. const char* needle_expr, const char* haystack_expr,
  14570. const wchar_t* needle, const wchar_t* haystack);
  14571. GTEST_API_ AssertionResult IsSubstring(
  14572. const char* needle_expr, const char* haystack_expr,
  14573. const ::std::string& needle, const ::std::string& haystack);
  14574. GTEST_API_ AssertionResult IsNotSubstring(
  14575. const char* needle_expr, const char* haystack_expr,
  14576. const ::std::string& needle, const ::std::string& haystack);
  14577. #if GTEST_HAS_STD_WSTRING
  14578. GTEST_API_ AssertionResult IsSubstring(
  14579. const char* needle_expr, const char* haystack_expr,
  14580. const ::std::wstring& needle, const ::std::wstring& haystack);
  14581. GTEST_API_ AssertionResult IsNotSubstring(
  14582. const char* needle_expr, const char* haystack_expr,
  14583. const ::std::wstring& needle, const ::std::wstring& haystack);
  14584. #endif // GTEST_HAS_STD_WSTRING
  14585. namespace internal {
  14586. // Helper template function for comparing floating-points.
  14587. //
  14588. // Template parameter:
  14589. //
  14590. // RawType: the raw floating-point type (either float or double)
  14591. //
  14592. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14593. template <typename RawType>
  14594. AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
  14595. const char* rhs_expression,
  14596. RawType lhs_value,
  14597. RawType rhs_value) {
  14598. const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
  14599. if (lhs.AlmostEquals(rhs)) {
  14600. return AssertionSuccess();
  14601. }
  14602. ::std::stringstream lhs_ss;
  14603. lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
  14604. << lhs_value;
  14605. ::std::stringstream rhs_ss;
  14606. rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
  14607. << rhs_value;
  14608. return EqFailure(lhs_expression,
  14609. rhs_expression,
  14610. StringStreamToString(&lhs_ss),
  14611. StringStreamToString(&rhs_ss),
  14612. false);
  14613. }
  14614. // Helper function for implementing ASSERT_NEAR.
  14615. //
  14616. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
  14617. GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
  14618. const char* expr2,
  14619. const char* abs_error_expr,
  14620. double val1,
  14621. double val2,
  14622. double abs_error);
  14623. // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
  14624. // A class that enables one to stream messages to assertion macros
  14625. class GTEST_API_ AssertHelper {
  14626. public:
  14627. // Constructor.
  14628. AssertHelper(TestPartResult::Type type,
  14629. const char* file,
  14630. int line,
  14631. const char* message);
  14632. ~AssertHelper();
  14633. // Message assignment is a semantic trick to enable assertion
  14634. // streaming; see the GTEST_MESSAGE_ macro below.
  14635. void operator=(const Message& message) const;
  14636. private:
  14637. // We put our data in a struct so that the size of the AssertHelper class can
  14638. // be as small as possible. This is important because gcc is incapable of
  14639. // re-using stack space even for temporary variables, so every EXPECT_EQ
  14640. // reserves stack space for another AssertHelper.
  14641. struct AssertHelperData {
  14642. AssertHelperData(TestPartResult::Type t,
  14643. const char* srcfile,
  14644. int line_num,
  14645. const char* msg)
  14646. : type(t), file(srcfile), line(line_num), message(msg) { }
  14647. TestPartResult::Type const type;
  14648. const char* const file;
  14649. int const line;
  14650. std::string const message;
  14651. private:
  14652. GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
  14653. };
  14654. AssertHelperData* const data_;
  14655. GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
  14656. };
  14657. enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW };
  14658. GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color,
  14659. const char* fmt,
  14660. ...);
  14661. } // namespace internal
  14662. // The pure interface class that all value-parameterized tests inherit from.
  14663. // A value-parameterized class must inherit from both ::testing::Test and
  14664. // ::testing::WithParamInterface. In most cases that just means inheriting
  14665. // from ::testing::TestWithParam, but more complicated test hierarchies
  14666. // may need to inherit from Test and WithParamInterface at different levels.
  14667. //
  14668. // This interface has support for accessing the test parameter value via
  14669. // the GetParam() method.
  14670. //
  14671. // Use it with one of the parameter generator defining functions, like Range(),
  14672. // Values(), ValuesIn(), Bool(), and Combine().
  14673. //
  14674. // class FooTest : public ::testing::TestWithParam<int> {
  14675. // protected:
  14676. // FooTest() {
  14677. // // Can use GetParam() here.
  14678. // }
  14679. // virtual ~FooTest() {
  14680. // // Can use GetParam() here.
  14681. // }
  14682. // virtual void SetUp() {
  14683. // // Can use GetParam() here.
  14684. // }
  14685. // virtual void TearDown {
  14686. // // Can use GetParam() here.
  14687. // }
  14688. // };
  14689. // TEST_P(FooTest, DoesBar) {
  14690. // // Can use GetParam() method here.
  14691. // Foo foo;
  14692. // ASSERT_TRUE(foo.DoesBar(GetParam()));
  14693. // }
  14694. // INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));
  14695. template <typename T>
  14696. class WithParamInterface {
  14697. public:
  14698. typedef T ParamType;
  14699. virtual ~WithParamInterface() {}
  14700. // The current parameter value. Is also available in the test fixture's
  14701. // constructor.
  14702. static const ParamType& GetParam() {
  14703. GTEST_CHECK_(parameter_ != nullptr)
  14704. << "GetParam() can only be called inside a value-parameterized test "
  14705. << "-- did you intend to write TEST_P instead of TEST_F?";
  14706. return *parameter_;
  14707. }
  14708. private:
  14709. // Sets parameter value. The caller is responsible for making sure the value
  14710. // remains alive and unchanged throughout the current test.
  14711. static void SetParam(const ParamType* parameter) {
  14712. parameter_ = parameter;
  14713. }
  14714. // Static value used for accessing parameter during a test lifetime.
  14715. static const ParamType* parameter_;
  14716. // TestClass must be a subclass of WithParamInterface<T> and Test.
  14717. template <class TestClass> friend class internal::ParameterizedTestFactory;
  14718. };
  14719. template <typename T>
  14720. const T* WithParamInterface<T>::parameter_ = nullptr;
  14721. // Most value-parameterized classes can ignore the existence of
  14722. // WithParamInterface, and can just inherit from ::testing::TestWithParam.
  14723. template <typename T>
  14724. class TestWithParam : public Test, public WithParamInterface<T> {
  14725. };
  14726. // Macros for indicating success/failure in test code.
  14727. // Skips test in runtime.
  14728. // Skipping test aborts current function.
  14729. // Skipped tests are neither successful nor failed.
  14730. #define GTEST_SKIP() GTEST_SKIP_("Skipped")
  14731. // ADD_FAILURE unconditionally adds a failure to the current test.
  14732. // SUCCEED generates a success - it doesn't automatically make the
  14733. // current test successful, as a test is only successful when it has
  14734. // no failure.
  14735. //
  14736. // EXPECT_* verifies that a certain condition is satisfied. If not,
  14737. // it behaves like ADD_FAILURE. In particular:
  14738. //
  14739. // EXPECT_TRUE verifies that a Boolean condition is true.
  14740. // EXPECT_FALSE verifies that a Boolean condition is false.
  14741. //
  14742. // FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except
  14743. // that they will also abort the current function on failure. People
  14744. // usually want the fail-fast behavior of FAIL and ASSERT_*, but those
  14745. // writing data-driven tests often find themselves using ADD_FAILURE
  14746. // and EXPECT_* more.
  14747. // Generates a nonfatal failure with a generic message.
  14748. #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
  14749. // Generates a nonfatal failure at the given source file location with
  14750. // a generic message.
  14751. #define ADD_FAILURE_AT(file, line) \
  14752. GTEST_MESSAGE_AT_(file, line, "Failed", \
  14753. ::testing::TestPartResult::kNonFatalFailure)
  14754. // Generates a fatal failure with a generic message.
  14755. #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
  14756. // Define this macro to 1 to omit the definition of FAIL(), which is a
  14757. // generic name and clashes with some other libraries.
  14758. #if !GTEST_DONT_DEFINE_FAIL
  14759. # define FAIL() GTEST_FAIL()
  14760. #endif
  14761. // Generates a success with a generic message.
  14762. #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
  14763. // Define this macro to 1 to omit the definition of SUCCEED(), which
  14764. // is a generic name and clashes with some other libraries.
  14765. #if !GTEST_DONT_DEFINE_SUCCEED
  14766. # define SUCCEED() GTEST_SUCCEED()
  14767. #endif
  14768. // Macros for testing exceptions.
  14769. //
  14770. // * {ASSERT|EXPECT}_THROW(statement, expected_exception):
  14771. // Tests that the statement throws the expected exception.
  14772. // * {ASSERT|EXPECT}_NO_THROW(statement):
  14773. // Tests that the statement doesn't throw any exception.
  14774. // * {ASSERT|EXPECT}_ANY_THROW(statement):
  14775. // Tests that the statement throws an exception.
  14776. #define EXPECT_THROW(statement, expected_exception) \
  14777. GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
  14778. #define EXPECT_NO_THROW(statement) \
  14779. GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
  14780. #define EXPECT_ANY_THROW(statement) \
  14781. GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
  14782. #define ASSERT_THROW(statement, expected_exception) \
  14783. GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
  14784. #define ASSERT_NO_THROW(statement) \
  14785. GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
  14786. #define ASSERT_ANY_THROW(statement) \
  14787. GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
  14788. // Boolean assertions. Condition can be either a Boolean expression or an
  14789. // AssertionResult. For more information on how to use AssertionResult with
  14790. // these macros see comments on that class.
  14791. #define EXPECT_TRUE(condition) \
  14792. GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
  14793. GTEST_NONFATAL_FAILURE_)
  14794. #define EXPECT_FALSE(condition) \
  14795. GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
  14796. GTEST_NONFATAL_FAILURE_)
  14797. #define ASSERT_TRUE(condition) \
  14798. GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
  14799. GTEST_FATAL_FAILURE_)
  14800. #define ASSERT_FALSE(condition) \
  14801. GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
  14802. GTEST_FATAL_FAILURE_)
  14803. // Macros for testing equalities and inequalities.
  14804. //
  14805. // * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
  14806. // * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
  14807. // * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
  14808. // * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
  14809. // * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
  14810. // * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
  14811. //
  14812. // When they are not, Google Test prints both the tested expressions and
  14813. // their actual values. The values must be compatible built-in types,
  14814. // or you will get a compiler error. By "compatible" we mean that the
  14815. // values can be compared by the respective operator.
  14816. //
  14817. // Note:
  14818. //
  14819. // 1. It is possible to make a user-defined type work with
  14820. // {ASSERT|EXPECT}_??(), but that requires overloading the
  14821. // comparison operators and is thus discouraged by the Google C++
  14822. // Usage Guide. Therefore, you are advised to use the
  14823. // {ASSERT|EXPECT}_TRUE() macro to assert that two objects are
  14824. // equal.
  14825. //
  14826. // 2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on
  14827. // pointers (in particular, C strings). Therefore, if you use it
  14828. // with two C strings, you are testing how their locations in memory
  14829. // are related, not how their content is related. To compare two C
  14830. // strings by content, use {ASSERT|EXPECT}_STR*().
  14831. //
  14832. // 3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to
  14833. // {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you
  14834. // what the actual value is when it fails, and similarly for the
  14835. // other comparisons.
  14836. //
  14837. // 4. Do not depend on the order in which {ASSERT|EXPECT}_??()
  14838. // evaluate their arguments, which is undefined.
  14839. //
  14840. // 5. These macros evaluate their arguments exactly once.
  14841. //
  14842. // Examples:
  14843. //
  14844. // EXPECT_NE(Foo(), 5);
  14845. // EXPECT_EQ(a_pointer, NULL);
  14846. // ASSERT_LT(i, array_size);
  14847. // ASSERT_GT(records.size(), 0) << "There is no record left.";
  14848. #define EXPECT_EQ(val1, val2) \
  14849. EXPECT_PRED_FORMAT2(::testing::internal:: \
  14850. EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
  14851. val1, val2)
  14852. #define EXPECT_NE(val1, val2) \
  14853. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
  14854. #define EXPECT_LE(val1, val2) \
  14855. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
  14856. #define EXPECT_LT(val1, val2) \
  14857. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
  14858. #define EXPECT_GE(val1, val2) \
  14859. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
  14860. #define EXPECT_GT(val1, val2) \
  14861. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
  14862. #define GTEST_ASSERT_EQ(val1, val2) \
  14863. ASSERT_PRED_FORMAT2(::testing::internal:: \
  14864. EqHelper<GTEST_IS_NULL_LITERAL_(val1)>::Compare, \
  14865. val1, val2)
  14866. #define GTEST_ASSERT_NE(val1, val2) \
  14867. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
  14868. #define GTEST_ASSERT_LE(val1, val2) \
  14869. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
  14870. #define GTEST_ASSERT_LT(val1, val2) \
  14871. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
  14872. #define GTEST_ASSERT_GE(val1, val2) \
  14873. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
  14874. #define GTEST_ASSERT_GT(val1, val2) \
  14875. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
  14876. // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
  14877. // ASSERT_XY(), which clashes with some users' own code.
  14878. #if !GTEST_DONT_DEFINE_ASSERT_EQ
  14879. # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
  14880. #endif
  14881. #if !GTEST_DONT_DEFINE_ASSERT_NE
  14882. # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
  14883. #endif
  14884. #if !GTEST_DONT_DEFINE_ASSERT_LE
  14885. # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
  14886. #endif
  14887. #if !GTEST_DONT_DEFINE_ASSERT_LT
  14888. # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
  14889. #endif
  14890. #if !GTEST_DONT_DEFINE_ASSERT_GE
  14891. # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
  14892. #endif
  14893. #if !GTEST_DONT_DEFINE_ASSERT_GT
  14894. # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
  14895. #endif
  14896. // C-string Comparisons. All tests treat NULL and any non-NULL string
  14897. // as different. Two NULLs are equal.
  14898. //
  14899. // * {ASSERT|EXPECT}_STREQ(s1, s2): Tests that s1 == s2
  14900. // * {ASSERT|EXPECT}_STRNE(s1, s2): Tests that s1 != s2
  14901. // * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case
  14902. // * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case
  14903. //
  14904. // For wide or narrow string objects, you can use the
  14905. // {ASSERT|EXPECT}_??() macros.
  14906. //
  14907. // Don't depend on the order in which the arguments are evaluated,
  14908. // which is undefined.
  14909. //
  14910. // These macros evaluate their arguments exactly once.
  14911. #define EXPECT_STREQ(s1, s2) \
  14912. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
  14913. #define EXPECT_STRNE(s1, s2) \
  14914. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
  14915. #define EXPECT_STRCASEEQ(s1, s2) \
  14916. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
  14917. #define EXPECT_STRCASENE(s1, s2)\
  14918. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
  14919. #define ASSERT_STREQ(s1, s2) \
  14920. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
  14921. #define ASSERT_STRNE(s1, s2) \
  14922. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
  14923. #define ASSERT_STRCASEEQ(s1, s2) \
  14924. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
  14925. #define ASSERT_STRCASENE(s1, s2)\
  14926. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
  14927. // Macros for comparing floating-point numbers.
  14928. //
  14929. // * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):
  14930. // Tests that two float values are almost equal.
  14931. // * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):
  14932. // Tests that two double values are almost equal.
  14933. // * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):
  14934. // Tests that v1 and v2 are within the given distance to each other.
  14935. //
  14936. // Google Test uses ULP-based comparison to automatically pick a default
  14937. // error bound that is appropriate for the operands. See the
  14938. // FloatingPoint template class in gtest-internal.h if you are
  14939. // interested in the implementation details.
  14940. #define EXPECT_FLOAT_EQ(val1, val2)\
  14941. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
  14942. val1, val2)
  14943. #define EXPECT_DOUBLE_EQ(val1, val2)\
  14944. EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
  14945. val1, val2)
  14946. #define ASSERT_FLOAT_EQ(val1, val2)\
  14947. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
  14948. val1, val2)
  14949. #define ASSERT_DOUBLE_EQ(val1, val2)\
  14950. ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
  14951. val1, val2)
  14952. #define EXPECT_NEAR(val1, val2, abs_error)\
  14953. EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
  14954. val1, val2, abs_error)
  14955. #define ASSERT_NEAR(val1, val2, abs_error)\
  14956. ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
  14957. val1, val2, abs_error)
  14958. // These predicate format functions work on floating-point values, and
  14959. // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.
  14960. //
  14961. // EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);
  14962. // Asserts that val1 is less than, or almost equal to, val2. Fails
  14963. // otherwise. In particular, it fails if either val1 or val2 is NaN.
  14964. GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
  14965. float val1, float val2);
  14966. GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
  14967. double val1, double val2);
  14968. #if GTEST_OS_WINDOWS
  14969. // Macros that test for HRESULT failure and success, these are only useful
  14970. // on Windows, and rely on Windows SDK macros and APIs to compile.
  14971. //
  14972. // * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)
  14973. //
  14974. // When expr unexpectedly fails or succeeds, Google Test prints the
  14975. // expected result and the actual result with both a human-readable
  14976. // string representation of the error, if available, as well as the
  14977. // hex result code.
  14978. # define EXPECT_HRESULT_SUCCEEDED(expr) \
  14979. EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
  14980. # define ASSERT_HRESULT_SUCCEEDED(expr) \
  14981. ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
  14982. # define EXPECT_HRESULT_FAILED(expr) \
  14983. EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
  14984. # define ASSERT_HRESULT_FAILED(expr) \
  14985. ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
  14986. #endif // GTEST_OS_WINDOWS
  14987. // Macros that execute statement and check that it doesn't generate new fatal
  14988. // failures in the current thread.
  14989. //
  14990. // * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);
  14991. //
  14992. // Examples:
  14993. //
  14994. // EXPECT_NO_FATAL_FAILURE(Process());
  14995. // ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed";
  14996. //
  14997. #define ASSERT_NO_FATAL_FAILURE(statement) \
  14998. GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
  14999. #define EXPECT_NO_FATAL_FAILURE(statement) \
  15000. GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
  15001. // Causes a trace (including the given source file path and line number,
  15002. // and the given message) to be included in every test failure message generated
  15003. // by code in the scope of the lifetime of an instance of this class. The effect
  15004. // is undone with the destruction of the instance.
  15005. //
  15006. // The message argument can be anything streamable to std::ostream.
  15007. //
  15008. // Example:
  15009. // testing::ScopedTrace trace("file.cc", 123, "message");
  15010. //
  15011. class GTEST_API_ ScopedTrace {
  15012. public:
  15013. // The c'tor pushes the given source file location and message onto
  15014. // a trace stack maintained by Google Test.
  15015. // Template version. Uses Message() to convert the values into strings.
  15016. // Slow, but flexible.
  15017. template <typename T>
  15018. ScopedTrace(const char* file, int line, const T& message) {
  15019. PushTrace(file, line, (Message() << message).GetString());
  15020. }
  15021. // Optimize for some known types.
  15022. ScopedTrace(const char* file, int line, const char* message) {
  15023. PushTrace(file, line, message ? message : "(null)");
  15024. }
  15025. #if GTEST_HAS_GLOBAL_STRING
  15026. ScopedTrace(const char* file, int line, const ::string& message) {
  15027. PushTrace(file, line, message);
  15028. }
  15029. #endif
  15030. ScopedTrace(const char* file, int line, const std::string& message) {
  15031. PushTrace(file, line, message);
  15032. }
  15033. // The d'tor pops the info pushed by the c'tor.
  15034. //
  15035. // Note that the d'tor is not virtual in order to be efficient.
  15036. // Don't inherit from ScopedTrace!
  15037. ~ScopedTrace();
  15038. private:
  15039. void PushTrace(const char* file, int line, std::string message);
  15040. GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
  15041. } GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its
  15042. // c'tor and d'tor. Therefore it doesn't
  15043. // need to be used otherwise.
  15044. // Causes a trace (including the source file path, the current line
  15045. // number, and the given message) to be included in every test failure
  15046. // message generated by code in the current scope. The effect is
  15047. // undone when the control leaves the current scope.
  15048. //
  15049. // The message argument can be anything streamable to std::ostream.
  15050. //
  15051. // In the implementation, we include the current line number as part
  15052. // of the dummy variable name, thus allowing multiple SCOPED_TRACE()s
  15053. // to appear in the same block - as long as they are on different
  15054. // lines.
  15055. //
  15056. // Assuming that each thread maintains its own stack of traces.
  15057. // Therefore, a SCOPED_TRACE() would (correctly) only affect the
  15058. // assertions in its own thread.
  15059. #define SCOPED_TRACE(message) \
  15060. ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
  15061. __FILE__, __LINE__, (message))
  15062. // Compile-time assertion for type equality.
  15063. // StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are
  15064. // the same type. The value it returns is not interesting.
  15065. //
  15066. // Instead of making StaticAssertTypeEq a class template, we make it a
  15067. // function template that invokes a helper class template. This
  15068. // prevents a user from misusing StaticAssertTypeEq<T1, T2> by
  15069. // defining objects of that type.
  15070. //
  15071. // CAVEAT:
  15072. //
  15073. // When used inside a method of a class template,
  15074. // StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is
  15075. // instantiated. For example, given:
  15076. //
  15077. // template <typename T> class Foo {
  15078. // public:
  15079. // void Bar() { testing::StaticAssertTypeEq<int, T>(); }
  15080. // };
  15081. //
  15082. // the code:
  15083. //
  15084. // void Test1() { Foo<bool> foo; }
  15085. //
  15086. // will NOT generate a compiler error, as Foo<bool>::Bar() is never
  15087. // actually instantiated. Instead, you need:
  15088. //
  15089. // void Test2() { Foo<bool> foo; foo.Bar(); }
  15090. //
  15091. // to cause a compiler error.
  15092. template <typename T1, typename T2>
  15093. bool StaticAssertTypeEq() {
  15094. (void)internal::StaticAssertTypeEqHelper<T1, T2>();
  15095. return true;
  15096. }
  15097. // Defines a test.
  15098. //
  15099. // The first parameter is the name of the test suite, and the second
  15100. // parameter is the name of the test within the test suite.
  15101. //
  15102. // The convention is to end the test suite name with "Test". For
  15103. // example, a test suite for the Foo class can be named FooTest.
  15104. //
  15105. // Test code should appear between braces after an invocation of
  15106. // this macro. Example:
  15107. //
  15108. // TEST(FooTest, InitializesCorrectly) {
  15109. // Foo foo;
  15110. // EXPECT_TRUE(foo.StatusIsOK());
  15111. // }
  15112. // Note that we call GetTestTypeId() instead of GetTypeId<
  15113. // ::testing::Test>() here to get the type ID of testing::Test. This
  15114. // is to work around a suspected linker bug when using Google Test as
  15115. // a framework on Mac OS X. The bug causes GetTypeId<
  15116. // ::testing::Test>() to return different values depending on whether
  15117. // the call is from the Google Test framework itself or from user test
  15118. // code. GetTestTypeId() is guaranteed to always return the same
  15119. // value, as it always calls GetTypeId<>() from the Google Test
  15120. // framework.
  15121. #define GTEST_TEST(test_suite_name, test_name) \
  15122. GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
  15123. ::testing::internal::GetTestTypeId())
  15124. // Define this macro to 1 to omit the definition of TEST(), which
  15125. // is a generic name and clashes with some other libraries.
  15126. #if !GTEST_DONT_DEFINE_TEST
  15127. #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
  15128. #endif
  15129. // Defines a test that uses a test fixture.
  15130. //
  15131. // The first parameter is the name of the test fixture class, which
  15132. // also doubles as the test suite name. The second parameter is the
  15133. // name of the test within the test suite.
  15134. //
  15135. // A test fixture class must be declared earlier. The user should put
  15136. // the test code between braces after using this macro. Example:
  15137. //
  15138. // class FooTest : public testing::Test {
  15139. // protected:
  15140. // virtual void SetUp() { b_.AddElement(3); }
  15141. //
  15142. // Foo a_;
  15143. // Foo b_;
  15144. // };
  15145. //
  15146. // TEST_F(FooTest, InitializesCorrectly) {
  15147. // EXPECT_TRUE(a_.StatusIsOK());
  15148. // }
  15149. //
  15150. // TEST_F(FooTest, ReturnsElementCountCorrectly) {
  15151. // EXPECT_EQ(a_.size(), 0);
  15152. // EXPECT_EQ(b_.size(), 1);
  15153. // }
  15154. #define TEST_F(test_fixture, test_name)\
  15155. GTEST_TEST_(test_fixture, test_name, test_fixture, \
  15156. ::testing::internal::GetTypeId<test_fixture>())
  15157. // Returns a path to temporary directory.
  15158. // Tries to determine an appropriate directory for the platform.
  15159. GTEST_API_ std::string TempDir();
  15160. #ifdef _MSC_VER
  15161. # pragma warning(pop)
  15162. #endif
  15163. // Dynamically registers a test with the framework.
  15164. //
  15165. // This is an advanced API only to be used when the `TEST` macros are
  15166. // insufficient. The macros should be preferred when possible, as they avoid
  15167. // most of the complexity of calling this function.
  15168. //
  15169. // The `factory` argument is a factory callable (move-constructible) object or
  15170. // function pointer that creates a new instance of the Test object. It
  15171. // handles ownership to the caller. The signature of the callable is
  15172. // `Fixture*()`, where `Fixture` is the test fixture class for the test. All
  15173. // tests registered with the same `test_suite_name` must return the same
  15174. // fixture type. This is checked at runtime.
  15175. //
  15176. // The framework will infer the fixture class from the factory and will call
  15177. // the `SetUpTestSuite` and `TearDownTestSuite` for it.
  15178. //
  15179. // Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is
  15180. // undefined.
  15181. //
  15182. // Use case example:
  15183. //
  15184. // class MyFixture : public ::testing::Test {
  15185. // public:
  15186. // // All of these optional, just like in regular macro usage.
  15187. // static void SetUpTestSuite() { ... }
  15188. // static void TearDownTestSuite() { ... }
  15189. // void SetUp() override { ... }
  15190. // void TearDown() override { ... }
  15191. // };
  15192. //
  15193. // class MyTest : public MyFixture {
  15194. // public:
  15195. // explicit MyTest(int data) : data_(data) {}
  15196. // void TestBody() override { ... }
  15197. //
  15198. // private:
  15199. // int data_;
  15200. // };
  15201. //
  15202. // void RegisterMyTests(const std::vector<int>& values) {
  15203. // for (int v : values) {
  15204. // ::testing::RegisterTest(
  15205. // "MyFixture", ("Test" + std::to_string(v)).c_str(), nullptr,
  15206. // std::to_string(v).c_str(),
  15207. // __FILE__, __LINE__,
  15208. // // Important to use the fixture type as the return type here.
  15209. // [=]() -> MyFixture* { return new MyTest(v); });
  15210. // }
  15211. // }
  15212. // ...
  15213. // int main(int argc, char** argv) {
  15214. // std::vector<int> values_to_test = LoadValuesFromConfig();
  15215. // RegisterMyTests(values_to_test);
  15216. // ...
  15217. // return RUN_ALL_TESTS();
  15218. // }
  15219. //
  15220. template <int&... ExplicitParameterBarrier, typename Factory>
  15221. TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
  15222. const char* type_param, const char* value_param,
  15223. const char* file, int line, Factory factory) {
  15224. using TestT = typename std::remove_pointer<decltype(factory())>::type;
  15225. class FactoryImpl : public internal::TestFactoryBase {
  15226. public:
  15227. explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
  15228. Test* CreateTest() override { return factory_(); }
  15229. private:
  15230. Factory factory_;
  15231. };
  15232. return internal::MakeAndRegisterTestInfo(
  15233. test_suite_name, test_name, type_param, value_param,
  15234. internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),
  15235. internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(),
  15236. internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(),
  15237. new FactoryImpl{std::move(factory)});
  15238. }
  15239. } // namespace testing
  15240. // Use this function in main() to run all tests. It returns 0 if all
  15241. // tests are successful, or 1 otherwise.
  15242. //
  15243. // RUN_ALL_TESTS() should be invoked after the command line has been
  15244. // parsed by InitGoogleTest().
  15245. //
  15246. // This function was formerly a macro; thus, it is in the global
  15247. // namespace and has an all-caps name.
  15248. int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
  15249. inline int RUN_ALL_TESTS() {
  15250. return ::testing::UnitTest::GetInstance()->Run();
  15251. }
  15252. GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
  15253. #endif // GTEST_INCLUDE_GTEST_GTEST_H_