1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377 |
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
- #include <cstddef>
- #include <limits>
- #include <memory>
- #include <ostream>
- #include <type_traits>
- #include <vector>
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
- #include <ctype.h> // for isspace, etc
- #include <stddef.h> // for ptrdiff_t
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <cerrno>
- #include <cstdint>
- #include <limits>
- #include <type_traits>
- #ifndef _WIN32_WCE
- # include <sys/types.h>
- # include <sys/stat.h>
- #endif
- #if defined __APPLE__
- # include <AvailabilityMacros.h>
- # include <TargetConditionals.h>
- #endif
- #include <iostream> // NOLINT
- #include <locale>
- #include <memory>
- #include <string> // NOLINT
- #include <tuple>
- #include <vector> // NOLINT
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
- #ifdef __CYGWIN__
- # define GTEST_OS_CYGWIN 1
- # elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
- # define GTEST_OS_WINDOWS_MINGW 1
- # define GTEST_OS_WINDOWS 1
- #elif defined _WIN32
- # define GTEST_OS_WINDOWS 1
- # ifdef _WIN32_WCE
- # define GTEST_OS_WINDOWS_MOBILE 1
- # elif defined(WINAPI_FAMILY)
- # include <winapifamily.h>
- # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
- # define GTEST_OS_WINDOWS_DESKTOP 1
- # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
- # define GTEST_OS_WINDOWS_PHONE 1
- # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
- # define GTEST_OS_WINDOWS_RT 1
- # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
- # define GTEST_OS_WINDOWS_PHONE 1
- # define GTEST_OS_WINDOWS_TV_TITLE 1
- # else
-
-
- # define GTEST_OS_WINDOWS_DESKTOP 1
- # endif
- # else
- # define GTEST_OS_WINDOWS_DESKTOP 1
- # endif
- #elif defined __OS2__
- # define GTEST_OS_OS2 1
- #elif defined __APPLE__
- # define GTEST_OS_MAC 1
- # include <TargetConditionals.h>
- # if TARGET_OS_IPHONE
- # define GTEST_OS_IOS 1
- # endif
- #elif defined __DragonFly__
- # define GTEST_OS_DRAGONFLY 1
- #elif defined __FreeBSD__
- # define GTEST_OS_FREEBSD 1
- #elif defined __Fuchsia__
- # define GTEST_OS_FUCHSIA 1
- #elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
- # define GTEST_OS_GNU_KFREEBSD 1
- #elif defined __linux__
- # define GTEST_OS_LINUX 1
- # if defined __ANDROID__
- # define GTEST_OS_LINUX_ANDROID 1
- # endif
- #elif defined __MVS__
- # define GTEST_OS_ZOS 1
- #elif defined(__sun) && defined(__SVR4)
- # define GTEST_OS_SOLARIS 1
- #elif defined(_AIX)
- # define GTEST_OS_AIX 1
- #elif defined(__hpux)
- # define GTEST_OS_HPUX 1
- #elif defined __native_client__
- # define GTEST_OS_NACL 1
- #elif defined __NetBSD__
- # define GTEST_OS_NETBSD 1
- #elif defined __OpenBSD__
- # define GTEST_OS_OPENBSD 1
- #elif defined __QNX__
- # define GTEST_OS_QNX 1
- #elif defined(__HAIKU__)
- #define GTEST_OS_HAIKU 1
- #elif defined ESP8266
- #define GTEST_OS_ESP8266 1
- #elif defined ESP32
- #define GTEST_OS_ESP32 1
- #elif defined(__XTENSA__)
- #define GTEST_OS_XTENSA 1
- #endif
- #endif
- #if !defined(GTEST_DEV_EMAIL_)
- # define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
- # define GTEST_FLAG_PREFIX_ "gtest_"
- # define GTEST_FLAG_PREFIX_DASH_ "gtest-"
- # define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
- # define GTEST_NAME_ "Google Test"
- # define GTEST_PROJECT_URL_ "https://github.com/google/googletest/"
- #endif
- #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)
- # define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest"
- #endif
- #ifdef __GNUC__
- # define GTEST_GCC_VER_ \
- (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
- #endif
- #if defined(_MSC_VER)
- # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
- __pragma(warning(push)) \
- __pragma(warning(disable: warnings))
- # define GTEST_DISABLE_MSC_WARNINGS_POP_() \
- __pragma(warning(pop))
- #else
- # define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
- # define GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- #ifdef __clang__
- # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
- _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
- #define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
- _Pragma("clang diagnostic pop")
- #else
- # define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
- # define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- #if GTEST_OS_WINDOWS
- # if !GTEST_OS_WINDOWS_MOBILE
- # include <direct.h>
- # include <io.h>
- # endif
- #if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
- typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
- #else
- typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
- #endif
- #elif GTEST_OS_XTENSA
- #include <unistd.h>
- #else
- # include <unistd.h>
- # include <strings.h>
- #endif
- #if GTEST_OS_LINUX_ANDROID
- # include <android/api-level.h> // NOLINT
- #endif
- #ifndef GTEST_HAS_POSIX_RE
- # if GTEST_OS_LINUX_ANDROID
- # define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
- # else
- #define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS && !GTEST_OS_XTENSA)
- # endif
- #endif
- #if GTEST_USES_PCRE
- #elif GTEST_HAS_POSIX_RE
- # include <regex.h> // NOLINT
- # define GTEST_USES_POSIX_RE 1
- #elif GTEST_OS_WINDOWS
- # define GTEST_USES_SIMPLE_RE 1
- #else
- # define GTEST_USES_SIMPLE_RE 1
- #endif
- #ifndef GTEST_HAS_EXCEPTIONS
- # if defined(_MSC_VER) && defined(_CPPUNWIND)
- # define GTEST_HAS_EXCEPTIONS 1
- # elif defined(__BORLANDC__)
- # ifndef _HAS_EXCEPTIONS
- # define _HAS_EXCEPTIONS 1
- # endif
- # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
- # elif defined(__clang__)
- # define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
- # elif defined(__GNUC__) && __EXCEPTIONS
- # define GTEST_HAS_EXCEPTIONS 1
- # elif defined(__SUNPRO_CC)
- # define GTEST_HAS_EXCEPTIONS 1
- # elif defined(__IBMCPP__) && __EXCEPTIONS
- # define GTEST_HAS_EXCEPTIONS 1
- # elif defined(__HP_aCC)
- # define GTEST_HAS_EXCEPTIONS 1
- # else
- # define GTEST_HAS_EXCEPTIONS 0
- # endif
- #endif
- #ifndef GTEST_HAS_STD_WSTRING
- #define GTEST_HAS_STD_WSTRING \
- (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
- GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || GTEST_OS_XTENSA))
- #endif
- #ifndef GTEST_HAS_RTTI
- # ifdef _MSC_VER
- #ifdef _CPPRTTI
- # define GTEST_HAS_RTTI 1
- # else
- # define GTEST_HAS_RTTI 0
- # endif
- # elif defined(__GNUC__)
- # ifdef __GXX_RTTI
- # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
- !defined(__EXCEPTIONS)
- # define GTEST_HAS_RTTI 0
- # else
- # define GTEST_HAS_RTTI 1
- # endif
- # else
- # define GTEST_HAS_RTTI 0
- # endif
- # elif defined(__clang__)
- # define GTEST_HAS_RTTI __has_feature(cxx_rtti)
- # elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
- # ifdef __RTTI_ALL__
- # define GTEST_HAS_RTTI 1
- # else
- # define GTEST_HAS_RTTI 0
- # endif
- # else
- # define GTEST_HAS_RTTI 1
- # endif
- #endif
- #if GTEST_HAS_RTTI
- # include <typeinfo>
- #endif
- #ifndef GTEST_HAS_PTHREAD
- #define GTEST_HAS_PTHREAD \
- (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
- GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
- GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \
- GTEST_OS_HAIKU)
- #endif
- #if GTEST_HAS_PTHREAD
- # include <pthread.h> // NOLINT
- # include <time.h> // NOLINT
- #endif
- #ifndef GTEST_HAS_CLONE
- # if GTEST_OS_LINUX && !defined(__ia64__)
- # if GTEST_OS_LINUX_ANDROID
- # if defined(__LP64__) || \
- (defined(__arm__) && __ANDROID_API__ >= 9) || \
- (defined(__mips__) && __ANDROID_API__ >= 12) || \
- (defined(__i386__) && __ANDROID_API__ >= 17)
- # define GTEST_HAS_CLONE 1
- # else
- # define GTEST_HAS_CLONE 0
- # endif
- # else
- # define GTEST_HAS_CLONE 1
- # endif
- # else
- # define GTEST_HAS_CLONE 0
- # endif
- #endif
- #ifndef GTEST_HAS_STREAM_REDIRECTION
- #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
- GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA
- # define GTEST_HAS_STREAM_REDIRECTION 0
- # else
- # define GTEST_HAS_STREAM_REDIRECTION 1
- # endif
- #endif
- #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
- (GTEST_OS_MAC && !GTEST_OS_IOS) || \
- (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW || \
- GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \
- GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
- GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU)
- # define GTEST_HAS_DEATH_TEST 1
- #endif
- #if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \
- defined(__IBMCPP__) || defined(__HP_aCC)
- # define GTEST_HAS_TYPED_TEST 1
- # define GTEST_HAS_TYPED_TEST_P 1
- #endif
- #define GTEST_WIDE_STRING_USES_UTF16_ \
- (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)
- #if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \
- GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
- # define GTEST_CAN_STREAM_RESULTS_ 1
- #endif
- #ifdef __INTEL_COMPILER
- # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
- #else
- # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:
- #endif
- #if defined(__GNUC__) && !defined(COMPILER_ICC)
- # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
- #elif defined(__clang__)
- # if __has_attribute(unused)
- # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
- # endif
- #endif
- #ifndef GTEST_ATTRIBUTE_UNUSED_
- # define GTEST_ATTRIBUTE_UNUSED_
- #endif
- #if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)
- # if defined(__MINGW_PRINTF_FORMAT)
- # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
- __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \
- first_to_check)))
- # else
- # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \
- __attribute__((__format__(__printf__, string_index, first_to_check)))
- # endif
- #else
- # define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
- #endif
- #define GTEST_DISALLOW_ASSIGN_(type) \
- type& operator=(type const &) = delete
- #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \
- type(type const&) = delete; \
- type& operator=(type const&) = delete
- #define GTEST_DISALLOW_MOVE_ASSIGN_(type) \
- type& operator=(type &&) noexcept = delete
- #define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \
- type(type&&) noexcept = delete; \
- type& operator=(type&&) noexcept = delete
- #if defined(__GNUC__) && !defined(COMPILER_ICC)
- # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
- #else
- # define GTEST_MUST_USE_RESULT_
- #endif
- # define GTEST_INTENTIONAL_CONST_COND_PUSH_() \
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)
- # define GTEST_INTENTIONAL_CONST_COND_POP_() \
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #ifndef GTEST_HAS_SEH
- # if defined(_MSC_VER) || defined(__BORLANDC__)
- # define GTEST_HAS_SEH 1
- # else
- # define GTEST_HAS_SEH 0
- # endif
- #endif
- #ifndef GTEST_IS_THREADSAFE
- #define GTEST_IS_THREADSAFE \
- (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \
- (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \
- GTEST_HAS_PTHREAD)
- #endif
- #ifndef GTEST_API_
- #ifdef _MSC_VER
- # if GTEST_LINKED_AS_SHARED_LIBRARY
- # define GTEST_API_ __declspec(dllimport)
- # elif GTEST_CREATE_SHARED_LIBRARY
- # define GTEST_API_ __declspec(dllexport)
- # endif
- #elif __GNUC__ >= 4 || defined(__clang__)
- # define GTEST_API_ __attribute__((visibility ("default")))
- #endif
- #endif
- #ifndef GTEST_API_
- # define GTEST_API_
- #endif
- #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE
- # define GTEST_DEFAULT_DEATH_TEST_STYLE "fast"
- #endif
- #ifdef __GNUC__
- # define GTEST_NO_INLINE_ __attribute__((noinline))
- #else
- # define GTEST_NO_INLINE_
- #endif
- #if !defined(GTEST_HAS_CXXABI_H_)
- # if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))
- # define GTEST_HAS_CXXABI_H_ 1
- # else
- # define GTEST_HAS_CXXABI_H_ 0
- # endif
- #endif
- #if defined(__clang__)
- # if __has_feature(memory_sanitizer)
- # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \
- __attribute__((no_sanitize_memory))
- # else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
- # endif
- #else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
- #endif
- #if defined(__clang__)
- # if __has_feature(address_sanitizer)
- # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
- __attribute__((no_sanitize_address))
- # else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
- # endif
- #else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
- #endif
- #if defined(__clang__)
- # if __has_feature(hwaddress_sanitizer)
- # define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \
- __attribute__((no_sanitize("hwaddress")))
- # else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
- # endif
- #else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
- #endif
- #if defined(__clang__)
- # if __has_feature(thread_sanitizer)
- # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \
- __attribute__((no_sanitize_thread))
- # else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
- # endif
- #else
- # define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
- #endif
- namespace testing {
- class Message;
- using std::get;
- using std::make_tuple;
- using std::tuple;
- using std::tuple_element;
- using std::tuple_size;
- namespace internal {
- class Secret;
- #define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)
- GTEST_API_ bool IsTrue(bool condition);
- #if GTEST_USES_PCRE
- #elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
- class GTEST_API_ RE {
- public:
-
-
- RE(const RE& other) { Init(other.pattern()); }
-
- RE(const ::std::string& regex) { Init(regex.c_str()); }
- RE(const char* regex) { Init(regex); }
- ~RE();
-
- const char* pattern() const { return pattern_; }
-
-
-
-
- static bool FullMatch(const ::std::string& str, const RE& re) {
- return FullMatch(str.c_str(), re);
- }
- static bool PartialMatch(const ::std::string& str, const RE& re) {
- return PartialMatch(str.c_str(), re);
- }
- static bool FullMatch(const char* str, const RE& re);
- static bool PartialMatch(const char* str, const RE& re);
- private:
- void Init(const char* regex);
- const char* pattern_;
- bool is_valid_;
- # if GTEST_USES_POSIX_RE
- regex_t full_regex_;
- regex_t partial_regex_;
- # else
- const char* full_pattern_;
- # endif
- };
- #endif
- GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
- GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,
- int line);
- enum GTestLogSeverity {
- GTEST_INFO,
- GTEST_WARNING,
- GTEST_ERROR,
- GTEST_FATAL
- };
- class GTEST_API_ GTestLog {
- public:
- GTestLog(GTestLogSeverity severity, const char* file, int line);
-
- ~GTestLog();
- ::std::ostream& GetStream() { return ::std::cerr; }
- private:
- const GTestLogSeverity severity_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
- };
- #if !defined(GTEST_LOG_)
- # define GTEST_LOG_(severity) \
- ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
- __FILE__, __LINE__).GetStream()
- inline void LogToStderr() {}
- inline void FlushInfoLog() { fflush(nullptr); }
- #endif
- #if !defined(GTEST_CHECK_)
- # define GTEST_CHECK_(condition) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::IsTrue(condition)) \
- ; \
- else \
- GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
- #endif
- #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
- if (const int gtest_error = (posix_call)) \
- GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
- << gtest_error
- template <typename T>
- struct ConstRef { typedef const T& type; };
- template <typename T>
- struct ConstRef<T&> { typedef T& type; };
- #define GTEST_REFERENCE_TO_CONST_(T) \
- typename ::testing::internal::ConstRef<T>::type
- template<typename To>
- inline To ImplicitCast_(To x) { return x; }
- template<typename To, typename From>
- inline To DownCast_(From* f) {
-
-
-
-
- GTEST_INTENTIONAL_CONST_COND_PUSH_()
- if (false) {
- GTEST_INTENTIONAL_CONST_COND_POP_()
- const To to = nullptr;
- ::testing::internal::ImplicitCast_<From*>(to);
- }
- #if GTEST_HAS_RTTI
-
- GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);
- #endif
- return static_cast<To>(f);
- }
- template <class Derived, class Base>
- Derived* CheckedDowncastToActualType(Base* base) {
- #if GTEST_HAS_RTTI
- GTEST_CHECK_(typeid(*base) == typeid(Derived));
- #endif
- #if GTEST_HAS_DOWNCAST_
- return ::down_cast<Derived*>(base);
- #elif GTEST_HAS_RTTI
- return dynamic_cast<Derived*>(base);
- #else
- return static_cast<Derived*>(base);
- #endif
- }
- #if GTEST_HAS_STREAM_REDIRECTION
- GTEST_API_ void CaptureStdout();
- GTEST_API_ std::string GetCapturedStdout();
- GTEST_API_ void CaptureStderr();
- GTEST_API_ std::string GetCapturedStderr();
- #endif
- GTEST_API_ size_t GetFileSize(FILE* file);
- GTEST_API_ std::string ReadEntireFile(FILE* file);
- GTEST_API_ std::vector<std::string> GetArgvs();
- #if GTEST_HAS_DEATH_TEST
- std::vector<std::string> GetInjectableArgvs();
- void SetInjectableArgvs(const std::vector<std::string>* new_argvs);
- void SetInjectableArgvs(const std::vector<std::string>& new_argvs);
- void ClearInjectableArgvs();
- #endif
- #if GTEST_IS_THREADSAFE
- # if GTEST_HAS_PTHREAD
- inline void SleepMilliseconds(int n) {
- const timespec time = {
- 0,
- n * 1000L * 1000L,
- };
- nanosleep(&time, nullptr);
- }
- # endif
- # if GTEST_HAS_NOTIFICATION_
- # elif GTEST_HAS_PTHREAD
- class Notification {
- public:
- Notification() : notified_(false) {
- GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
- }
- ~Notification() {
- pthread_mutex_destroy(&mutex_);
- }
-
-
- void Notify() {
- pthread_mutex_lock(&mutex_);
- notified_ = true;
- pthread_mutex_unlock(&mutex_);
- }
-
-
- void WaitForNotification() {
- for (;;) {
- pthread_mutex_lock(&mutex_);
- const bool notified = notified_;
- pthread_mutex_unlock(&mutex_);
- if (notified)
- break;
- SleepMilliseconds(10);
- }
- }
- private:
- pthread_mutex_t mutex_;
- bool notified_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
- };
- # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
- GTEST_API_ void SleepMilliseconds(int n);
- class GTEST_API_ AutoHandle {
- public:
-
-
-
-
-
- typedef void* Handle;
- AutoHandle();
- explicit AutoHandle(Handle handle);
- ~AutoHandle();
- Handle Get() const;
- void Reset();
- void Reset(Handle handle);
- private:
-
-
- bool IsCloseable() const;
- Handle handle_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
- };
- class GTEST_API_ Notification {
- public:
- Notification();
- void Notify();
- void WaitForNotification();
- private:
- AutoHandle event_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
- };
- # endif
- # if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW
- class ThreadWithParamBase {
- public:
- virtual ~ThreadWithParamBase() {}
- virtual void Run() = 0;
- };
- extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
- static_cast<ThreadWithParamBase*>(thread)->Run();
- return nullptr;
- }
- template <typename T>
- class ThreadWithParam : public ThreadWithParamBase {
- public:
- typedef void UserThreadFunc(T);
- ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
- : func_(func),
- param_(param),
- thread_can_start_(thread_can_start),
- finished_(false) {
- ThreadWithParamBase* const base = this;
-
-
- GTEST_CHECK_POSIX_SUCCESS_(
- pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));
- }
- ~ThreadWithParam() override { Join(); }
- void Join() {
- if (!finished_) {
- GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr));
- finished_ = true;
- }
- }
- void Run() override {
- if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();
- func_(param_);
- }
- private:
- UserThreadFunc* const func_;
- const T param_;
-
-
- Notification* const thread_can_start_;
- bool finished_;
-
- pthread_t thread_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
- };
- # endif
-
- # if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
- # elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
- class GTEST_API_ Mutex {
- public:
- enum MutexType { kStatic = 0, kDynamic = 1 };
-
-
-
- enum StaticConstructorSelector { kStaticMutex = 0 };
-
-
-
- explicit Mutex(StaticConstructorSelector ) {}
- Mutex();
- ~Mutex();
- void Lock();
- void Unlock();
-
-
- void AssertHeld();
- private:
-
- void ThreadSafeLazyInit();
-
-
- unsigned int owner_thread_id_;
-
-
- MutexType type_;
- long critical_section_init_phase_;
- GTEST_CRITICAL_SECTION* critical_section_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
- };
- # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
- extern ::testing::internal::Mutex mutex
- # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
- ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)
- class GTestMutexLock {
- public:
- explicit GTestMutexLock(Mutex* mutex)
- : mutex_(mutex) { mutex_->Lock(); }
- ~GTestMutexLock() { mutex_->Unlock(); }
- private:
- Mutex* const mutex_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
- };
- typedef GTestMutexLock MutexLock;
- class ThreadLocalValueHolderBase {
- public:
- virtual ~ThreadLocalValueHolderBase() {}
- };
- class ThreadLocalBase {
- public:
-
-
-
-
- virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;
- protected:
- ThreadLocalBase() {}
- virtual ~ThreadLocalBase() {}
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);
- };
- class GTEST_API_ ThreadLocalRegistry {
- public:
-
-
- static ThreadLocalValueHolderBase* GetValueOnCurrentThread(
- const ThreadLocalBase* thread_local_instance);
-
- static void OnThreadLocalDestroyed(
- const ThreadLocalBase* thread_local_instance);
- };
- class GTEST_API_ ThreadWithParamBase {
- public:
- void Join();
- protected:
- class Runnable {
- public:
- virtual ~Runnable() {}
- virtual void Run() = 0;
- };
- ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);
- virtual ~ThreadWithParamBase();
- private:
- AutoHandle thread_;
- };
- template <typename T>
- class ThreadWithParam : public ThreadWithParamBase {
- public:
- typedef void UserThreadFunc(T);
- ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)
- : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {
- }
- virtual ~ThreadWithParam() {}
- private:
- class RunnableImpl : public Runnable {
- public:
- RunnableImpl(UserThreadFunc* func, T param)
- : func_(func),
- param_(param) {
- }
- virtual ~RunnableImpl() {}
- virtual void Run() {
- func_(param_);
- }
- private:
- UserThreadFunc* const func_;
- const T param_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);
- };
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
- };
- template <typename T>
- class ThreadLocal : public ThreadLocalBase {
- public:
- ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}
- explicit ThreadLocal(const T& value)
- : default_factory_(new InstanceValueHolderFactory(value)) {}
- ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }
- T* pointer() { return GetOrCreateValue(); }
- const T* pointer() const { return GetOrCreateValue(); }
- const T& get() const { return *pointer(); }
- void set(const T& value) { *pointer() = value; }
- private:
-
-
- class ValueHolder : public ThreadLocalValueHolderBase {
- public:
- ValueHolder() : value_() {}
- explicit ValueHolder(const T& value) : value_(value) {}
- T* pointer() { return &value_; }
- private:
- T value_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
- };
- T* GetOrCreateValue() const {
- return static_cast<ValueHolder*>(
- ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();
- }
- virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {
- return default_factory_->MakeNewHolder();
- }
- class ValueHolderFactory {
- public:
- ValueHolderFactory() {}
- virtual ~ValueHolderFactory() {}
- virtual ValueHolder* MakeNewHolder() const = 0;
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
- };
- class DefaultValueHolderFactory : public ValueHolderFactory {
- public:
- DefaultValueHolderFactory() {}
- ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
- };
- class InstanceValueHolderFactory : public ValueHolderFactory {
- public:
- explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
- ValueHolder* MakeNewHolder() const override {
- return new ValueHolder(value_);
- }
- private:
- const T value_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
- };
- std::unique_ptr<ValueHolderFactory> default_factory_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
- };
- # elif GTEST_HAS_PTHREAD
- class MutexBase {
- public:
-
- void Lock() {
- GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
- owner_ = pthread_self();
- has_owner_ = true;
- }
-
- void Unlock() {
-
-
-
-
- has_owner_ = false;
- GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
- }
-
-
- void AssertHeld() const {
- GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
- << "The current thread is not holding the mutex @" << this;
- }
-
-
-
-
-
- public:
- pthread_mutex_t mutex_;
-
-
-
-
-
-
- bool has_owner_;
- pthread_t owner_;
- };
- # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
- extern ::testing::internal::MutexBase mutex
- #define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
- ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
- class Mutex : public MutexBase {
- public:
- Mutex() {
- GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));
- has_owner_ = false;
- }
- ~Mutex() {
- GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
- }
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
- };
- class GTestMutexLock {
- public:
- explicit GTestMutexLock(MutexBase* mutex)
- : mutex_(mutex) { mutex_->Lock(); }
- ~GTestMutexLock() { mutex_->Unlock(); }
- private:
- MutexBase* const mutex_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
- };
- typedef GTestMutexLock MutexLock;
- class ThreadLocalValueHolderBase {
- public:
- virtual ~ThreadLocalValueHolderBase() {}
- };
- extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
- delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
- }
- template <typename T>
- class GTEST_API_ ThreadLocal {
- public:
- ThreadLocal()
- : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
- explicit ThreadLocal(const T& value)
- : key_(CreateKey()),
- default_factory_(new InstanceValueHolderFactory(value)) {}
- ~ThreadLocal() {
-
- DeleteThreadLocalValue(pthread_getspecific(key_));
-
-
- GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
- }
- T* pointer() { return GetOrCreateValue(); }
- const T* pointer() const { return GetOrCreateValue(); }
- const T& get() const { return *pointer(); }
- void set(const T& value) { *pointer() = value; }
- private:
-
- class ValueHolder : public ThreadLocalValueHolderBase {
- public:
- ValueHolder() : value_() {}
- explicit ValueHolder(const T& value) : value_(value) {}
- T* pointer() { return &value_; }
- private:
- T value_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
- };
- static pthread_key_t CreateKey() {
- pthread_key_t key;
-
-
- GTEST_CHECK_POSIX_SUCCESS_(
- pthread_key_create(&key, &DeleteThreadLocalValue));
- return key;
- }
- T* GetOrCreateValue() const {
- ThreadLocalValueHolderBase* const holder =
- static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
- if (holder != nullptr) {
- return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
- }
- ValueHolder* const new_holder = default_factory_->MakeNewHolder();
- ThreadLocalValueHolderBase* const holder_base = new_holder;
- GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
- return new_holder->pointer();
- }
- class ValueHolderFactory {
- public:
- ValueHolderFactory() {}
- virtual ~ValueHolderFactory() {}
- virtual ValueHolder* MakeNewHolder() const = 0;
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);
- };
- class DefaultValueHolderFactory : public ValueHolderFactory {
- public:
- DefaultValueHolderFactory() {}
- ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);
- };
- class InstanceValueHolderFactory : public ValueHolderFactory {
- public:
- explicit InstanceValueHolderFactory(const T& value) : value_(value) {}
- ValueHolder* MakeNewHolder() const override {
- return new ValueHolder(value_);
- }
- private:
- const T value_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);
- };
-
- const pthread_key_t key_;
- std::unique_ptr<ValueHolderFactory> default_factory_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
- };
- # endif
- #else
- class Mutex {
- public:
- Mutex() {}
- void Lock() {}
- void Unlock() {}
- void AssertHeld() const {}
- };
- # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
- extern ::testing::internal::Mutex mutex
- # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
- class GTestMutexLock {
- public:
- explicit GTestMutexLock(Mutex*) {}
- };
- typedef GTestMutexLock MutexLock;
- template <typename T>
- class GTEST_API_ ThreadLocal {
- public:
- ThreadLocal() : value_() {}
- explicit ThreadLocal(const T& value) : value_(value) {}
- T* pointer() { return &value_; }
- const T* pointer() const { return &value_; }
- const T& get() const { return value_; }
- void set(const T& value) { value_ = value; }
- private:
- T value_;
- };
- #endif
- GTEST_API_ size_t GetThreadCount();
- #if GTEST_OS_WINDOWS
- # define GTEST_PATH_SEP_ "\\"
- # define GTEST_HAS_ALT_PATH_SEP_ 1
- #else
- # define GTEST_PATH_SEP_ "/"
- # define GTEST_HAS_ALT_PATH_SEP_ 0
- #endif
- inline bool IsAlpha(char ch) {
- return isalpha(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsAlNum(char ch) {
- return isalnum(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsDigit(char ch) {
- return isdigit(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsLower(char ch) {
- return islower(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsSpace(char ch) {
- return isspace(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsUpper(char ch) {
- return isupper(static_cast<unsigned char>(ch)) != 0;
- }
- inline bool IsXDigit(char ch) {
- return isxdigit(static_cast<unsigned char>(ch)) != 0;
- }
- #ifdef __cpp_char8_t
- inline bool IsXDigit(char8_t ch) {
- return isxdigit(static_cast<unsigned char>(ch)) != 0;
- }
- #endif
- inline bool IsXDigit(char16_t ch) {
- const unsigned char low_byte = static_cast<unsigned char>(ch);
- return ch == low_byte && isxdigit(low_byte) != 0;
- }
- inline bool IsXDigit(char32_t ch) {
- const unsigned char low_byte = static_cast<unsigned char>(ch);
- return ch == low_byte && isxdigit(low_byte) != 0;
- }
- inline bool IsXDigit(wchar_t ch) {
- const unsigned char low_byte = static_cast<unsigned char>(ch);
- return ch == low_byte && isxdigit(low_byte) != 0;
- }
- inline char ToLower(char ch) {
- return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
- }
- inline char ToUpper(char ch) {
- return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
- }
- inline std::string StripTrailingSpaces(std::string str) {
- std::string::iterator it = str.end();
- while (it != str.begin() && IsSpace(*--it))
- it = str.erase(it);
- return str;
- }
- namespace posix {
- #if GTEST_OS_WINDOWS
- typedef struct _stat StatStruct;
- # ifdef __BORLANDC__
- inline int DoIsATTY(int fd) { return isatty(fd); }
- inline int StrCaseCmp(const char* s1, const char* s2) {
- return stricmp(s1, s2);
- }
- inline char* StrDup(const char* src) { return strdup(src); }
- # else
- # if GTEST_OS_WINDOWS_MOBILE
- inline int DoIsATTY(int ) { return 0; }
- # else
- inline int DoIsATTY(int fd) { return _isatty(fd); }
- # endif
- inline int StrCaseCmp(const char* s1, const char* s2) {
- return _stricmp(s1, s2);
- }
- inline char* StrDup(const char* src) { return _strdup(src); }
- # endif
- # if GTEST_OS_WINDOWS_MOBILE
- inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
- # else
- inline int FileNo(FILE* file) { return _fileno(file); }
- inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
- inline int RmDir(const char* dir) { return _rmdir(dir); }
- inline bool IsDir(const StatStruct& st) {
- return (_S_IFDIR & st.st_mode) != 0;
- }
- # endif
- #elif GTEST_OS_ESP8266
- typedef struct stat StatStruct;
- inline int FileNo(FILE* file) { return fileno(file); }
- inline int DoIsATTY(int fd) { return isatty(fd); }
- inline int Stat(const char* path, StatStruct* buf) {
-
- return 0;
- }
- inline int StrCaseCmp(const char* s1, const char* s2) {
- return strcasecmp(s1, s2);
- }
- inline char* StrDup(const char* src) { return strdup(src); }
- inline int RmDir(const char* dir) { return rmdir(dir); }
- inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
- #else
- typedef struct stat StatStruct;
- inline int FileNo(FILE* file) { return fileno(file); }
- inline int DoIsATTY(int fd) { return isatty(fd); }
- inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
- inline int StrCaseCmp(const char* s1, const char* s2) {
- return strcasecmp(s1, s2);
- }
- inline char* StrDup(const char* src) { return strdup(src); }
- inline int RmDir(const char* dir) { return rmdir(dir); }
- inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
- #endif
- inline int IsATTY(int fd) {
-
-
-
- int savedErrno = errno;
- int isAttyValue = DoIsATTY(fd);
- errno = savedErrno;
- return isAttyValue;
- }
- GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
- #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
- !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA
- inline int ChDir(const char* dir) { return chdir(dir); }
- #endif
- inline FILE* FOpen(const char* path, const char* mode) {
- #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
- struct wchar_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t> {};
- std::wstring_convert<wchar_codecvt> converter;
- std::wstring wide_path = converter.from_bytes(path);
- std::wstring wide_mode = converter.from_bytes(mode);
- return _wfopen(wide_path.c_str(), wide_mode.c_str());
- #else
- return fopen(path, mode);
- #endif
- }
- #if !GTEST_OS_WINDOWS_MOBILE
- inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
- return freopen(path, mode, stream);
- }
- inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
- #endif
- inline int FClose(FILE* fp) { return fclose(fp); }
- #if !GTEST_OS_WINDOWS_MOBILE
- inline int Read(int fd, void* buf, unsigned int count) {
- return static_cast<int>(read(fd, buf, count));
- }
- inline int Write(int fd, const void* buf, unsigned int count) {
- return static_cast<int>(write(fd, buf, count));
- }
- inline int Close(int fd) { return close(fd); }
- inline const char* StrError(int errnum) { return strerror(errnum); }
- #endif
- inline const char* GetEnv(const char* name) {
- #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
- GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA
-
- static_cast<void>(name);
- return nullptr;
- #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
-
-
- const char* const env = getenv(name);
- return (env != nullptr && env[0] != '\0') ? env : nullptr;
- #else
- return getenv(name);
- #endif
- }
- GTEST_DISABLE_MSC_DEPRECATED_POP_()
- #if GTEST_OS_WINDOWS_MOBILE
- [[noreturn]] void Abort();
- #else
- [[noreturn]] inline void Abort() { abort(); }
- #endif
- }
- #if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE
- # define GTEST_SNPRINTF_(buffer, size, format, ...) \
- _snprintf_s(buffer, size, size, format, __VA_ARGS__)
- #elif defined(_MSC_VER)
- # define GTEST_SNPRINTF_ _snprintf
- #else
- # define GTEST_SNPRINTF_ snprintf
- #endif
- using BiggestInt = long long;
- constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits<BiggestInt>::max)();
- template <size_t size>
- class TypeWithSize {
- public:
-
-
- using UInt = void;
- };
- template <>
- class TypeWithSize<4> {
- public:
- using Int = std::int32_t;
- using UInt = std::uint32_t;
- };
- template <>
- class TypeWithSize<8> {
- public:
- using Int = std::int64_t;
- using UInt = std::uint64_t;
- };
- using TimeInMillis = int64_t;
- #if !defined(GTEST_FLAG)
- # define GTEST_FLAG(name) FLAGS_gtest_##name
- #endif
- #if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)
- # define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
- #endif
- #if !defined(GTEST_DECLARE_bool_)
- # define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver
- # define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
- # define GTEST_DECLARE_int32_(name) \
- GTEST_API_ extern std::int32_t GTEST_FLAG(name)
- # define GTEST_DECLARE_string_(name) \
- GTEST_API_ extern ::std::string GTEST_FLAG(name)
- # define GTEST_DEFINE_bool_(name, default_val, doc) \
- GTEST_API_ bool GTEST_FLAG(name) = (default_val)
- # define GTEST_DEFINE_int32_(name, default_val, doc) \
- GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val)
- # define GTEST_DEFINE_string_(name, default_val, doc) \
- GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
- #endif
- #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
- # define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
- # define GTEST_LOCK_EXCLUDED_(locks)
- #endif
- GTEST_API_ bool ParseInt32(const Message& src_text, const char* str,
- int32_t* value);
- bool BoolFromGTestEnv(const char* flag, bool default_val);
- GTEST_API_ int32_t Int32FromGTestEnv(const char* flag, int32_t default_val);
- std::string OutputFlagAlsoCheckEnvVar();
- const char* StringFromGTestEnv(const char* flag, const char* default_val);
- }
- }
- #if !defined(GTEST_INTERNAL_DEPRECATED)
- #if defined(_MSC_VER)
- #define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))
- #elif defined(__GNUC__)
- #define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))
- #else
- #define GTEST_INTERNAL_DEPRECATED(message)
- #endif
- #endif
- #if GTEST_HAS_ABSL
- #define GTEST_INTERNAL_HAS_ANY 1
- #include "absl/types/any.h"
- namespace testing {
- namespace internal {
- using Any = ::absl::any;
- }
- }
- #else
- #ifdef __has_include
- #if __has_include(<any>) && __cplusplus >= 201703L
- #define GTEST_INTERNAL_HAS_ANY 1
- #include <any>
- namespace testing {
- namespace internal {
- using Any = ::std::any;
- }
- }
- #endif
- #endif
- #endif
- #if GTEST_HAS_ABSL
- #define GTEST_INTERNAL_HAS_OPTIONAL 1
- #include "absl/types/optional.h"
- namespace testing {
- namespace internal {
- template <typename T>
- using Optional = ::absl::optional<T>;
- }
- }
- #else
- #ifdef __has_include
- #if __has_include(<optional>) && __cplusplus >= 201703L
- #define GTEST_INTERNAL_HAS_OPTIONAL 1
- #include <optional>
- namespace testing {
- namespace internal {
- template <typename T>
- using Optional = ::std::optional<T>;
- }
- }
- #endif
- #endif
- #endif
- #if GTEST_HAS_ABSL
- # define GTEST_INTERNAL_HAS_STRING_VIEW 1
- #include "absl/strings/string_view.h"
- namespace testing {
- namespace internal {
- using StringView = ::absl::string_view;
- }
- }
- #else
- # ifdef __has_include
- # if __has_include(<string_view>) && __cplusplus >= 201703L
- # define GTEST_INTERNAL_HAS_STRING_VIEW 1
- #include <string_view>
- namespace testing {
- namespace internal {
- using StringView = ::std::string_view;
- }
- }
- # endif
- # endif
- #endif
- #if GTEST_HAS_ABSL
- #define GTEST_INTERNAL_HAS_VARIANT 1
- #include "absl/types/variant.h"
- namespace testing {
- namespace internal {
- template <typename... T>
- using Variant = ::absl::variant<T...>;
- }
- }
- #else
- #ifdef __has_include
- #if __has_include(<variant>) && __cplusplus >= 201703L
- #define GTEST_INTERNAL_HAS_VARIANT 1
- #include <variant>
- namespace testing {
- namespace internal {
- template <typename... T>
- using Variant = ::std::variant<T...>;
- }
- }
- #endif
- #endif
- #endif
- #endif
- #if GTEST_OS_LINUX
- # include <stdlib.h>
- # include <sys/types.h>
- # include <sys/wait.h>
- # include <unistd.h>
- #endif
- #if GTEST_HAS_EXCEPTIONS
- # include <stdexcept>
- #endif
- #include <ctype.h>
- #include <float.h>
- #include <string.h>
- #include <cstdint>
- #include <iomanip>
- #include <limits>
- #include <map>
- #include <set>
- #include <string>
- #include <type_traits>
- #include <vector>
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
- #include <limits>
- #include <memory>
- #include <sstream>
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- void operator<<(const testing::internal::Secret&, int);
- namespace testing {
- class GTEST_API_ Message {
- private:
-
-
- typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
- public:
-
- Message();
-
- Message(const Message& msg) : ss_(new ::std::stringstream) {
- *ss_ << msg.GetString();
- }
-
- explicit Message(const char* str) : ss_(new ::std::stringstream) {
- *ss_ << str;
- }
-
- template <typename T>
- inline Message& operator <<(const T& val) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- using ::operator <<;
- *ss_ << val;
- return *this;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <typename T>
- inline Message& operator <<(T* const& pointer) {
- if (pointer == nullptr) {
- *ss_ << "(null)";
- } else {
- *ss_ << pointer;
- }
- return *this;
- }
-
-
-
-
-
-
- Message& operator <<(BasicNarrowIoManip val) {
- *ss_ << val;
- return *this;
- }
-
- Message& operator <<(bool b) {
- return *this << (b ? "true" : "false");
- }
-
-
- Message& operator <<(const wchar_t* wide_c_str);
- Message& operator <<(wchar_t* wide_c_str);
- #if GTEST_HAS_STD_WSTRING
-
-
- Message& operator <<(const ::std::wstring& wstr);
- #endif
-
-
-
-
- std::string GetString() const;
- private:
-
- const std::unique_ptr< ::std::stringstream> ss_;
-
-
- void operator=(const Message&);
- };
- inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
- return os << sb.GetString();
- }
- namespace internal {
- template <typename T>
- std::string StreamableToString(const T& streamable) {
- return (Message() << streamable).GetString();
- }
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
- #ifdef __BORLANDC__
- # include <mem.h>
- #endif
- #include <string.h>
- #include <cstdint>
- #include <string>
- namespace testing {
- namespace internal {
- class GTEST_API_ String {
- public:
-
-
-
-
-
-
-
-
- static const char* CloneCString(const char* c_str);
- #if GTEST_OS_WINDOWS_MOBILE
-
-
-
-
-
-
-
-
-
-
-
- static LPCWSTR AnsiToUtf16(const char* c_str);
-
-
-
-
-
-
-
-
- static const char* Utf16ToAnsi(LPCWSTR utf16_str);
- #endif
-
-
-
-
-
-
- static bool CStringEquals(const char* lhs, const char* rhs);
-
-
-
-
- static std::string ShowWideCString(const wchar_t* wide_c_str);
-
-
-
-
-
-
- static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
-
-
-
-
-
-
- static bool CaseInsensitiveCStringEquals(const char* lhs,
- const char* rhs);
-
-
-
-
-
-
-
-
-
-
-
-
- static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
- const wchar_t* rhs);
-
-
- static bool EndsWithCaseInsensitive(
- const std::string& str, const std::string& suffix);
-
- static std::string FormatIntWidth2(int value);
-
- static std::string FormatIntWidthN(int value, int width);
-
- static std::string FormatHexInt(int value);
-
- static std::string FormatHexUInt32(uint32_t value);
-
- static std::string FormatByte(unsigned char value);
- private:
- String();
- };
- GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
- }
- }
- #endif
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- namespace internal {
- class GTEST_API_ FilePath {
- public:
- FilePath() : pathname_("") { }
- FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
- explicit FilePath(const std::string& pathname) : pathname_(pathname) {
- Normalize();
- }
- FilePath& operator=(const FilePath& rhs) {
- Set(rhs);
- return *this;
- }
- void Set(const FilePath& rhs) {
- pathname_ = rhs.pathname_;
- }
- const std::string& string() const { return pathname_; }
- const char* c_str() const { return pathname_.c_str(); }
-
- static FilePath GetCurrentDir();
-
-
-
-
- static FilePath MakeFileName(const FilePath& directory,
- const FilePath& base_name,
- int number,
- const char* extension);
-
-
-
- static FilePath ConcatPaths(const FilePath& directory,
- const FilePath& relative_path);
-
-
-
-
-
-
-
-
- static FilePath GenerateUniqueFileName(const FilePath& directory,
- const FilePath& base_name,
- const char* extension);
-
- bool IsEmpty() const { return pathname_.empty(); }
-
-
-
- FilePath RemoveTrailingPathSeparator() const;
-
-
-
-
-
-
- FilePath RemoveDirectoryName() const;
-
-
-
-
-
-
- FilePath RemoveFileName() const;
-
-
-
-
- FilePath RemoveExtension(const char* extension) const;
-
-
-
-
- bool CreateDirectoriesRecursively() const;
-
-
-
-
- bool CreateFolder() const;
-
-
- bool FileOrDirectoryExists() const;
-
-
- bool DirectoryExists() const;
-
-
-
- bool IsDirectory() const;
-
-
- bool IsRootDirectory() const;
-
- bool IsAbsolutePath() const;
- private:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void Normalize();
-
-
-
- const char* FindLastPathSeparator() const;
- std::string pathname_;
- };
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
- # if GTEST_HAS_CXXABI_H_
- # include <cxxabi.h>
- # elif defined(__HP_aCC)
- # include <acxx_demangle.h>
- # endif
- namespace testing {
- namespace internal {
- inline std::string CanonicalizeForStdLibVersioning(std::string s) {
- static const char prefix[] = "std::__";
- if (s.compare(0, strlen(prefix), prefix) == 0) {
- std::string::size_type end = s.find("::", strlen(prefix));
- if (end != s.npos) {
-
- s.erase(strlen("std"), end - strlen("std"));
- }
- }
- return s;
- }
- #if GTEST_HAS_RTTI
- inline std::string GetTypeName(const std::type_info& type) {
- const char* const name = type.name();
- #if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)
- int status = 0;
-
-
- #if GTEST_HAS_CXXABI_H_
- using abi::__cxa_demangle;
- #endif
- char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status);
- const std::string name_str(status == 0 ? readable_name : name);
- free(readable_name);
- return CanonicalizeForStdLibVersioning(name_str);
- #else
- return name;
- #endif
- }
- #endif
- template <typename T>
- std::string GetTypeName() {
- #if GTEST_HAS_RTTI
- return GetTypeName(typeid(T));
- #else
- return "<type>";
- #endif
- }
- struct None {};
- # define GTEST_TEMPLATE_ template <typename T> class
- template <GTEST_TEMPLATE_ Tmpl>
- struct TemplateSel {
- template <typename T>
- struct Bind {
- typedef Tmpl<T> type;
- };
- };
- # define GTEST_BIND_(TmplSel, T) \
- TmplSel::template Bind<T>::type
- template <GTEST_TEMPLATE_ Head_, GTEST_TEMPLATE_... Tail_>
- struct Templates {
- using Head = TemplateSel<Head_>;
- using Tail = Templates<Tail_...>;
- };
- template <GTEST_TEMPLATE_ Head_>
- struct Templates<Head_> {
- using Head = TemplateSel<Head_>;
- using Tail = None;
- };
- template <typename Head_, typename... Tail_>
- struct Types {
- using Head = Head_;
- using Tail = Types<Tail_...>;
- };
- template <typename Head_>
- struct Types<Head_> {
- using Head = Head_;
- using Tail = None;
- };
- template <typename... Ts>
- struct ProxyTypeList {
- using type = Types<Ts...>;
- };
- template <typename>
- struct is_proxy_type_list : std::false_type {};
- template <typename... Ts>
- struct is_proxy_type_list<ProxyTypeList<Ts...>> : std::true_type {};
- template <typename T>
- struct GenerateTypeList {
- private:
- using proxy = typename std::conditional<is_proxy_type_list<T>::value, T,
- ProxyTypeList<T>>::type;
- public:
- using type = typename proxy::type;
- };
- }
- template <typename... Ts>
- using Types = internal::ProxyTypeList<Ts...>;
- }
- #endif
- #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
- #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
- #define GTEST_STRINGIFY_HELPER_(name, ...) #name
- #define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, )
- namespace proto2 {
- class MessageLite;
- }
- namespace testing {
- class AssertionResult;
- class Message;
- class Test;
- class TestInfo;
- class TestPartResult;
- class UnitTest;
- template <typename T>
- ::std::string PrintToString(const T& value);
- namespace internal {
- struct TraceInfo;
- class TestInfoImpl;
- class UnitTestImpl;
- GTEST_API_ extern const char kStackTraceMarker[];
- class IgnoredValue {
- struct Sink {};
- public:
-
-
-
-
-
-
-
- template <typename T,
- typename std::enable_if<!std::is_convertible<T, Sink>::value,
- int>::type = 0>
- IgnoredValue(const T& ) {}
- };
- GTEST_API_ std::string AppendUserMessage(
- const std::string& gtest_msg, const Message& user_msg);
- #if GTEST_HAS_EXCEPTIONS
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \
- )
- class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {
- public:
- explicit GoogleTestFailureException(const TestPartResult& failure);
- };
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- namespace edit_distance {
- enum EditType { kMatch, kAdd, kRemove, kReplace };
- GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
- const std::vector<size_t>& left, const std::vector<size_t>& right);
- GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
- const std::vector<std::string>& left,
- const std::vector<std::string>& right);
- GTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,
- const std::vector<std::string>& right,
- size_t context = 2);
- }
- GTEST_API_ std::string DiffStrings(const std::string& left,
- const std::string& right,
- size_t* total_line_count);
- GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
- const char* actual_expression,
- const std::string& expected_value,
- const std::string& actual_value,
- bool ignoring_case);
- GTEST_API_ std::string GetBoolAssertionFailureMessage(
- const AssertionResult& assertion_result,
- const char* expression_text,
- const char* actual_predicate_value,
- const char* expected_predicate_value);
- template <typename RawType>
- class FloatingPoint {
- public:
-
-
- typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;
-
-
- static const size_t kBitCount = 8*sizeof(RawType);
-
- static const size_t kFractionBitCount =
- std::numeric_limits<RawType>::digits - 1;
-
- static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
-
- static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);
-
- static const Bits kFractionBitMask =
- ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
-
- static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
-
-
-
-
-
-
-
-
-
-
-
-
- static const uint32_t kMaxUlps = 4;
-
-
-
-
-
-
- explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
-
-
-
-
- static RawType ReinterpretBits(const Bits bits) {
- FloatingPoint fp(0);
- fp.u_.bits_ = bits;
- return fp.u_.value_;
- }
-
- static RawType Infinity() {
- return ReinterpretBits(kExponentBitMask);
- }
-
- static RawType Max();
-
-
- const Bits &bits() const { return u_.bits_; }
-
- Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
-
- Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
-
- Bits sign_bit() const { return kSignBitMask & u_.bits_; }
-
- bool is_nan() const {
-
-
- return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
- }
-
-
-
-
-
-
- bool AlmostEquals(const FloatingPoint& rhs) const {
-
-
- if (is_nan() || rhs.is_nan()) return false;
- return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
- <= kMaxUlps;
- }
- private:
-
- union FloatingPointUnion {
- RawType value_;
- Bits bits_;
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- static Bits SignAndMagnitudeToBiased(const Bits &sam) {
- if (kSignBitMask & sam) {
-
- return ~sam + 1;
- } else {
-
- return kSignBitMask | sam;
- }
- }
-
-
- static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,
- const Bits &sam2) {
- const Bits biased1 = SignAndMagnitudeToBiased(sam1);
- const Bits biased2 = SignAndMagnitudeToBiased(sam2);
- return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
- }
- FloatingPointUnion u_;
- };
- template <>
- inline float FloatingPoint<float>::Max() { return FLT_MAX; }
- template <>
- inline double FloatingPoint<double>::Max() { return DBL_MAX; }
- typedef FloatingPoint<float> Float;
- typedef FloatingPoint<double> Double;
- typedef const void* TypeId;
- template <typename T>
- class TypeIdHelper {
- public:
-
-
-
- static bool dummy_;
- };
- template <typename T>
- bool TypeIdHelper<T>::dummy_ = false;
- template <typename T>
- TypeId GetTypeId() {
-
-
-
-
- return &(TypeIdHelper<T>::dummy_);
- }
- GTEST_API_ TypeId GetTestTypeId();
- class TestFactoryBase {
- public:
- virtual ~TestFactoryBase() {}
-
-
- virtual Test* CreateTest() = 0;
- protected:
- TestFactoryBase() {}
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);
- };
- template <class TestClass>
- class TestFactoryImpl : public TestFactoryBase {
- public:
- Test* CreateTest() override { return new TestClass; }
- };
- #if GTEST_OS_WINDOWS
- GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,
- long hr);
- GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,
- long hr);
- #endif
- using SetUpTestSuiteFunc = void (*)();
- using TearDownTestSuiteFunc = void (*)();
- struct CodeLocation {
- CodeLocation(const std::string& a_file, int a_line)
- : file(a_file), line(a_line) {}
- std::string file;
- int line;
- };
- using SetUpTearDownSuiteFuncType = void (*)();
- inline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(
- SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) {
- return a == def ? nullptr : a;
- }
- template <typename T>
- struct SuiteApiResolver : T {
-
-
- using Test =
- typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;
- static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite(const char* filename,
- int line_num) {
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- SetUpTearDownSuiteFuncType test_case_fp =
- GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase);
- SetUpTearDownSuiteFuncType test_suite_fp =
- GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite);
- GTEST_CHECK_(!test_case_fp || !test_suite_fp)
- << "Test can not provide both SetUpTestSuite and SetUpTestCase, please "
- "make sure there is only one present at "
- << filename << ":" << line_num;
- return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
- #else
- (void)(filename);
- (void)(line_num);
- return &T::SetUpTestSuite;
- #endif
- }
- static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite(const char* filename,
- int line_num) {
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- SetUpTearDownSuiteFuncType test_case_fp =
- GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase);
- SetUpTearDownSuiteFuncType test_suite_fp =
- GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite);
- GTEST_CHECK_(!test_case_fp || !test_suite_fp)
- << "Test can not provide both TearDownTestSuite and TearDownTestCase,"
- " please make sure there is only one present at"
- << filename << ":" << line_num;
- return test_case_fp != nullptr ? test_case_fp : test_suite_fp;
- #else
- (void)(filename);
- (void)(line_num);
- return &T::TearDownTestSuite;
- #endif
- }
- };
- GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
- const char* test_suite_name, const char* name, const char* type_param,
- const char* value_param, CodeLocation code_location,
- TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
- TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
- GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- class GTEST_API_ TypedTestSuitePState {
- public:
- TypedTestSuitePState() : registered_(false) {}
-
-
-
- bool AddTestName(const char* file, int line, const char* case_name,
- const char* test_name) {
- if (registered_) {
- fprintf(stderr,
- "%s Test %s must be defined before "
- "REGISTER_TYPED_TEST_SUITE_P(%s, ...).\n",
- FormatFileLocation(file, line).c_str(), test_name, case_name);
- fflush(stderr);
- posix::Abort();
- }
- registered_tests_.insert(
- ::std::make_pair(test_name, CodeLocation(file, line)));
- return true;
- }
- bool TestExists(const std::string& test_name) const {
- return registered_tests_.count(test_name) > 0;
- }
- const CodeLocation& GetCodeLocation(const std::string& test_name) const {
- RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);
- GTEST_CHECK_(it != registered_tests_.end());
- return it->second;
- }
-
-
-
- const char* VerifyRegisteredTestNames(const char* test_suite_name,
- const char* file, int line,
- const char* registered_tests);
- private:
- typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;
- bool registered_;
- RegisteredTestsMap registered_tests_;
- };
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- using TypedTestCasePState = TypedTestSuitePState;
- #endif
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- inline const char* SkipComma(const char* str) {
- const char* comma = strchr(str, ',');
- if (comma == nullptr) {
- return nullptr;
- }
- while (IsSpace(*(++comma))) {}
- return comma;
- }
- inline std::string GetPrefixUntilComma(const char* str) {
- const char* comma = strchr(str, ',');
- return comma == nullptr ? str : std::string(str, comma);
- }
- void SplitString(const ::std::string& str, char delimiter,
- ::std::vector< ::std::string>* dest);
- struct DefaultNameGenerator {
- template <typename T>
- static std::string GetName(int i) {
- return StreamableToString(i);
- }
- };
- template <typename Provided = DefaultNameGenerator>
- struct NameGeneratorSelector {
- typedef Provided type;
- };
- template <typename NameGenerator>
- void GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}
- template <typename NameGenerator, typename Types>
- void GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) {
- result->push_back(NameGenerator::template GetName<typename Types::Head>(i));
- GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result,
- i + 1);
- }
- template <typename NameGenerator, typename Types>
- std::vector<std::string> GenerateNames() {
- std::vector<std::string> result;
- GenerateNamesRecursively<NameGenerator>(Types(), &result, 0);
- return result;
- }
- template <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>
- class TypeParameterizedTest {
- public:
-
-
-
-
- static bool Register(const char* prefix, const CodeLocation& code_location,
- const char* case_name, const char* test_names, int index,
- const std::vector<std::string>& type_names =
- GenerateNames<DefaultNameGenerator, Types>()) {
- typedef typename Types::Head Type;
- typedef Fixture<Type> FixtureClass;
- typedef typename GTEST_BIND_(TestSel, Type) TestClass;
-
-
- MakeAndRegisterTestInfo(
- (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
- "/" + type_names[static_cast<size_t>(index)])
- .c_str(),
- StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
- GetTypeName<Type>().c_str(),
- nullptr,
- code_location, GetTypeId<FixtureClass>(),
- SuiteApiResolver<TestClass>::GetSetUpCaseOrSuite(
- code_location.file.c_str(), code_location.line),
- SuiteApiResolver<TestClass>::GetTearDownCaseOrSuite(
- code_location.file.c_str(), code_location.line),
- new TestFactoryImpl<TestClass>);
-
- return TypeParameterizedTest<Fixture, TestSel,
- typename Types::Tail>::Register(prefix,
- code_location,
- case_name,
- test_names,
- index + 1,
- type_names);
- }
- };
- template <GTEST_TEMPLATE_ Fixture, class TestSel>
- class TypeParameterizedTest<Fixture, TestSel, internal::None> {
- public:
- static bool Register(const char* , const CodeLocation&,
- const char* , const char* ,
- int ,
- const std::vector<std::string>& =
- std::vector<std::string>() ) {
- return true;
- }
- };
- GTEST_API_ void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
- CodeLocation code_location);
- GTEST_API_ void RegisterTypeParameterizedTestSuiteInstantiation(
- const char* case_name);
- template <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>
- class TypeParameterizedTestSuite {
- public:
- static bool Register(const char* prefix, CodeLocation code_location,
- const TypedTestSuitePState* state, const char* case_name,
- const char* test_names,
- const std::vector<std::string>& type_names =
- GenerateNames<DefaultNameGenerator, Types>()) {
- RegisterTypeParameterizedTestSuiteInstantiation(case_name);
- std::string test_name = StripTrailingSpaces(
- GetPrefixUntilComma(test_names));
- if (!state->TestExists(test_name)) {
- fprintf(stderr, "Failed to get code location for test %s.%s at %s.",
- case_name, test_name.c_str(),
- FormatFileLocation(code_location.file.c_str(),
- code_location.line).c_str());
- fflush(stderr);
- posix::Abort();
- }
- const CodeLocation& test_location = state->GetCodeLocation(test_name);
- typedef typename Tests::Head Head;
-
- TypeParameterizedTest<Fixture, Head, Types>::Register(
- prefix, test_location, case_name, test_names, 0, type_names);
-
- return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
- Types>::Register(prefix, code_location,
- state, case_name,
- SkipComma(test_names),
- type_names);
- }
- };
- template <GTEST_TEMPLATE_ Fixture, typename Types>
- class TypeParameterizedTestSuite<Fixture, internal::None, Types> {
- public:
- static bool Register(const char* , const CodeLocation&,
- const TypedTestSuitePState* ,
- const char* , const char* ,
- const std::vector<std::string>& =
- std::vector<std::string>() ) {
- return true;
- }
- };
- GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(
- UnitTest* unit_test, int skip_count);
- GTEST_API_ bool AlwaysTrue();
- inline bool AlwaysFalse() { return !AlwaysTrue(); }
- struct GTEST_API_ ConstCharPtr {
- ConstCharPtr(const char* str) : value(str) {}
- operator bool() const { return true; }
- const char* value;
- };
- struct TrueWithString {
- TrueWithString() = default;
- explicit TrueWithString(const char* str) : value(str) {}
- explicit TrueWithString(const std::string& str) : value(str) {}
- explicit operator bool() const { return true; }
- std::string value;
- };
- class GTEST_API_ Random {
- public:
- static const uint32_t kMaxRange = 1u << 31;
- explicit Random(uint32_t seed) : state_(seed) {}
- void Reseed(uint32_t seed) { state_ = seed; }
-
-
- uint32_t Generate(uint32_t range);
- private:
- uint32_t state_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
- };
- #define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
- typename std::remove_const<typename std::remove_reference<T>::type>::type
- template <typename T>
- class HasDebugStringAndShortDebugString {
- private:
- template <typename C>
- static auto CheckDebugString(C*) -> typename std::is_same<
- std::string, decltype(std::declval<const C>().DebugString())>::type;
- template <typename>
- static std::false_type CheckDebugString(...);
- template <typename C>
- static auto CheckShortDebugString(C*) -> typename std::is_same<
- std::string, decltype(std::declval<const C>().ShortDebugString())>::type;
- template <typename>
- static std::false_type CheckShortDebugString(...);
- using HasDebugStringType = decltype(CheckDebugString<T>(nullptr));
- using HasShortDebugStringType = decltype(CheckShortDebugString<T>(nullptr));
- public:
- static constexpr bool value =
- HasDebugStringType::value && HasShortDebugStringType::value;
- };
- template <typename T>
- constexpr bool HasDebugStringAndShortDebugString<T>::value;
- typedef int IsContainer;
- template <class C,
- class Iterator = decltype(::std::declval<const C&>().begin()),
- class = decltype(::std::declval<const C&>().end()),
- class = decltype(++::std::declval<Iterator&>()),
- class = decltype(*::std::declval<Iterator>()),
- class = typename C::const_iterator>
- IsContainer IsContainerTest(int ) {
- return 0;
- }
- typedef char IsNotContainer;
- template <class C>
- IsNotContainer IsContainerTest(long ) { return '\0'; }
- template <typename T>
- struct IsHashTable {
- private:
- template <typename U>
- static char test(typename U::hasher*, typename U::reverse_iterator*);
- template <typename U>
- static int test(typename U::hasher*, ...);
- template <typename U>
- static char test(...);
- public:
- static const bool value = sizeof(test<T>(nullptr, nullptr)) == sizeof(int);
- };
- template <typename T>
- const bool IsHashTable<T>::value;
- template <typename C,
- bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)>
- struct IsRecursiveContainerImpl;
- template <typename C>
- struct IsRecursiveContainerImpl<C, false> : public std::false_type {};
- template <typename C>
- struct IsRecursiveContainerImpl<C, true> {
- using value_type = decltype(*std::declval<typename C::const_iterator>());
- using type =
- std::is_same<typename std::remove_const<
- typename std::remove_reference<value_type>::type>::type,
- C>;
- };
- template <typename C>
- struct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};
- template <typename T, typename U>
- bool ArrayEq(const T* lhs, size_t size, const U* rhs);
- template <typename T, typename U>
- inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }
- template <typename T, typename U, size_t N>
- inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
- return internal::ArrayEq(lhs, N, rhs);
- }
- template <typename T, typename U>
- bool ArrayEq(const T* lhs, size_t size, const U* rhs) {
- for (size_t i = 0; i != size; i++) {
- if (!internal::ArrayEq(lhs[i], rhs[i]))
- return false;
- }
- return true;
- }
- template <typename Iter, typename Element>
- Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {
- for (Iter it = begin; it != end; ++it) {
- if (internal::ArrayEq(*it, elem))
- return it;
- }
- return end;
- }
- template <typename T, typename U>
- void CopyArray(const T* from, size_t size, U* to);
- template <typename T, typename U>
- inline void CopyArray(const T& from, U* to) { *to = from; }
- template <typename T, typename U, size_t N>
- inline void CopyArray(const T(&from)[N], U(*to)[N]) {
- internal::CopyArray(from, N, *to);
- }
- template <typename T, typename U>
- void CopyArray(const T* from, size_t size, U* to) {
- for (size_t i = 0; i != size; i++) {
- internal::CopyArray(from[i], to + i);
- }
- }
- struct RelationToSourceReference {};
- struct RelationToSourceCopy {};
- template <typename Element>
- class NativeArray {
- public:
-
- typedef Element value_type;
- typedef Element* iterator;
- typedef const Element* const_iterator;
-
- NativeArray(const Element* array, size_t count, RelationToSourceReference) {
- InitRef(array, count);
- }
-
- NativeArray(const Element* array, size_t count, RelationToSourceCopy) {
- InitCopy(array, count);
- }
-
- NativeArray(const NativeArray& rhs) {
- (this->*rhs.clone_)(rhs.array_, rhs.size_);
- }
- ~NativeArray() {
- if (clone_ != &NativeArray::InitRef)
- delete[] array_;
- }
-
- size_t size() const { return size_; }
- const_iterator begin() const { return array_; }
- const_iterator end() const { return array_ + size_; }
- bool operator==(const NativeArray& rhs) const {
- return size() == rhs.size() &&
- ArrayEq(begin(), size(), rhs.begin());
- }
- private:
- static_assert(!std::is_const<Element>::value, "Type must not be const");
- static_assert(!std::is_reference<Element>::value,
- "Type must not be a reference");
-
- void InitCopy(const Element* array, size_t a_size) {
- Element* const copy = new Element[a_size];
- CopyArray(array, a_size, copy);
- array_ = copy;
- size_ = a_size;
- clone_ = &NativeArray::InitCopy;
- }
-
- void InitRef(const Element* array, size_t a_size) {
- array_ = array;
- size_ = a_size;
- clone_ = &NativeArray::InitRef;
- }
- const Element* array_;
- size_t size_;
- void (NativeArray::*clone_)(const Element*, size_t);
- };
- template <size_t... Is>
- struct IndexSequence {
- using type = IndexSequence;
- };
- template <bool plus_one, typename T, size_t sizeofT>
- struct DoubleSequence;
- template <size_t... I, size_t sizeofT>
- struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
- using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
- };
- template <size_t... I, size_t sizeofT>
- struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
- using type = IndexSequence<I..., (sizeofT + I)...>;
- };
- template <size_t N>
- struct MakeIndexSequenceImpl
- : DoubleSequence<N % 2 == 1, typename MakeIndexSequenceImpl<N / 2>::type,
- N / 2>::type {};
- template <>
- struct MakeIndexSequenceImpl<0> : IndexSequence<> {};
- template <size_t N>
- using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::type;
- template <typename... T>
- using IndexSequenceFor = typename MakeIndexSequence<sizeof...(T)>::type;
- template <size_t>
- struct Ignore {
- Ignore(...);
- };
- template <typename>
- struct ElemFromListImpl;
- template <size_t... I>
- struct ElemFromListImpl<IndexSequence<I...>> {
-
-
-
-
- template <typename R>
- static R Apply(Ignore<0 * I>..., R (*)(), ...);
- };
- template <size_t N, typename... T>
- struct ElemFromList {
- using type =
- decltype(ElemFromListImpl<typename MakeIndexSequence<N>::type>::Apply(
- static_cast<T (*)()>(nullptr)...));
- };
- struct FlatTupleConstructTag {};
- template <typename... T>
- class FlatTuple;
- template <typename Derived, size_t I>
- struct FlatTupleElemBase;
- template <typename... T, size_t I>
- struct FlatTupleElemBase<FlatTuple<T...>, I> {
- using value_type = typename ElemFromList<I, T...>::type;
- FlatTupleElemBase() = default;
- template <typename Arg>
- explicit FlatTupleElemBase(FlatTupleConstructTag, Arg&& t)
- : value(std::forward<Arg>(t)) {}
- value_type value;
- };
- template <typename Derived, typename Idx>
- struct FlatTupleBase;
- template <size_t... Idx, typename... T>
- struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
- : FlatTupleElemBase<FlatTuple<T...>, Idx>... {
- using Indices = IndexSequence<Idx...>;
- FlatTupleBase() = default;
- template <typename... Args>
- explicit FlatTupleBase(FlatTupleConstructTag, Args&&... args)
- : FlatTupleElemBase<FlatTuple<T...>, Idx>(FlatTupleConstructTag{},
- std::forward<Args>(args))... {}
- template <size_t I>
- const typename ElemFromList<I, T...>::type& Get() const {
- return FlatTupleElemBase<FlatTuple<T...>, I>::value;
- }
- template <size_t I>
- typename ElemFromList<I, T...>::type& Get() {
- return FlatTupleElemBase<FlatTuple<T...>, I>::value;
- }
- template <typename F>
- auto Apply(F&& f) -> decltype(std::forward<F>(f)(this->Get<Idx>()...)) {
- return std::forward<F>(f)(Get<Idx>()...);
- }
- template <typename F>
- auto Apply(F&& f) const -> decltype(std::forward<F>(f)(this->Get<Idx>()...)) {
- return std::forward<F>(f)(Get<Idx>()...);
- }
- };
- template <typename... T>
- class FlatTuple
- : private FlatTupleBase<FlatTuple<T...>,
- typename MakeIndexSequence<sizeof...(T)>::type> {
- using Indices = typename FlatTupleBase<
- FlatTuple<T...>, typename MakeIndexSequence<sizeof...(T)>::type>::Indices;
- public:
- FlatTuple() = default;
- template <typename... Args>
- explicit FlatTuple(FlatTupleConstructTag tag, Args&&... args)
- : FlatTuple::FlatTupleBase(tag, std::forward<Args>(args)...) {}
- using FlatTuple::FlatTupleBase::Apply;
- using FlatTuple::FlatTupleBase::Get;
- };
- GTEST_INTERNAL_DEPRECATED(
- "INSTANTIATE_TEST_CASE_P is deprecated, please use "
- "INSTANTIATE_TEST_SUITE_P")
- constexpr bool InstantiateTestCase_P_IsDeprecated() { return true; }
- GTEST_INTERNAL_DEPRECATED(
- "TYPED_TEST_CASE_P is deprecated, please use "
- "TYPED_TEST_SUITE_P")
- constexpr bool TypedTestCase_P_IsDeprecated() { return true; }
- GTEST_INTERNAL_DEPRECATED(
- "TYPED_TEST_CASE is deprecated, please use "
- "TYPED_TEST_SUITE")
- constexpr bool TypedTestCaseIsDeprecated() { return true; }
- GTEST_INTERNAL_DEPRECATED(
- "REGISTER_TYPED_TEST_CASE_P is deprecated, please use "
- "REGISTER_TYPED_TEST_SUITE_P")
- constexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; }
- GTEST_INTERNAL_DEPRECATED(
- "INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use "
- "INSTANTIATE_TYPED_TEST_SUITE_P")
- constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
- }
- }
- namespace std {
- #ifdef __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wmismatched-tags"
- #endif
- template <typename... Ts>
- struct tuple_size<testing::internal::FlatTuple<Ts...>>
- : std::integral_constant<size_t, sizeof...(Ts)> {};
- #ifdef __clang__
- #pragma clang diagnostic pop
- #endif
- }
- #define GTEST_MESSAGE_AT_(file, line, message, result_type) \
- ::testing::internal::AssertHelper(result_type, file, line, message) \
- = ::testing::Message()
- #define GTEST_MESSAGE_(message, result_type) \
- GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
- #define GTEST_FATAL_FAILURE_(message) \
- return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
- #define GTEST_NONFATAL_FAILURE_(message) \
- GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)
- #define GTEST_SUCCESS_(message) \
- GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
- #define GTEST_SKIP_(message) \
- return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
- #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
- if (::testing::internal::AlwaysTrue()) { \
- statement; \
- } else \
- static_assert(true, "")
- #if GTEST_HAS_EXCEPTIONS
- namespace testing {
- namespace internal {
- class NeverThrown {
- public:
- const char* what() const noexcept {
- return "this exception should never be thrown";
- }
- };
- }
- }
- #if GTEST_HAS_RTTI
- #define GTEST_EXCEPTION_TYPE_(e) ::testing::internal::GetTypeName(typeid(e))
- #else
- #define GTEST_EXCEPTION_TYPE_(e) \
- std::string { "an std::exception-derived error" }
- #endif
- #define GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception) \
- catch (typename std::conditional< \
- std::is_same<typename std::remove_cv<typename std::remove_reference< \
- expected_exception>::type>::type, \
- std::exception>::value, \
- const ::testing::internal::NeverThrown&, const std::exception&>::type \
- e) { \
- gtest_msg.value = "Expected: " #statement \
- " throws an exception of type " #expected_exception \
- ".\n Actual: it throws "; \
- gtest_msg.value += GTEST_EXCEPTION_TYPE_(e); \
- gtest_msg.value += " with description \""; \
- gtest_msg.value += e.what(); \
- gtest_msg.value += "\"."; \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- }
- #else
- #define GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception)
- #endif
- #define GTEST_TEST_THROW_(statement, expected_exception, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::TrueWithString gtest_msg{}) { \
- bool gtest_caught_expected = false; \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } catch (expected_exception const&) { \
- gtest_caught_expected = true; \
- } \
- GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception) \
- catch (...) { \
- gtest_msg.value = "Expected: " #statement \
- " throws an exception of type " #expected_exception \
- ".\n Actual: it throws a different type."; \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- } \
- if (!gtest_caught_expected) { \
- gtest_msg.value = "Expected: " #statement \
- " throws an exception of type " #expected_exception \
- ".\n Actual: it throws nothing."; \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \
- : fail(gtest_msg.value.c_str())
- #if GTEST_HAS_EXCEPTIONS
- #define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
- catch (std::exception const& e) { \
- gtest_msg.value = "it throws "; \
- gtest_msg.value += GTEST_EXCEPTION_TYPE_(e); \
- gtest_msg.value += " with description \""; \
- gtest_msg.value += e.what(); \
- gtest_msg.value += "\"."; \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
- }
- #else
- #define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_()
- #endif
- #define GTEST_TEST_NO_THROW_(statement, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::TrueWithString gtest_msg{}) { \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } \
- GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \
- catch (...) { \
- gtest_msg.value = "it throws."; \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
- fail(("Expected: " #statement " doesn't throw an exception.\n" \
- " Actual: " + gtest_msg.value).c_str())
- #define GTEST_TEST_ANY_THROW_(statement, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AlwaysTrue()) { \
- bool gtest_caught_any = false; \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } \
- catch (...) { \
- gtest_caught_any = true; \
- } \
- if (!gtest_caught_any) { \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
- fail("Expected: " #statement " throws an exception.\n" \
- " Actual: it doesn't.")
- #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (const ::testing::AssertionResult gtest_ar_ = \
- ::testing::AssertionResult(expression)) \
- ; \
- else \
- fail(::testing::internal::GetBoolAssertionFailureMessage(\
- gtest_ar_, text, #actual, #expected).c_str())
- #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AlwaysTrue()) { \
- ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
- fail("Expected: " #statement " doesn't generate new fatal " \
- "failures in the current thread.\n" \
- " Actual: it does.")
- #define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
- test_suite_name##_##test_name##_Test
- #define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
- static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
- "test_suite_name must not be empty"); \
- static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
- "test_name must not be empty"); \
- class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
- : public parent_class { \
- public: \
- GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
- ~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
- GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
- \
- private: \
- void TestBody() override; \
- static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
- }; \
- \
- ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)::test_info_ = \
- ::testing::internal::MakeAndRegisterTestInfo( \
- #test_suite_name, #test_name, nullptr, nullptr, \
- ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \
- ::testing::internal::SuiteApiResolver< \
- parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__), \
- ::testing::internal::SuiteApiResolver< \
- parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__), \
- new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_( \
- test_suite_name, test_name)>); \
- void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
- #include <atomic>
- #include <memory>
- #include <ostream>
- #include <string>
- #include <type_traits>
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
- #include <functional>
- #include <memory>
- #include <ostream> // NOLINT
- #include <sstream>
- #include <string>
- #include <tuple>
- #include <type_traits>
- #include <utility>
- #include <vector>
- namespace testing {
- namespace internal {
- template <typename T>
- void UniversalPrint(const T& value, ::std::ostream* os);
- struct ContainerPrinter {
- template <typename T,
- typename = typename std::enable_if<
- (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
- !IsRecursiveContainer<T>::value>::type>
- static void PrintValue(const T& container, std::ostream* os) {
- const size_t kMaxCount = 32;
- *os << '{';
- size_t count = 0;
- for (auto&& elem : container) {
- if (count > 0) {
- *os << ',';
- if (count == kMaxCount) {
- *os << " ...";
- break;
- }
- }
- *os << ' ';
-
-
- internal::UniversalPrint(elem, os);
- ++count;
- }
- if (count > 0) {
- *os << ' ';
- }
- *os << '}';
- }
- };
- struct FunctionPointerPrinter {
- template <typename T, typename = typename std::enable_if<
- std::is_function<T>::value>::type>
- static void PrintValue(T* p, ::std::ostream* os) {
- if (p == nullptr) {
- *os << "NULL";
- } else {
-
-
-
- *os << reinterpret_cast<const void*>(p);
- }
- }
- };
- struct PointerPrinter {
- template <typename T>
- static void PrintValue(T* p, ::std::ostream* os) {
- if (p == nullptr) {
- *os << "NULL";
- } else {
-
-
-
- *os << p;
- }
- }
- };
- namespace internal_stream_operator_without_lexical_name_lookup {
- struct LookupBlocker {};
- void operator<<(LookupBlocker, LookupBlocker);
- struct StreamPrinter {
- template <typename T,
-
-
- typename = typename std::enable_if<
- !std::is_member_pointer<T>::value>::type,
-
-
- typename = decltype(std::declval<std::ostream&>()
- << std::declval<const T&>())>
- static void PrintValue(const T& value, ::std::ostream* os) {
-
-
- *os << value;
- }
- };
- }
- struct ProtobufPrinter {
-
-
-
- static const size_t kProtobufOneLinerMaxLength = 50;
- template <typename T,
- typename = typename std::enable_if<
- internal::HasDebugStringAndShortDebugString<T>::value>::type>
- static void PrintValue(const T& value, ::std::ostream* os) {
- std::string pretty_str = value.ShortDebugString();
- if (pretty_str.length() > kProtobufOneLinerMaxLength) {
- pretty_str = "\n" + value.DebugString();
- }
- *os << ("<" + pretty_str + ">");
- }
- };
- struct ConvertibleToIntegerPrinter {
-
-
-
-
-
-
-
- static void PrintValue(internal::BiggestInt value, ::std::ostream* os) {
- *os << value;
- }
- };
- struct ConvertibleToStringViewPrinter {
- #if GTEST_INTERNAL_HAS_STRING_VIEW
- static void PrintValue(internal::StringView value, ::std::ostream* os) {
- internal::UniversalPrint(value, os);
- }
- #endif
- };
- GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
- size_t count,
- ::std::ostream* os);
- struct RawBytesPrinter {
-
- template <typename T, size_t = sizeof(T)>
- static void PrintValue(const T& value, ::std::ostream* os) {
- PrintBytesInObjectTo(
- static_cast<const unsigned char*>(
-
- reinterpret_cast<const void*>(std::addressof(value))),
- sizeof(value), os);
- }
- };
- struct FallbackPrinter {
- template <typename T>
- static void PrintValue(const T&, ::std::ostream* os) {
- *os << "(incomplete type)";
- }
- };
- template <typename T, typename E, typename Printer, typename... Printers>
- struct FindFirstPrinter : FindFirstPrinter<T, E, Printers...> {};
- template <typename T, typename Printer, typename... Printers>
- struct FindFirstPrinter<
- T, decltype(Printer::PrintValue(std::declval<const T&>(), nullptr)),
- Printer, Printers...> {
- using type = Printer;
- };
- template <typename T>
- void PrintWithFallback(const T& value, ::std::ostream* os) {
- using Printer = typename FindFirstPrinter<
- T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
- internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
- ProtobufPrinter, ConvertibleToIntegerPrinter,
- ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;
- Printer::PrintValue(value, os);
- }
- template <typename ToPrint, typename OtherOperand>
- class FormatForComparison {
- public:
- static ::std::string Format(const ToPrint& value) {
- return ::testing::PrintToString(value);
- }
- };
- template <typename ToPrint, size_t N, typename OtherOperand>
- class FormatForComparison<ToPrint[N], OtherOperand> {
- public:
- static ::std::string Format(const ToPrint* value) {
- return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
- }
- };
- #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \
- template <typename OtherOperand> \
- class FormatForComparison<CharType*, OtherOperand> { \
- public: \
- static ::std::string Format(CharType* value) { \
- return ::testing::PrintToString(static_cast<const void*>(value)); \
- } \
- }
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
- #ifdef __cpp_char8_t
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char8_t);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char8_t);
- #endif
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char16_t);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char16_t);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char32_t);
- GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char32_t);
- #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
- #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
- template <> \
- class FormatForComparison<CharType*, OtherStringType> { \
- public: \
- static ::std::string Format(CharType* value) { \
- return ::testing::PrintToString(value); \
- } \
- }
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
- #ifdef __cpp_char8_t
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char8_t, ::std::u8string);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char8_t, ::std::u8string);
- #endif
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char16_t, ::std::u16string);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char16_t, ::std::u16string);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char32_t, ::std::u32string);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char32_t, ::std::u32string);
- #if GTEST_HAS_STD_WSTRING
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
- GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
- #endif
- #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
- template <typename T1, typename T2>
- std::string FormatForComparisonFailureMessage(
- const T1& value, const T2& ) {
- return FormatForComparison<T1, T2>::Format(value);
- }
- template <typename T>
- class UniversalPrinter;
- template <typename T>
- void PrintTo(const T& value, ::std::ostream* os) {
- internal::PrintWithFallback(value, os);
- }
- GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
- GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
- inline void PrintTo(char c, ::std::ostream* os) {
-
-
-
- PrintTo(static_cast<unsigned char>(c), os);
- }
- inline void PrintTo(bool x, ::std::ostream* os) {
- *os << (x ? "true" : "false");
- }
- GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
- GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
- inline void PrintTo(char16_t c, ::std::ostream* os) {
- PrintTo(ImplicitCast_<char32_t>(c), os);
- }
- #ifdef __cpp_char8_t
- inline void PrintTo(char8_t c, ::std::ostream* os) {
- PrintTo(ImplicitCast_<char32_t>(c), os);
- }
- #endif
- GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
- inline void PrintTo(char* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const char*>(s), os);
- }
- inline void PrintTo(const signed char* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const void*>(s), os);
- }
- inline void PrintTo(signed char* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const void*>(s), os);
- }
- inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const void*>(s), os);
- }
- inline void PrintTo(unsigned char* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const void*>(s), os);
- }
- #ifdef __cpp_char8_t
- GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
- inline void PrintTo(char8_t* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const char8_t*>(s), os);
- }
- #endif
- GTEST_API_ void PrintTo(const char16_t* s, ::std::ostream* os);
- inline void PrintTo(char16_t* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const char16_t*>(s), os);
- }
- GTEST_API_ void PrintTo(const char32_t* s, ::std::ostream* os);
- inline void PrintTo(char32_t* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const char32_t*>(s), os);
- }
- #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
- GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
- inline void PrintTo(wchar_t* s, ::std::ostream* os) {
- PrintTo(ImplicitCast_<const wchar_t*>(s), os);
- }
- #endif
- template <typename T>
- void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
- UniversalPrint(a[0], os);
- for (size_t i = 1; i != count; i++) {
- *os << ", ";
- UniversalPrint(a[i], os);
- }
- }
- GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
- inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
- PrintStringTo(s, os);
- }
- #ifdef __cpp_char8_t
- GTEST_API_ void PrintU8StringTo(const ::std::u8string& s, ::std::ostream* os);
- inline void PrintTo(const ::std::u8string& s, ::std::ostream* os) {
- PrintU8StringTo(s, os);
- }
- #endif
- GTEST_API_ void PrintU16StringTo(const ::std::u16string& s, ::std::ostream* os);
- inline void PrintTo(const ::std::u16string& s, ::std::ostream* os) {
- PrintU16StringTo(s, os);
- }
- GTEST_API_ void PrintU32StringTo(const ::std::u32string& s, ::std::ostream* os);
- inline void PrintTo(const ::std::u32string& s, ::std::ostream* os) {
- PrintU32StringTo(s, os);
- }
- #if GTEST_HAS_STD_WSTRING
- GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
- inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
- PrintWideStringTo(s, os);
- }
- #endif
- #if GTEST_INTERNAL_HAS_STRING_VIEW
- inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
- PrintTo(::std::string(sp), os);
- }
- #endif
- inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
- template <typename T>
- void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
- UniversalPrinter<T&>::Print(ref.get(), os);
- }
- inline const void* VoidifyPointer(const void* p) { return p; }
- inline const void* VoidifyPointer(volatile const void* p) {
- return const_cast<const void*>(p);
- }
- template <typename T, typename Ptr>
- void PrintSmartPointer(const Ptr& ptr, std::ostream* os, char) {
- if (ptr == nullptr) {
- *os << "(nullptr)";
- } else {
-
- *os << "(" << (VoidifyPointer)(ptr.get()) << ")";
- }
- }
- template <typename T, typename Ptr,
- typename = typename std::enable_if<!std::is_void<T>::value &&
- !std::is_array<T>::value>::type>
- void PrintSmartPointer(const Ptr& ptr, std::ostream* os, int) {
- if (ptr == nullptr) {
- *os << "(nullptr)";
- } else {
- *os << "(ptr = " << (VoidifyPointer)(ptr.get()) << ", value = ";
- UniversalPrinter<T>::Print(*ptr, os);
- *os << ")";
- }
- }
- template <typename T, typename D>
- void PrintTo(const std::unique_ptr<T, D>& ptr, std::ostream* os) {
- (PrintSmartPointer<T>)(ptr, os, 0);
- }
- template <typename T>
- void PrintTo(const std::shared_ptr<T>& ptr, std::ostream* os) {
- (PrintSmartPointer<T>)(ptr, os, 0);
- }
- template <typename T>
- void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
- ::std::ostream*) {}
- template <typename T, size_t I>
- void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
- ::std::ostream* os) {
- PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
- GTEST_INTENTIONAL_CONST_COND_PUSH_()
- if (I > 1) {
- GTEST_INTENTIONAL_CONST_COND_POP_()
- *os << ", ";
- }
- UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
- std::get<I - 1>(t), os);
- }
- template <typename... Types>
- void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
- *os << "(";
- PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
- *os << ")";
- }
- template <typename T1, typename T2>
- void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
- *os << '(';
-
-
- UniversalPrinter<T1>::Print(value.first, os);
- *os << ", ";
- UniversalPrinter<T2>::Print(value.second, os);
- *os << ')';
- }
- template <typename T>
- class UniversalPrinter {
- public:
-
-
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
-
-
-
- static void Print(const T& value, ::std::ostream* os) {
-
-
-
-
-
-
-
-
- PrintTo(value, os);
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- };
- template <typename T>
- class UniversalPrinter<const T> : public UniversalPrinter<T> {};
- #if GTEST_INTERNAL_HAS_ANY
- template <>
- class UniversalPrinter<Any> {
- public:
- static void Print(const Any& value, ::std::ostream* os) {
- if (value.has_value()) {
- *os << "value of type " << GetTypeName(value);
- } else {
- *os << "no value";
- }
- }
- private:
- static std::string GetTypeName(const Any& value) {
- #if GTEST_HAS_RTTI
- return internal::GetTypeName(value.type());
- #else
- static_cast<void>(value);
- return "<unknown_type>";
- #endif
- }
- };
- #endif
- #if GTEST_INTERNAL_HAS_OPTIONAL
- template <typename T>
- class UniversalPrinter<Optional<T>> {
- public:
- static void Print(const Optional<T>& value, ::std::ostream* os) {
- *os << '(';
- if (!value) {
- *os << "nullopt";
- } else {
- UniversalPrint(*value, os);
- }
- *os << ')';
- }
- };
- #endif
- #if GTEST_INTERNAL_HAS_VARIANT
- template <typename... T>
- class UniversalPrinter<Variant<T...>> {
- public:
- static void Print(const Variant<T...>& value, ::std::ostream* os) {
- *os << '(';
- #if GTEST_HAS_ABSL
- absl::visit(Visitor{os, value.index()}, value);
- #else
- std::visit(Visitor{os, value.index()}, value);
- #endif
- *os << ')';
- }
- private:
- struct Visitor {
- template <typename U>
- void operator()(const U& u) const {
- *os << "'" << GetTypeName<U>() << "(index = " << index
- << ")' with value ";
- UniversalPrint(u, os);
- }
- ::std::ostream* os;
- std::size_t index;
- };
- };
- #endif
- template <typename T>
- void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
- if (len == 0) {
- *os << "{}";
- } else {
- *os << "{ ";
- const size_t kThreshold = 18;
- const size_t kChunkSize = 8;
-
-
-
- if (len <= kThreshold) {
- PrintRawArrayTo(begin, len, os);
- } else {
- PrintRawArrayTo(begin, kChunkSize, os);
- *os << ", ..., ";
- PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
- }
- *os << " }";
- }
- }
- GTEST_API_ void UniversalPrintArray(
- const char* begin, size_t len, ::std::ostream* os);
- #ifdef __cpp_char8_t
- GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
- ::std::ostream* os);
- #endif
- GTEST_API_ void UniversalPrintArray(const char16_t* begin, size_t len,
- ::std::ostream* os);
- GTEST_API_ void UniversalPrintArray(const char32_t* begin, size_t len,
- ::std::ostream* os);
- GTEST_API_ void UniversalPrintArray(
- const wchar_t* begin, size_t len, ::std::ostream* os);
- template <typename T, size_t N>
- class UniversalPrinter<T[N]> {
- public:
-
-
- static void Print(const T (&a)[N], ::std::ostream* os) {
- UniversalPrintArray(a, N, os);
- }
- };
- template <typename T>
- class UniversalPrinter<T&> {
- public:
-
-
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
- static void Print(const T& value, ::std::ostream* os) {
-
-
- *os << "@" << reinterpret_cast<const void*>(&value) << " ";
-
- UniversalPrint(value, os);
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- };
- template <typename T>
- class UniversalTersePrinter {
- public:
- static void Print(const T& value, ::std::ostream* os) {
- UniversalPrint(value, os);
- }
- };
- template <typename T>
- class UniversalTersePrinter<T&> {
- public:
- static void Print(const T& value, ::std::ostream* os) {
- UniversalPrint(value, os);
- }
- };
- template <typename T, size_t N>
- class UniversalTersePrinter<T[N]> {
- public:
- static void Print(const T (&value)[N], ::std::ostream* os) {
- UniversalPrinter<T[N]>::Print(value, os);
- }
- };
- template <>
- class UniversalTersePrinter<const char*> {
- public:
- static void Print(const char* str, ::std::ostream* os) {
- if (str == nullptr) {
- *os << "NULL";
- } else {
- UniversalPrint(std::string(str), os);
- }
- }
- };
- template <>
- class UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {
- };
- #ifdef __cpp_char8_t
- template <>
- class UniversalTersePrinter<const char8_t*> {
- public:
- static void Print(const char8_t* str, ::std::ostream* os) {
- if (str == nullptr) {
- *os << "NULL";
- } else {
- UniversalPrint(::std::u8string(str), os);
- }
- }
- };
- template <>
- class UniversalTersePrinter<char8_t*>
- : public UniversalTersePrinter<const char8_t*> {};
- #endif
- template <>
- class UniversalTersePrinter<const char16_t*> {
- public:
- static void Print(const char16_t* str, ::std::ostream* os) {
- if (str == nullptr) {
- *os << "NULL";
- } else {
- UniversalPrint(::std::u16string(str), os);
- }
- }
- };
- template <>
- class UniversalTersePrinter<char16_t*>
- : public UniversalTersePrinter<const char16_t*> {};
- template <>
- class UniversalTersePrinter<const char32_t*> {
- public:
- static void Print(const char32_t* str, ::std::ostream* os) {
- if (str == nullptr) {
- *os << "NULL";
- } else {
- UniversalPrint(::std::u32string(str), os);
- }
- }
- };
- template <>
- class UniversalTersePrinter<char32_t*>
- : public UniversalTersePrinter<const char32_t*> {};
- #if GTEST_HAS_STD_WSTRING
- template <>
- class UniversalTersePrinter<const wchar_t*> {
- public:
- static void Print(const wchar_t* str, ::std::ostream* os) {
- if (str == nullptr) {
- *os << "NULL";
- } else {
- UniversalPrint(::std::wstring(str), os);
- }
- }
- };
- #endif
- template <>
- class UniversalTersePrinter<wchar_t*> {
- public:
- static void Print(wchar_t* str, ::std::ostream* os) {
- UniversalTersePrinter<const wchar_t*>::Print(str, os);
- }
- };
- template <typename T>
- void UniversalTersePrint(const T& value, ::std::ostream* os) {
- UniversalTersePrinter<T>::Print(value, os);
- }
- template <typename T>
- void UniversalPrint(const T& value, ::std::ostream* os) {
-
-
- typedef T T1;
- UniversalPrinter<T1>::Print(value, os);
- }
- typedef ::std::vector< ::std::string> Strings;
-
-
- template <typename Tuple>
- void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
- Strings*) {}
- template <typename Tuple, size_t I>
- void TersePrintPrefixToStrings(const Tuple& t,
- std::integral_constant<size_t, I>,
- Strings* strings) {
- TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
- strings);
- ::std::stringstream ss;
- UniversalTersePrint(std::get<I - 1>(t), &ss);
- strings->push_back(ss.str());
- }
- template <typename Tuple>
- Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
- Strings result;
- TersePrintPrefixToStrings(
- value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
- &result);
- return result;
- }
- }
- template <typename T>
- ::std::string PrintToString(const T& value) {
- ::std::stringstream ss;
- internal::UniversalTersePrinter<T>::Print(value, &ss);
- return ss.str();
- }
- }
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
- #endif
- #endif
- #if defined(_MSC_VER) && _MSC_VER >= 1915
- #define GTEST_MAYBE_5046_ 5046
- #else
- #define GTEST_MAYBE_5046_
- #endif
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(
- 4251 GTEST_MAYBE_5046_
- )
- namespace testing {
- class MatchResultListener {
- public:
-
-
-
- explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
- virtual ~MatchResultListener() = 0;
-
-
- template <typename T>
- MatchResultListener& operator<<(const T& x) {
- if (stream_ != nullptr) *stream_ << x;
- return *this;
- }
-
- ::std::ostream* stream() { return stream_; }
-
-
-
-
- bool IsInterested() const { return stream_ != nullptr; }
- private:
- ::std::ostream* const stream_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
- };
- inline MatchResultListener::~MatchResultListener() {
- }
- class GTEST_API_ MatcherDescriberInterface {
- public:
- virtual ~MatcherDescriberInterface() {}
-
-
-
-
-
- virtual void DescribeTo(::std::ostream* os) const = 0;
-
-
-
-
-
-
- virtual void DescribeNegationTo(::std::ostream* os) const {
- *os << "not (";
- DescribeTo(os);
- *os << ")";
- }
- };
- template <typename T>
- class MatcherInterface : public MatcherDescriberInterface {
- public:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
-
-
-
- };
- namespace internal {
- struct AnyEq {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a == b; }
- };
- struct AnyNe {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a != b; }
- };
- struct AnyLt {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a < b; }
- };
- struct AnyGt {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a > b; }
- };
- struct AnyLe {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a <= b; }
- };
- struct AnyGe {
- template <typename A, typename B>
- bool operator()(const A& a, const B& b) const { return a >= b; }
- };
- class DummyMatchResultListener : public MatchResultListener {
- public:
- DummyMatchResultListener() : MatchResultListener(nullptr) {}
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
- };
- class StreamMatchResultListener : public MatchResultListener {
- public:
- explicit StreamMatchResultListener(::std::ostream* os)
- : MatchResultListener(os) {}
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
- };
- struct SharedPayloadBase {
- std::atomic<int> ref{1};
- void Ref() { ref.fetch_add(1, std::memory_order_relaxed); }
- bool Unref() { return ref.fetch_sub(1, std::memory_order_acq_rel) == 1; }
- };
- template <typename T>
- struct SharedPayload : SharedPayloadBase {
- explicit SharedPayload(const T& v) : value(v) {}
- explicit SharedPayload(T&& v) : value(std::move(v)) {}
- static void Destroy(SharedPayloadBase* shared) {
- delete static_cast<SharedPayload*>(shared);
- }
- T value;
- };
- template <typename T>
- class MatcherBase : private MatcherDescriberInterface {
- public:
-
-
- bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
- GTEST_CHECK_(vtable_ != nullptr);
- return vtable_->match_and_explain(*this, x, listener);
- }
-
- bool Matches(const T& x) const {
- DummyMatchResultListener dummy;
- return MatchAndExplain(x, &dummy);
- }
-
- void DescribeTo(::std::ostream* os) const final {
- GTEST_CHECK_(vtable_ != nullptr);
- vtable_->describe(*this, os, false);
- }
-
- void DescribeNegationTo(::std::ostream* os) const final {
- GTEST_CHECK_(vtable_ != nullptr);
- vtable_->describe(*this, os, true);
- }
-
- void ExplainMatchResultTo(const T& x, ::std::ostream* os) const {
- StreamMatchResultListener listener(os);
- MatchAndExplain(x, &listener);
- }
-
-
-
- const MatcherDescriberInterface* GetDescriber() const {
- if (vtable_ == nullptr) return nullptr;
- return vtable_->get_describer(*this);
- }
- protected:
- MatcherBase() : vtable_(nullptr) {}
-
- template <typename U>
- explicit MatcherBase(const MatcherInterface<U>* impl) {
- Init(impl);
- }
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- MatcherBase(M&& m) {
- Init(std::forward<M>(m));
- }
- MatcherBase(const MatcherBase& other)
- : vtable_(other.vtable_), buffer_(other.buffer_) {
- if (IsShared()) buffer_.shared->Ref();
- }
- MatcherBase& operator=(const MatcherBase& other) {
- if (this == &other) return *this;
- Destroy();
- vtable_ = other.vtable_;
- buffer_ = other.buffer_;
- if (IsShared()) buffer_.shared->Ref();
- return *this;
- }
- MatcherBase(MatcherBase&& other)
- : vtable_(other.vtable_), buffer_(other.buffer_) {
- other.vtable_ = nullptr;
- }
- MatcherBase& operator=(MatcherBase&& other) {
- if (this == &other) return *this;
- Destroy();
- vtable_ = other.vtable_;
- buffer_ = other.buffer_;
- other.vtable_ = nullptr;
- return *this;
- }
- ~MatcherBase() override { Destroy(); }
- private:
- struct VTable {
- bool (*match_and_explain)(const MatcherBase&, const T&,
- MatchResultListener*);
- void (*describe)(const MatcherBase&, std::ostream*, bool negation);
-
-
- const MatcherDescriberInterface* (*get_describer)(const MatcherBase&);
-
- void (*shared_destroy)(SharedPayloadBase*);
- };
- bool IsShared() const {
- return vtable_ != nullptr && vtable_->shared_destroy != nullptr;
- }
-
- template <typename P>
- static auto MatchAndExplainImpl(const MatcherBase& m, const T& value,
- MatchResultListener* listener)
- -> decltype(P::Get(m).MatchAndExplain(value, listener->stream())) {
- return P::Get(m).MatchAndExplain(value, listener->stream());
- }
- template <typename P>
- static auto MatchAndExplainImpl(const MatcherBase& m, const T& value,
- MatchResultListener* listener)
- -> decltype(P::Get(m).MatchAndExplain(value, listener)) {
- return P::Get(m).MatchAndExplain(value, listener);
- }
- template <typename P>
- static void DescribeImpl(const MatcherBase& m, std::ostream* os,
- bool negation) {
- if (negation) {
- P::Get(m).DescribeNegationTo(os);
- } else {
- P::Get(m).DescribeTo(os);
- }
- }
- template <typename P>
- static const MatcherDescriberInterface* GetDescriberImpl(
- const MatcherBase& m) {
-
-
-
-
-
-
- return std::get<(
- std::is_convertible<decltype(&P::Get(m)),
- const MatcherDescriberInterface*>::value
- ? 1
- : 0)>(std::make_tuple(&m, &P::Get(m)));
- }
- template <typename P>
- const VTable* GetVTable() {
- static constexpr VTable kVTable = {&MatchAndExplainImpl<P>,
- &DescribeImpl<P>, &GetDescriberImpl<P>,
- P::shared_destroy};
- return &kVTable;
- }
- union Buffer {
-
- void* ptr;
- double d;
- int64_t i;
-
- SharedPayloadBase* shared;
- };
- void Destroy() {
- if (IsShared() && buffer_.shared->Unref()) {
- vtable_->shared_destroy(buffer_.shared);
- }
- }
- template <typename M>
- static constexpr bool IsInlined() {
- return sizeof(M) <= sizeof(Buffer) && alignof(M) <= alignof(Buffer) &&
- std::is_trivially_copy_constructible<M>::value &&
- std::is_trivially_destructible<M>::value;
- }
- template <typename M, bool = MatcherBase::IsInlined<M>()>
- struct ValuePolicy {
- static const M& Get(const MatcherBase& m) {
-
-
- const M *ptr = static_cast<const M*>(
- static_cast<const void*>(&m.buffer_));
- return *ptr;
- }
- static void Init(MatcherBase& m, M impl) {
- ::new (static_cast<void*>(&m.buffer_)) M(impl);
- }
- static constexpr auto shared_destroy = nullptr;
- };
- template <typename M>
- struct ValuePolicy<M, false> {
- using Shared = SharedPayload<M>;
- static const M& Get(const MatcherBase& m) {
- return static_cast<Shared*>(m.buffer_.shared)->value;
- }
- template <typename Arg>
- static void Init(MatcherBase& m, Arg&& arg) {
- m.buffer_.shared = new Shared(std::forward<Arg>(arg));
- }
- static constexpr auto shared_destroy = &Shared::Destroy;
- };
- template <typename U, bool B>
- struct ValuePolicy<const MatcherInterface<U>*, B> {
- using M = const MatcherInterface<U>;
- using Shared = SharedPayload<std::unique_ptr<M>>;
- static const M& Get(const MatcherBase& m) {
- return *static_cast<Shared*>(m.buffer_.shared)->value;
- }
- static void Init(MatcherBase& m, M* impl) {
- m.buffer_.shared = new Shared(std::unique_ptr<M>(impl));
- }
- static constexpr auto shared_destroy = &Shared::Destroy;
- };
- template <typename M>
- void Init(M&& m) {
- using MM = typename std::decay<M>::type;
- using Policy = ValuePolicy<MM>;
- vtable_ = GetVTable<Policy>();
- Policy::Init(*this, std::forward<M>(m));
- }
- const VTable* vtable_;
- Buffer buffer_;
- };
- }
- template <typename T>
- class Matcher : public internal::MatcherBase<T> {
- public:
-
-
-
- explicit Matcher() {}
-
- explicit Matcher(const MatcherInterface<const T&>* impl)
- : internal::MatcherBase<T>(impl) {}
- template <typename U>
- explicit Matcher(
- const MatcherInterface<U>* impl,
- typename std::enable_if<!std::is_same<U, const U&>::value>::type* =
- nullptr)
- : internal::MatcherBase<T>(impl) {}
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- Matcher(M&& m) : internal::MatcherBase<T>(std::forward<M>(m)) {}
-
-
- Matcher(T value);
- };
- template <>
- class GTEST_API_ Matcher<const std::string&>
- : public internal::MatcherBase<const std::string&> {
- public:
- Matcher() {}
- explicit Matcher(const MatcherInterface<const std::string&>* impl)
- : internal::MatcherBase<const std::string&>(impl) {}
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<const std::string&>(std::forward<M>(m)) {}
-
-
- Matcher(const std::string& s);
-
- Matcher(const char* s);
- };
- template <>
- class GTEST_API_ Matcher<std::string>
- : public internal::MatcherBase<std::string> {
- public:
- Matcher() {}
- explicit Matcher(const MatcherInterface<const std::string&>* impl)
- : internal::MatcherBase<std::string>(impl) {}
- explicit Matcher(const MatcherInterface<std::string>* impl)
- : internal::MatcherBase<std::string>(impl) {}
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<std::string>(std::forward<M>(m)) {}
-
-
- Matcher(const std::string& s);
-
- Matcher(const char* s);
- };
- #if GTEST_INTERNAL_HAS_STRING_VIEW
- template <>
- class GTEST_API_ Matcher<const internal::StringView&>
- : public internal::MatcherBase<const internal::StringView&> {
- public:
- Matcher() {}
- explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
- : internal::MatcherBase<const internal::StringView&>(impl) {}
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<const internal::StringView&>(std::forward<M>(m)) {
- }
-
-
- Matcher(const std::string& s);
-
- Matcher(const char* s);
-
- Matcher(internal::StringView s);
- };
- template <>
- class GTEST_API_ Matcher<internal::StringView>
- : public internal::MatcherBase<internal::StringView> {
- public:
- Matcher() {}
- explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
- : internal::MatcherBase<internal::StringView>(impl) {}
- explicit Matcher(const MatcherInterface<internal::StringView>* impl)
- : internal::MatcherBase<internal::StringView>(impl) {}
- template <typename M, typename = typename std::remove_reference<
- M>::type::is_gtest_matcher>
- Matcher(M&& m)
- : internal::MatcherBase<internal::StringView>(std::forward<M>(m)) {}
-
-
- Matcher(const std::string& s);
-
- Matcher(const char* s);
-
- Matcher(internal::StringView s);
- };
- #endif
- template <typename T>
- std::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) {
- matcher.DescribeTo(&os);
- return os;
- }
- template <class Impl>
- class PolymorphicMatcher {
- public:
- explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
-
-
- Impl& mutable_impl() { return impl_; }
-
-
- const Impl& impl() const { return impl_; }
- template <typename T>
- operator Matcher<T>() const {
- return Matcher<T>(new MonomorphicImpl<const T&>(impl_));
- }
- private:
- template <typename T>
- class MonomorphicImpl : public MatcherInterface<T> {
- public:
- explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
- void DescribeTo(::std::ostream* os) const override { impl_.DescribeTo(os); }
- void DescribeNegationTo(::std::ostream* os) const override {
- impl_.DescribeNegationTo(os);
- }
- bool MatchAndExplain(T x, MatchResultListener* listener) const override {
- return impl_.MatchAndExplain(x, listener);
- }
- private:
- const Impl impl_;
- };
- Impl impl_;
- };
- template <typename T>
- inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
- return Matcher<T>(impl);
- }
- template <class Impl>
- inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
- return PolymorphicMatcher<Impl>(impl);
- }
- namespace internal {
- template <typename D, typename Rhs, typename Op>
- class ComparisonBase {
- public:
- explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {}
- using is_gtest_matcher = void;
- template <typename Lhs>
- bool MatchAndExplain(const Lhs& lhs, std::ostream*) const {
- return Op()(lhs, Unwrap(rhs_));
- }
- void DescribeTo(std::ostream* os) const {
- *os << D::Desc() << " ";
- UniversalPrint(Unwrap(rhs_), os);
- }
- void DescribeNegationTo(std::ostream* os) const {
- *os << D::NegatedDesc() << " ";
- UniversalPrint(Unwrap(rhs_), os);
- }
- private:
- template <typename T>
- static const T& Unwrap(const T& v) {
- return v;
- }
- template <typename T>
- static const T& Unwrap(std::reference_wrapper<T> v) {
- return v;
- }
- Rhs rhs_;
- };
- template <typename Rhs>
- class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
- public:
- explicit EqMatcher(const Rhs& rhs)
- : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }
- static const char* Desc() { return "is equal to"; }
- static const char* NegatedDesc() { return "isn't equal to"; }
- };
- template <typename Rhs>
- class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
- public:
- explicit NeMatcher(const Rhs& rhs)
- : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }
- static const char* Desc() { return "isn't equal to"; }
- static const char* NegatedDesc() { return "is equal to"; }
- };
- template <typename Rhs>
- class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
- public:
- explicit LtMatcher(const Rhs& rhs)
- : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }
- static const char* Desc() { return "is <"; }
- static const char* NegatedDesc() { return "isn't <"; }
- };
- template <typename Rhs>
- class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
- public:
- explicit GtMatcher(const Rhs& rhs)
- : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }
- static const char* Desc() { return "is >"; }
- static const char* NegatedDesc() { return "isn't >"; }
- };
- template <typename Rhs>
- class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
- public:
- explicit LeMatcher(const Rhs& rhs)
- : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }
- static const char* Desc() { return "is <="; }
- static const char* NegatedDesc() { return "isn't <="; }
- };
- template <typename Rhs>
- class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
- public:
- explicit GeMatcher(const Rhs& rhs)
- : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }
- static const char* Desc() { return "is >="; }
- static const char* NegatedDesc() { return "isn't >="; }
- };
- template <typename T, typename = typename std::enable_if<
- std::is_constructible<std::string, T>::value>::type>
- using StringLike = T;
- class MatchesRegexMatcher {
- public:
- MatchesRegexMatcher(const RE* regex, bool full_match)
- : regex_(regex), full_match_(full_match) {}
- #if GTEST_INTERNAL_HAS_STRING_VIEW
- bool MatchAndExplain(const internal::StringView& s,
- MatchResultListener* listener) const {
- return MatchAndExplain(std::string(s), listener);
- }
- #endif
-
-
-
-
-
- template <typename CharType>
- bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
- return s != nullptr && MatchAndExplain(std::string(s), listener);
- }
-
-
-
-
- template <class MatcheeStringType>
- bool MatchAndExplain(const MatcheeStringType& s,
- MatchResultListener* ) const {
- const std::string& s2(s);
- return full_match_ ? RE::FullMatch(s2, *regex_)
- : RE::PartialMatch(s2, *regex_);
- }
- void DescribeTo(::std::ostream* os) const {
- *os << (full_match_ ? "matches" : "contains") << " regular expression ";
- UniversalPrinter<std::string>::Print(regex_->pattern(), os);
- }
- void DescribeNegationTo(::std::ostream* os) const {
- *os << "doesn't " << (full_match_ ? "match" : "contain")
- << " regular expression ";
- UniversalPrinter<std::string>::Print(regex_->pattern(), os);
- }
- private:
- const std::shared_ptr<const RE> regex_;
- const bool full_match_;
- };
- }
- inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
- const internal::RE* regex) {
- return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
- }
- template <typename T = std::string>
- PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
- const internal::StringLike<T>& regex) {
- return MatchesRegex(new internal::RE(std::string(regex)));
- }
- inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
- const internal::RE* regex) {
- return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
- }
- template <typename T = std::string>
- PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
- const internal::StringLike<T>& regex) {
- return ContainsRegex(new internal::RE(std::string(regex)));
- }
- template <typename T>
- inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
- template <typename T>
- Matcher<T>::Matcher(T value) { *this = Eq(value); }
- template <typename Lhs, typename Rhs>
- inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
- template <typename Rhs>
- inline internal::GeMatcher<Rhs> Ge(Rhs x) {
- return internal::GeMatcher<Rhs>(x);
- }
- template <typename Rhs>
- inline internal::GtMatcher<Rhs> Gt(Rhs x) {
- return internal::GtMatcher<Rhs>(x);
- }
- template <typename Rhs>
- inline internal::LeMatcher<Rhs> Le(Rhs x) {
- return internal::LeMatcher<Rhs>(x);
- }
- template <typename Rhs>
- inline internal::LtMatcher<Rhs> Lt(Rhs x) {
- return internal::LtMatcher<Rhs>(x);
- }
- template <typename Rhs>
- inline internal::NeMatcher<Rhs> Ne(Rhs x) {
- return internal::NeMatcher<Rhs>(x);
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- #include <stdio.h>
- #include <memory>
- namespace testing {
- namespace internal {
- GTEST_DECLARE_string_(internal_run_death_test);
- const char kDeathTestStyleFlag[] = "death_test_style";
- const char kDeathTestUseFork[] = "death_test_use_fork";
- const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
- #if GTEST_HAS_DEATH_TEST
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- class GTEST_API_ DeathTest {
- public:
-
-
-
-
-
-
-
-
- static bool Create(const char* statement, Matcher<const std::string&> matcher,
- const char* file, int line, DeathTest** test);
- DeathTest();
- virtual ~DeathTest() { }
-
- class ReturnSentinel {
- public:
- explicit ReturnSentinel(DeathTest* test) : test_(test) { }
- ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
- private:
- DeathTest* const test_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
- } GTEST_ATTRIBUTE_UNUSED_;
-
-
-
-
-
- enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
-
- enum AbortReason {
- TEST_ENCOUNTERED_RETURN_STATEMENT,
- TEST_THREW_EXCEPTION,
- TEST_DID_NOT_DIE
- };
-
- virtual TestRole AssumeRole() = 0;
-
- virtual int Wait() = 0;
-
-
-
-
-
-
-
- virtual bool Passed(bool exit_status_ok) = 0;
-
- virtual void Abort(AbortReason reason) = 0;
-
-
- static const char* LastMessage();
- static void set_last_death_test_message(const std::string& message);
- private:
-
- static std::string last_death_test_message_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
- };
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- class DeathTestFactory {
- public:
- virtual ~DeathTestFactory() { }
- virtual bool Create(const char* statement,
- Matcher<const std::string&> matcher, const char* file,
- int line, DeathTest** test) = 0;
- };
- class DefaultDeathTestFactory : public DeathTestFactory {
- public:
- bool Create(const char* statement, Matcher<const std::string&> matcher,
- const char* file, int line, DeathTest** test) override;
- };
- GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
- inline Matcher<const ::std::string&> MakeDeathTestMatcher(
- ::testing::internal::RE regex) {
- return ContainsRegex(regex.pattern());
- }
- inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
- return ContainsRegex(regex);
- }
- inline Matcher<const ::std::string&> MakeDeathTestMatcher(
- const ::std::string& regex) {
- return ContainsRegex(regex);
- }
- inline Matcher<const ::std::string&> MakeDeathTestMatcher(
- Matcher<const ::std::string&> matcher) {
- return matcher;
- }
- # if GTEST_HAS_EXCEPTIONS
- # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } catch (const ::std::exception& gtest_exception) { \
- fprintf(\
- stderr, \
- "\n%s: Caught std::exception-derived exception escaping the " \
- "death test statement. Exception message: %s\n", \
- ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
- gtest_exception.what()); \
- fflush(stderr); \
- death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
- } catch (...) { \
- death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
- }
- # else
- # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
- # endif
- #define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AlwaysTrue()) { \
- ::testing::internal::DeathTest* gtest_dt; \
- if (!::testing::internal::DeathTest::Create( \
- #statement, \
- ::testing::internal::MakeDeathTestMatcher(regex_or_matcher), \
- __FILE__, __LINE__, >est_dt)) { \
- goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
- } \
- if (gtest_dt != nullptr) { \
- std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
- switch (gtest_dt->AssumeRole()) { \
- case ::testing::internal::DeathTest::OVERSEE_TEST: \
- if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
- goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
- } \
- break; \
- case ::testing::internal::DeathTest::EXECUTE_TEST: { \
- ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
- gtest_dt); \
- GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
- gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
- break; \
- } \
- default: \
- break; \
- } \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__) \
- : fail(::testing::internal::DeathTest::LastMessage())
- #define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AlwaysTrue()) { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } else if (!::testing::internal::AlwaysTrue()) { \
- ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
- } else \
- ::testing::Message()
- class InternalRunDeathTestFlag {
- public:
- InternalRunDeathTestFlag(const std::string& a_file,
- int a_line,
- int an_index,
- int a_write_fd)
- : file_(a_file), line_(a_line), index_(an_index),
- write_fd_(a_write_fd) {}
- ~InternalRunDeathTestFlag() {
- if (write_fd_ >= 0)
- posix::Close(write_fd_);
- }
- const std::string& file() const { return file_; }
- int line() const { return line_; }
- int index() const { return index_; }
- int write_fd() const { return write_fd_; }
- private:
- std::string file_;
- int line_;
- int index_;
- int write_fd_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
- };
- InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
- #endif
- }
- }
- #endif
- namespace testing {
- GTEST_DECLARE_string_(death_test_style);
- #if GTEST_HAS_DEATH_TEST
- namespace internal {
- GTEST_API_ bool InDeathTestChild();
- }
- # define ASSERT_EXIT(statement, predicate, matcher) \
- GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_FATAL_FAILURE_)
- # define EXPECT_EXIT(statement, predicate, matcher) \
- GTEST_DEATH_TEST_(statement, predicate, matcher, GTEST_NONFATAL_FAILURE_)
- # define ASSERT_DEATH(statement, matcher) \
- ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
- # define EXPECT_DEATH(statement, matcher) \
- EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, matcher)
- class GTEST_API_ ExitedWithCode {
- public:
- explicit ExitedWithCode(int exit_code);
- ExitedWithCode(const ExitedWithCode&) = default;
- void operator=(const ExitedWithCode& other) = delete;
- bool operator()(int exit_status) const;
- private:
- const int exit_code_;
- };
- # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
- class GTEST_API_ KilledBySignal {
- public:
- explicit KilledBySignal(int signum);
- bool operator()(int exit_status) const;
- private:
- const int signum_;
- };
- # endif
- # ifdef NDEBUG
- # define EXPECT_DEBUG_DEATH(statement, regex) \
- GTEST_EXECUTE_STATEMENT_(statement, regex)
- # define ASSERT_DEBUG_DEATH(statement, regex) \
- GTEST_EXECUTE_STATEMENT_(statement, regex)
- # else
- # define EXPECT_DEBUG_DEATH(statement, regex) \
- EXPECT_DEATH(statement, regex)
- # define ASSERT_DEBUG_DEATH(statement, regex) \
- ASSERT_DEATH(statement, regex)
- # endif
- #endif
- # define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AlwaysTrue()) { \
- GTEST_LOG_(WARNING) \
- << "Death tests are not supported on this platform.\n" \
- << "Statement '" #statement "' cannot be verified."; \
- } else if (::testing::internal::AlwaysFalse()) { \
- ::testing::internal::RE::PartialMatch(".*", (regex)); \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- terminator; \
- } else \
- ::testing::Message()
- #if GTEST_HAS_DEATH_TEST
- # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
- EXPECT_DEATH(statement, regex)
- # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
- ASSERT_DEATH(statement, regex)
- #else
- # define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
- GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )
- # define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
- GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)
- #endif
- }
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
- #if 0
- class FooTest : public ::testing::TestWithParam<const char*> {
-
- };
- TEST_P(FooTest, DoesBlah) {
-
-
- EXPECT_TRUE(foo.Blah(GetParam()));
- ...
- }
- TEST_P(FooTest, HasBlahBlah) {
- ...
- }
- INSTANTIATE_TEST_SUITE_P(InstantiationName,
- FooTest,
- Values("meeny", "miny", "moe"));
- const char* pets[] = {"cat", "dog"};
- INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
- class BaseTest : public ::testing::Test {
-
-
- };
- class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
-
- };
- TEST_F(BaseTest, HasFoo) {
-
- }
- TEST_P(DerivedTest, DoesBlah) {
-
- EXPECT_TRUE(foo.Blah(GetParam()));
- }
- #endif
- #include <iterator>
- #include <utility>
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
- #include <ctype.h>
- #include <cassert>
- #include <iterator>
- #include <memory>
- #include <set>
- #include <tuple>
- #include <type_traits>
- #include <utility>
- #include <vector>
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
- #include <iosfwd>
- #include <vector>
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- class GTEST_API_ TestPartResult {
- public:
-
-
- enum Type {
- kSuccess,
- kNonFatalFailure,
- kFatalFailure,
- kSkip
- };
-
-
-
- TestPartResult(Type a_type, const char* a_file_name, int a_line_number,
- const char* a_message)
- : type_(a_type),
- file_name_(a_file_name == nullptr ? "" : a_file_name),
- line_number_(a_line_number),
- summary_(ExtractSummary(a_message)),
- message_(a_message) {}
-
- Type type() const { return type_; }
-
-
- const char* file_name() const {
- return file_name_.empty() ? nullptr : file_name_.c_str();
- }
-
-
- int line_number() const { return line_number_; }
-
- const char* summary() const { return summary_.c_str(); }
-
- const char* message() const { return message_.c_str(); }
-
- bool skipped() const { return type_ == kSkip; }
-
- bool passed() const { return type_ == kSuccess; }
-
- bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
-
- bool fatally_failed() const { return type_ == kFatalFailure; }
-
- bool failed() const { return fatally_failed() || nonfatally_failed(); }
- private:
- Type type_;
-
-
- static std::string ExtractSummary(const char* message);
-
-
- std::string file_name_;
-
-
- int line_number_;
- std::string summary_;
- std::string message_;
- };
- std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
- class GTEST_API_ TestPartResultArray {
- public:
- TestPartResultArray() {}
-
- void Append(const TestPartResult& result);
-
- const TestPartResult& GetTestPartResult(int index) const;
-
- int size() const;
- private:
- std::vector<TestPartResult> array_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);
- };
- class GTEST_API_ TestPartResultReporterInterface {
- public:
- virtual ~TestPartResultReporterInterface() {}
- virtual void ReportTestPartResult(const TestPartResult& result) = 0;
- };
- namespace internal {
- class GTEST_API_ HasNewFatalFailureHelper
- : public TestPartResultReporterInterface {
- public:
- HasNewFatalFailureHelper();
- ~HasNewFatalFailureHelper() override;
- void ReportTestPartResult(const TestPartResult& result) override;
- bool has_new_fatal_failure() const { return has_new_fatal_failure_; }
- private:
- bool has_new_fatal_failure_;
- TestPartResultReporterInterface* original_reporter_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);
- };
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
- namespace testing {
- template <class ParamType>
- struct TestParamInfo {
- TestParamInfo(const ParamType& a_param, size_t an_index) :
- param(a_param),
- index(an_index) {}
- ParamType param;
- size_t index;
- };
- struct PrintToStringParamName {
- template <class ParamType>
- std::string operator()(const TestParamInfo<ParamType>& info) const {
- return PrintToString(info.param);
- }
- };
- namespace internal {
- GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
- CodeLocation code_location);
- template <typename> class ParamGeneratorInterface;
- template <typename> class ParamGenerator;
- template <typename T>
- class ParamIteratorInterface {
- public:
- virtual ~ParamIteratorInterface() {}
-
-
-
- virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;
-
-
-
-
- virtual void Advance() = 0;
-
-
- virtual ParamIteratorInterface* Clone() const = 0;
-
-
-
-
- virtual const T* Current() const = 0;
-
-
-
- virtual bool Equals(const ParamIteratorInterface& other) const = 0;
- };
- template <typename T>
- class ParamIterator {
- public:
- typedef T value_type;
- typedef const T& reference;
- typedef ptrdiff_t difference_type;
-
- ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}
- ParamIterator& operator=(const ParamIterator& other) {
- if (this != &other)
- impl_.reset(other.impl_->Clone());
- return *this;
- }
- const T& operator*() const { return *impl_->Current(); }
- const T* operator->() const { return impl_->Current(); }
-
- ParamIterator& operator++() {
- impl_->Advance();
- return *this;
- }
-
- ParamIterator operator++(int ) {
- ParamIteratorInterface<T>* clone = impl_->Clone();
- impl_->Advance();
- return ParamIterator(clone);
- }
- bool operator==(const ParamIterator& other) const {
- return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);
- }
- bool operator!=(const ParamIterator& other) const {
- return !(*this == other);
- }
- private:
- friend class ParamGenerator<T>;
- explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}
- std::unique_ptr<ParamIteratorInterface<T> > impl_;
- };
- template <typename T>
- class ParamGeneratorInterface {
- public:
- typedef T ParamType;
- virtual ~ParamGeneratorInterface() {}
-
- virtual ParamIteratorInterface<T>* Begin() const = 0;
- virtual ParamIteratorInterface<T>* End() const = 0;
- };
- template<typename T>
- class ParamGenerator {
- public:
- typedef ParamIterator<T> iterator;
- explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}
- ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}
- ParamGenerator& operator=(const ParamGenerator& other) {
- impl_ = other.impl_;
- return *this;
- }
- iterator begin() const { return iterator(impl_->Begin()); }
- iterator end() const { return iterator(impl_->End()); }
- private:
- std::shared_ptr<const ParamGeneratorInterface<T> > impl_;
- };
- template <typename T, typename IncrementT>
- class RangeGenerator : public ParamGeneratorInterface<T> {
- public:
- RangeGenerator(T begin, T end, IncrementT step)
- : begin_(begin), end_(end),
- step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}
- ~RangeGenerator() override {}
- ParamIteratorInterface<T>* Begin() const override {
- return new Iterator(this, begin_, 0, step_);
- }
- ParamIteratorInterface<T>* End() const override {
- return new Iterator(this, end_, end_index_, step_);
- }
- private:
- class Iterator : public ParamIteratorInterface<T> {
- public:
- Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
- IncrementT step)
- : base_(base), value_(value), index_(index), step_(step) {}
- ~Iterator() override {}
- const ParamGeneratorInterface<T>* BaseGenerator() const override {
- return base_;
- }
- void Advance() override {
- value_ = static_cast<T>(value_ + step_);
- index_++;
- }
- ParamIteratorInterface<T>* Clone() const override {
- return new Iterator(*this);
- }
- const T* Current() const override { return &value_; }
- bool Equals(const ParamIteratorInterface<T>& other) const override {
-
-
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
- << "The program attempted to compare iterators "
- << "from different generators." << std::endl;
- const int other_index =
- CheckedDowncastToActualType<const Iterator>(&other)->index_;
- return index_ == other_index;
- }
- private:
- Iterator(const Iterator& other)
- : ParamIteratorInterface<T>(),
- base_(other.base_), value_(other.value_), index_(other.index_),
- step_(other.step_) {}
-
- void operator=(const Iterator& other);
- const ParamGeneratorInterface<T>* const base_;
- T value_;
- int index_;
- const IncrementT step_;
- };
- static int CalculateEndIndex(const T& begin,
- const T& end,
- const IncrementT& step) {
- int end_index = 0;
- for (T i = begin; i < end; i = static_cast<T>(i + step))
- end_index++;
- return end_index;
- }
-
- void operator=(const RangeGenerator& other);
- const T begin_;
- const T end_;
- const IncrementT step_;
-
-
- const int end_index_;
- };
- template <typename T>
- class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
- public:
- template <typename ForwardIterator>
- ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
- : container_(begin, end) {}
- ~ValuesInIteratorRangeGenerator() override {}
- ParamIteratorInterface<T>* Begin() const override {
- return new Iterator(this, container_.begin());
- }
- ParamIteratorInterface<T>* End() const override {
- return new Iterator(this, container_.end());
- }
- private:
- typedef typename ::std::vector<T> ContainerType;
- class Iterator : public ParamIteratorInterface<T> {
- public:
- Iterator(const ParamGeneratorInterface<T>* base,
- typename ContainerType::const_iterator iterator)
- : base_(base), iterator_(iterator) {}
- ~Iterator() override {}
- const ParamGeneratorInterface<T>* BaseGenerator() const override {
- return base_;
- }
- void Advance() override {
- ++iterator_;
- value_.reset();
- }
- ParamIteratorInterface<T>* Clone() const override {
- return new Iterator(*this);
- }
-
-
-
-
-
-
-
- const T* Current() const override {
- if (value_.get() == nullptr) value_.reset(new T(*iterator_));
- return value_.get();
- }
- bool Equals(const ParamIteratorInterface<T>& other) const override {
-
-
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
- << "The program attempted to compare iterators "
- << "from different generators." << std::endl;
- return iterator_ ==
- CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
- }
- private:
- Iterator(const Iterator& other)
-
-
- : ParamIteratorInterface<T>(),
- base_(other.base_),
- iterator_(other.iterator_) {}
- const ParamGeneratorInterface<T>* const base_;
- typename ContainerType::const_iterator iterator_;
-
-
-
-
-
- mutable std::unique_ptr<const T> value_;
- };
-
- void operator=(const ValuesInIteratorRangeGenerator& other);
- const ContainerType container_;
- };
- template <class ParamType>
- std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
- Message name_stream;
- name_stream << info.index;
- return name_stream.GetString();
- }
- template <typename T = int>
- void TestNotEmpty() {
- static_assert(sizeof(T) == 0, "Empty arguments are not allowed.");
- }
- template <typename T = int>
- void TestNotEmpty(const T&) {}
- template <class TestClass>
- class ParameterizedTestFactory : public TestFactoryBase {
- public:
- typedef typename TestClass::ParamType ParamType;
- explicit ParameterizedTestFactory(ParamType parameter) :
- parameter_(parameter) {}
- Test* CreateTest() override {
- TestClass::SetParam(¶meter_);
- return new TestClass();
- }
- private:
- const ParamType parameter_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);
- };
- template <class ParamType>
- class TestMetaFactoryBase {
- public:
- virtual ~TestMetaFactoryBase() {}
- virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
- };
- template <class TestSuite>
- class TestMetaFactory
- : public TestMetaFactoryBase<typename TestSuite::ParamType> {
- public:
- using ParamType = typename TestSuite::ParamType;
- TestMetaFactory() {}
- TestFactoryBase* CreateTestFactory(ParamType parameter) override {
- return new ParameterizedTestFactory<TestSuite>(parameter);
- }
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);
- };
- class ParameterizedTestSuiteInfoBase {
- public:
- virtual ~ParameterizedTestSuiteInfoBase() {}
-
- virtual const std::string& GetTestSuiteName() const = 0;
-
- virtual TypeId GetTestSuiteTypeId() const = 0;
-
-
-
-
- virtual void RegisterTests() = 0;
- protected:
- ParameterizedTestSuiteInfoBase() {}
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);
- };
- struct GTEST_API_ MarkAsIgnored {
- explicit MarkAsIgnored(const char* test_suite);
- };
- GTEST_API_ void InsertSyntheticTestCase(const std::string& name,
- CodeLocation location, bool has_test_p);
- template <class TestSuite>
- class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
- public:
-
-
-
- using ParamType = typename TestSuite::ParamType;
-
- typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
- using ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&);
- explicit ParameterizedTestSuiteInfo(const char* name,
- CodeLocation code_location)
- : test_suite_name_(name), code_location_(code_location) {}
-
- const std::string& GetTestSuiteName() const override {
- return test_suite_name_;
- }
-
- TypeId GetTestSuiteTypeId() const override { return GetTypeId<TestSuite>(); }
-
-
-
-
-
-
- void AddTestPattern(const char* test_suite_name, const char* test_base_name,
- TestMetaFactoryBase<ParamType>* meta_factory,
- CodeLocation code_location) {
- tests_.push_back(std::shared_ptr<TestInfo>(new TestInfo(
- test_suite_name, test_base_name, meta_factory, code_location)));
- }
-
-
- int AddTestSuiteInstantiation(const std::string& instantiation_name,
- GeneratorCreationFunc* func,
- ParamNameGeneratorFunc* name_func,
- const char* file, int line) {
- instantiations_.push_back(
- InstantiationInfo(instantiation_name, func, name_func, file, line));
- return 0;
- }
-
-
-
-
-
- void RegisterTests() override {
- bool generated_instantiations = false;
- for (typename TestInfoContainer::iterator test_it = tests_.begin();
- test_it != tests_.end(); ++test_it) {
- std::shared_ptr<TestInfo> test_info = *test_it;
- for (typename InstantiationContainer::iterator gen_it =
- instantiations_.begin(); gen_it != instantiations_.end();
- ++gen_it) {
- const std::string& instantiation_name = gen_it->name;
- ParamGenerator<ParamType> generator((*gen_it->generator)());
- ParamNameGeneratorFunc* name_func = gen_it->name_func;
- const char* file = gen_it->file;
- int line = gen_it->line;
- std::string test_suite_name;
- if ( !instantiation_name.empty() )
- test_suite_name = instantiation_name + "/";
- test_suite_name += test_info->test_suite_base_name;
- size_t i = 0;
- std::set<std::string> test_param_names;
- for (typename ParamGenerator<ParamType>::iterator param_it =
- generator.begin();
- param_it != generator.end(); ++param_it, ++i) {
- generated_instantiations = true;
- Message test_name_stream;
- std::string param_name = name_func(
- TestParamInfo<ParamType>(*param_it, i));
- GTEST_CHECK_(IsValidParamName(param_name))
- << "Parameterized test name '" << param_name
- << "' is invalid, in " << file
- << " line " << line << std::endl;
- GTEST_CHECK_(test_param_names.count(param_name) == 0)
- << "Duplicate parameterized test name '" << param_name
- << "', in " << file << " line " << line << std::endl;
- test_param_names.insert(param_name);
- if (!test_info->test_base_name.empty()) {
- test_name_stream << test_info->test_base_name << "/";
- }
- test_name_stream << param_name;
- MakeAndRegisterTestInfo(
- test_suite_name.c_str(), test_name_stream.GetString().c_str(),
- nullptr,
- PrintToString(*param_it).c_str(), test_info->code_location,
- GetTestSuiteTypeId(),
- SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(file, line),
- SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(file, line),
- test_info->test_meta_factory->CreateTestFactory(*param_it));
- }
- }
- }
- if (!generated_instantiations) {
-
- InsertSyntheticTestCase(GetTestSuiteName(), code_location_,
- !tests_.empty());
- }
- }
- private:
-
-
- struct TestInfo {
- TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
- TestMetaFactoryBase<ParamType>* a_test_meta_factory,
- CodeLocation a_code_location)
- : test_suite_base_name(a_test_suite_base_name),
- test_base_name(a_test_base_name),
- test_meta_factory(a_test_meta_factory),
- code_location(a_code_location) {}
- const std::string test_suite_base_name;
- const std::string test_base_name;
- const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;
- const CodeLocation code_location;
- };
- using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;
-
-
-
- struct InstantiationInfo {
- InstantiationInfo(const std::string &name_in,
- GeneratorCreationFunc* generator_in,
- ParamNameGeneratorFunc* name_func_in,
- const char* file_in,
- int line_in)
- : name(name_in),
- generator(generator_in),
- name_func(name_func_in),
- file(file_in),
- line(line_in) {}
- std::string name;
- GeneratorCreationFunc* generator;
- ParamNameGeneratorFunc* name_func;
- const char* file;
- int line;
- };
- typedef ::std::vector<InstantiationInfo> InstantiationContainer;
- static bool IsValidParamName(const std::string& name) {
-
- if (name.empty())
- return false;
-
- for (std::string::size_type index = 0; index < name.size(); ++index) {
- if (!IsAlNum(name[index]) && name[index] != '_')
- return false;
- }
- return true;
- }
- const std::string test_suite_name_;
- CodeLocation code_location_;
- TestInfoContainer tests_;
- InstantiationContainer instantiations_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);
- };
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- template <class TestCase>
- using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
- #endif
- class ParameterizedTestSuiteRegistry {
- public:
- ParameterizedTestSuiteRegistry() {}
- ~ParameterizedTestSuiteRegistry() {
- for (auto& test_suite_info : test_suite_infos_) {
- delete test_suite_info;
- }
- }
-
-
- template <class TestSuite>
- ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(
- const char* test_suite_name, CodeLocation code_location) {
- ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;
- for (auto& test_suite_info : test_suite_infos_) {
- if (test_suite_info->GetTestSuiteName() == test_suite_name) {
- if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
-
-
-
- ReportInvalidTestSuiteType(test_suite_name, code_location);
- posix::Abort();
- } else {
-
-
-
- typed_test_info = CheckedDowncastToActualType<
- ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);
- }
- break;
- }
- }
- if (typed_test_info == nullptr) {
- typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(
- test_suite_name, code_location);
- test_suite_infos_.push_back(typed_test_info);
- }
- return typed_test_info;
- }
- void RegisterTests() {
- for (auto& test_suite_info : test_suite_infos_) {
- test_suite_info->RegisterTests();
- }
- }
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- template <class TestCase>
- ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
- const char* test_case_name, CodeLocation code_location) {
- return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);
- }
- #endif
- private:
- using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;
- TestSuiteInfoContainer test_suite_infos_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);
- };
- class TypeParameterizedTestSuiteRegistry {
- public:
-
- void RegisterTestSuite(const char* test_suite_name,
- CodeLocation code_location);
-
- void RegisterInstantiation(const char* test_suite_name);
-
-
- void CheckForInstantiations();
- private:
- struct TypeParameterizedTestSuiteInfo {
- explicit TypeParameterizedTestSuiteInfo(CodeLocation c)
- : code_location(c), instantiated(false) {}
- CodeLocation code_location;
- bool instantiated;
- };
- std::map<std::string, TypeParameterizedTestSuiteInfo> suites_;
- };
- }
- template <class Container>
- internal::ParamGenerator<typename Container::value_type> ValuesIn(
- const Container& container);
- namespace internal {
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4100)
- #endif
- template <typename... Ts>
- class ValueArray {
- public:
- explicit ValueArray(Ts... v) : v_(FlatTupleConstructTag{}, std::move(v)...) {}
- template <typename T>
- operator ParamGenerator<T>() const {
- return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
- }
- private:
- template <typename T, size_t... I>
- std::vector<T> MakeVector(IndexSequence<I...>) const {
- return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
- }
- FlatTuple<Ts...> v_;
- };
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- template <typename... T>
- class CartesianProductGenerator
- : public ParamGeneratorInterface<::std::tuple<T...>> {
- public:
- typedef ::std::tuple<T...> ParamType;
- CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
- : generators_(g) {}
- ~CartesianProductGenerator() override {}
- ParamIteratorInterface<ParamType>* Begin() const override {
- return new Iterator(this, generators_, false);
- }
- ParamIteratorInterface<ParamType>* End() const override {
- return new Iterator(this, generators_, true);
- }
- private:
- template <class I>
- class IteratorImpl;
- template <size_t... I>
- class IteratorImpl<IndexSequence<I...>>
- : public ParamIteratorInterface<ParamType> {
- public:
- IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
- const std::tuple<ParamGenerator<T>...>& generators, bool is_end)
- : base_(base),
- begin_(std::get<I>(generators).begin()...),
- end_(std::get<I>(generators).end()...),
- current_(is_end ? end_ : begin_) {
- ComputeCurrentValue();
- }
- ~IteratorImpl() override {}
- const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
- return base_;
- }
-
-
- void Advance() override {
- assert(!AtEnd());
-
- ++std::get<sizeof...(T) - 1>(current_);
-
- AdvanceIfEnd<sizeof...(T) - 1>();
- ComputeCurrentValue();
- }
- ParamIteratorInterface<ParamType>* Clone() const override {
- return new IteratorImpl(*this);
- }
- const ParamType* Current() const override { return current_value_.get(); }
- bool Equals(const ParamIteratorInterface<ParamType>& other) const override {
-
-
- GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
- << "The program attempted to compare iterators "
- << "from different generators." << std::endl;
- const IteratorImpl* typed_other =
- CheckedDowncastToActualType<const IteratorImpl>(&other);
-
-
-
- if (AtEnd() && typed_other->AtEnd()) return true;
- bool same = true;
- bool dummy[] = {
- (same = same && std::get<I>(current_) ==
- std::get<I>(typed_other->current_))...};
- (void)dummy;
- return same;
- }
- private:
- template <size_t ThisI>
- void AdvanceIfEnd() {
- if (std::get<ThisI>(current_) != std::get<ThisI>(end_)) return;
- bool last = ThisI == 0;
- if (last) {
-
- return;
- }
- constexpr size_t NextI = ThisI - (ThisI != 0);
- std::get<ThisI>(current_) = std::get<ThisI>(begin_);
- ++std::get<NextI>(current_);
- AdvanceIfEnd<NextI>();
- }
- void ComputeCurrentValue() {
- if (!AtEnd())
- current_value_ = std::make_shared<ParamType>(*std::get<I>(current_)...);
- }
- bool AtEnd() const {
- bool at_end = false;
- bool dummy[] = {
- (at_end = at_end || std::get<I>(current_) == std::get<I>(end_))...};
- (void)dummy;
- return at_end;
- }
- const ParamGeneratorInterface<ParamType>* const base_;
- std::tuple<typename ParamGenerator<T>::iterator...> begin_;
- std::tuple<typename ParamGenerator<T>::iterator...> end_;
- std::tuple<typename ParamGenerator<T>::iterator...> current_;
- std::shared_ptr<ParamType> current_value_;
- };
- using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;
- std::tuple<ParamGenerator<T>...> generators_;
- };
- template <class... Gen>
- class CartesianProductHolder {
- public:
- CartesianProductHolder(const Gen&... g) : generators_(g...) {}
- template <typename... T>
- operator ParamGenerator<::std::tuple<T...>>() const {
- return ParamGenerator<::std::tuple<T...>>(
- new CartesianProductGenerator<T...>(generators_));
- }
- private:
- std::tuple<Gen...> generators_;
- };
- }
- }
- #endif
- namespace testing {
- template <typename T, typename IncrementT>
- internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
- return internal::ParamGenerator<T>(
- new internal::RangeGenerator<T, IncrementT>(start, end, step));
- }
- template <typename T>
- internal::ParamGenerator<T> Range(T start, T end) {
- return Range(start, end, 1);
- }
- template <typename ForwardIterator>
- internal::ParamGenerator<
- typename std::iterator_traits<ForwardIterator>::value_type>
- ValuesIn(ForwardIterator begin, ForwardIterator end) {
- typedef typename std::iterator_traits<ForwardIterator>::value_type ParamType;
- return internal::ParamGenerator<ParamType>(
- new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
- }
- template <typename T, size_t N>
- internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
- return ValuesIn(array, array + N);
- }
- template <class Container>
- internal::ParamGenerator<typename Container::value_type> ValuesIn(
- const Container& container) {
- return ValuesIn(container.begin(), container.end());
- }
- template <typename... T>
- internal::ValueArray<T...> Values(T... v) {
- return internal::ValueArray<T...>(std::move(v)...);
- }
- inline internal::ParamGenerator<bool> Bool() {
- return Values(false, true);
- }
- template <typename... Generator>
- internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
- return internal::CartesianProductHolder<Generator...>(g...);
- }
- #define TEST_P(test_suite_name, test_name) \
- class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
- : public test_suite_name { \
- public: \
- GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
- void TestBody() override; \
- \
- private: \
- static int AddToRegistry() { \
- ::testing::UnitTest::GetInstance() \
- ->parameterized_test_registry() \
- .GetTestSuitePatternHolder<test_suite_name>( \
- GTEST_STRINGIFY_(test_suite_name), \
- ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
- ->AddTestPattern( \
- GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
- new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
- test_suite_name, test_name)>(), \
- ::testing::internal::CodeLocation(__FILE__, __LINE__)); \
- return 0; \
- } \
- static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
- }; \
- int GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)::gtest_registering_dummy_ = \
- GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
- void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
- #define GTEST_EXPAND_(arg) arg
- #define GTEST_GET_FIRST_(first, ...) first
- #define GTEST_GET_SECOND_(first, second, ...) second
- #define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
- static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
- gtest_##prefix##test_suite_name##_EvalGenerator_() { \
- return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
- } \
- static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
- const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
- if (::testing::internal::AlwaysFalse()) { \
- ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \
- __VA_ARGS__, \
- ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
- DUMMY_PARAM_))); \
- auto t = std::make_tuple(__VA_ARGS__); \
- static_assert(std::tuple_size<decltype(t)>::value <= 2, \
- "Too Many Args!"); \
- } \
- return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \
- __VA_ARGS__, \
- ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
- DUMMY_PARAM_))))(info); \
- } \
- static int gtest_##prefix##test_suite_name##_dummy_ \
- GTEST_ATTRIBUTE_UNUSED_ = \
- ::testing::UnitTest::GetInstance() \
- ->parameterized_test_registry() \
- .GetTestSuitePatternHolder<test_suite_name>( \
- GTEST_STRINGIFY_(test_suite_name), \
- ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
- ->AddTestSuiteInstantiation( \
- GTEST_STRINGIFY_(prefix), \
- >est_##prefix##test_suite_name##_EvalGenerator_, \
- >est_##prefix##test_suite_name##_EvalGenerateName_, \
- __FILE__, __LINE__)
- #define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \
- namespace gtest_do_not_use_outside_namespace_scope {} \
- static const ::testing::internal::MarkAsIgnored gtest_allow_ignore_##T( \
- GTEST_STRINGIFY_(T))
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- #define INSTANTIATE_TEST_CASE_P \
- static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
- ""); \
- INSTANTIATE_TEST_SUITE_P
- #endif
- }
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_
- #define FRIEND_TEST(test_case_name, test_name)\
- friend class test_case_name##_##test_name##_Test
- #endif
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
- #if 0
- template <typename T>
- class FooTest : public testing::Test {
- public:
- ...
- typedef std::list<T> List;
- static T shared_;
- T value_;
- };
- typedef testing::Types<char, int, unsigned int> MyTypes;
- TYPED_TEST_SUITE(FooTest, MyTypes);
- TYPED_TEST(FooTest, DoesBlah) {
-
-
-
- TypeParam n = this->value_;
-
-
- n += TestFixture::shared_;
-
-
- typename TestFixture::List values;
- values.push_back(n);
- ...
- }
- TYPED_TEST(FooTest, HasPropertyA) { ... }
- #endif
- #if 0
- template <typename T>
- class FooTest : public testing::Test {
- ...
- };
- TYPED_TEST_SUITE_P(FooTest);
- TYPED_TEST_P(FooTest, DoesBlah) {
-
- TypeParam n = 0;
- ...
- }
- TYPED_TEST_P(FooTest, HasPropertyA) { ... }
- REGISTER_TYPED_TEST_SUITE_P(FooTest,
- DoesBlah, HasPropertyA);
- typedef testing::Types<char, int, unsigned int> MyTypes;
- INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
- #endif
- #define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_
- #define GTEST_NAME_GENERATOR_(TestSuiteName) \
- gtest_type_params_##TestSuiteName##_NameGenerator
- #define TYPED_TEST_SUITE(CaseName, Types, ...) \
- typedef ::testing::internal::GenerateTypeList<Types>::type \
- GTEST_TYPE_PARAMS_(CaseName); \
- typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
- GTEST_NAME_GENERATOR_(CaseName)
- #define TYPED_TEST(CaseName, TestName) \
- static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
- "test-name must not be empty"); \
- template <typename gtest_TypeParam_> \
- class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
- : public CaseName<gtest_TypeParam_> { \
- private: \
- typedef CaseName<gtest_TypeParam_> TestFixture; \
- typedef gtest_TypeParam_ TypeParam; \
- void TestBody() override; \
- }; \
- static bool gtest_##CaseName##_##TestName##_registered_ \
- GTEST_ATTRIBUTE_UNUSED_ = ::testing::internal::TypeParameterizedTest< \
- CaseName, \
- ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
- TestName)>, \
- GTEST_TYPE_PARAMS_( \
- CaseName)>::Register("", \
- ::testing::internal::CodeLocation( \
- __FILE__, __LINE__), \
- GTEST_STRINGIFY_(CaseName), \
- GTEST_STRINGIFY_(TestName), 0, \
- ::testing::internal::GenerateNames< \
- GTEST_NAME_GENERATOR_(CaseName), \
- GTEST_TYPE_PARAMS_(CaseName)>()); \
- template <typename gtest_TypeParam_> \
- void GTEST_TEST_CLASS_NAME_(CaseName, \
- TestName)<gtest_TypeParam_>::TestBody()
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- #define TYPED_TEST_CASE \
- static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \
- TYPED_TEST_SUITE
- #endif
- #define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_
- #define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \
- gtest_typed_test_suite_p_state_##TestSuiteName##_
- #define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \
- gtest_registered_test_names_##TestSuiteName##_
- #define TYPED_TEST_SUITE_P(SuiteName) \
- static ::testing::internal::TypedTestSuitePState \
- GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- #define TYPED_TEST_CASE_P \
- static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), ""); \
- TYPED_TEST_SUITE_P
- #endif
- #define TYPED_TEST_P(SuiteName, TestName) \
- namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
- template <typename gtest_TypeParam_> \
- class TestName : public SuiteName<gtest_TypeParam_> { \
- private: \
- typedef SuiteName<gtest_TypeParam_> TestFixture; \
- typedef gtest_TypeParam_ TypeParam; \
- void TestBody() override; \
- }; \
- static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
- GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
- __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
- GTEST_STRINGIFY_(TestName)); \
- } \
- template <typename gtest_TypeParam_> \
- void GTEST_SUITE_NAMESPACE_( \
- SuiteName)::TestName<gtest_TypeParam_>::TestBody()
- #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
- namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
- typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
- } \
- static const char* const GTEST_REGISTERED_TEST_NAMES_( \
- SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
- GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
- GTEST_STRINGIFY_(SuiteName), __FILE__, __LINE__, #__VA_ARGS__)
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- #define REGISTER_TYPED_TEST_CASE_P \
- static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \
- ""); \
- REGISTER_TYPED_TEST_SUITE_P
- #endif
- #define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
- static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
- "test-suit-prefix must not be empty"); \
- static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
- ::testing::internal::TypeParameterizedTestSuite< \
- SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
- ::testing::internal::GenerateTypeList<Types>::type>:: \
- Register(GTEST_STRINGIFY_(Prefix), \
- ::testing::internal::CodeLocation(__FILE__, __LINE__), \
- >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
- GTEST_STRINGIFY_(SuiteName), \
- GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
- ::testing::internal::GenerateNames< \
- ::testing::internal::NameGeneratorSelector< \
- __VA_ARGS__>::type, \
- ::testing::internal::GenerateTypeList<Types>::type>())
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- #define INSTANTIATE_TYPED_TEST_CASE_P \
- static_assert( \
- ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), ""); \
- INSTANTIATE_TYPED_TEST_SUITE_P
- #endif
- #endif
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- #ifdef _MSC_VER
- # pragma warning(push)
- # pragma warning(disable:4805)
- # pragma warning(disable:4100)
- #endif
- GTEST_DECLARE_bool_(also_run_disabled_tests);
- GTEST_DECLARE_bool_(break_on_failure);
- GTEST_DECLARE_bool_(catch_exceptions);
- GTEST_DECLARE_string_(color);
- GTEST_DECLARE_bool_(fail_fast);
- GTEST_DECLARE_string_(filter);
- GTEST_DECLARE_bool_(install_failure_signal_handler);
- GTEST_DECLARE_bool_(list_tests);
- GTEST_DECLARE_string_(output);
- GTEST_DECLARE_bool_(brief);
- GTEST_DECLARE_bool_(print_time);
- GTEST_DECLARE_bool_(print_utf8);
- GTEST_DECLARE_int32_(random_seed);
- GTEST_DECLARE_int32_(repeat);
- GTEST_DECLARE_bool_(show_internal_stack_frames);
- GTEST_DECLARE_bool_(shuffle);
- GTEST_DECLARE_int32_(stack_trace_depth);
- GTEST_DECLARE_bool_(throw_on_failure);
- GTEST_DECLARE_string_(stream_result_to);
- #if GTEST_USE_OWN_FLAGFILE_FLAG_
- GTEST_DECLARE_string_(flagfile);
- #endif
- const int kMaxStackTraceDepth = 100;
- namespace internal {
- class AssertHelper;
- class DefaultGlobalTestPartResultReporter;
- class ExecDeathTest;
- class NoExecDeathTest;
- class FinalSuccessChecker;
- class GTestFlagSaver;
- class StreamingListenerTest;
- class TestResultAccessor;
- class TestEventListenersAccessor;
- class TestEventRepeater;
- class UnitTestRecordPropertyTestHelper;
- class WindowsDeathTest;
- class FuchsiaDeathTest;
- class UnitTestImpl* GetUnitTestImpl();
- void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
- const std::string& message);
- std::set<std::string>* GetIgnoredParameterizedTestSuites();
- }
- class Test;
- class TestSuite;
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- using TestCase = TestSuite;
- #endif
- class TestInfo;
- class UnitTest;
- class GTEST_API_ AssertionResult {
- public:
-
-
- AssertionResult(const AssertionResult& other);
- #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 )
- #endif
-
-
-
-
-
-
-
- template <typename T>
- explicit AssertionResult(
- const T& success,
- typename std::enable_if<
- !std::is_convertible<T, AssertionResult>::value>::type*
-
- = nullptr)
- : success_(success) {}
- #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
-
- AssertionResult& operator=(AssertionResult other) {
- swap(other);
- return *this;
- }
-
- operator bool() const { return success_; }
-
- AssertionResult operator!() const;
-
-
-
-
- const char* message() const {
- return message_.get() != nullptr ? message_->c_str() : "";
- }
-
- const char* failure_message() const { return message(); }
-
- template <typename T> AssertionResult& operator<<(const T& value) {
- AppendMessage(Message() << value);
- return *this;
- }
-
-
- AssertionResult& operator<<(
- ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
- AppendMessage(Message() << basic_manipulator);
- return *this;
- }
- private:
-
- void AppendMessage(const Message& a_message) {
- if (message_.get() == nullptr) message_.reset(new ::std::string);
- message_->append(a_message.GetString().c_str());
- }
-
- void swap(AssertionResult& other);
-
- bool success_;
-
-
-
-
- std::unique_ptr< ::std::string> message_;
- };
- GTEST_API_ AssertionResult AssertionSuccess();
- GTEST_API_ AssertionResult AssertionFailure();
- GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
- }
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
- namespace testing {
- #define GTEST_ASSERT_(expression, on_failure) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (const ::testing::AssertionResult gtest_ar = (expression)) \
- ; \
- else \
- on_failure(gtest_ar.failure_message())
- template <typename Pred,
- typename T1>
- AssertionResult AssertPred1Helper(const char* pred_text,
- const char* e1,
- Pred pred,
- const T1& v1) {
- if (pred(v1)) return AssertionSuccess();
- return AssertionFailure()
- << pred_text << "(" << e1 << ") evaluates to false, where"
- << "\n"
- << e1 << " evaluates to " << ::testing::PrintToString(v1);
- }
- #define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\
- GTEST_ASSERT_(pred_format(#v1, v1), \
- on_failure)
- #define GTEST_PRED1_(pred, v1, on_failure)\
- GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \
- #v1, \
- pred, \
- v1), on_failure)
- #define EXPECT_PRED_FORMAT1(pred_format, v1) \
- GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_PRED1(pred, v1) \
- GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_PRED_FORMAT1(pred_format, v1) \
- GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)
- #define ASSERT_PRED1(pred, v1) \
- GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)
- template <typename Pred,
- typename T1,
- typename T2>
- AssertionResult AssertPred2Helper(const char* pred_text,
- const char* e1,
- const char* e2,
- Pred pred,
- const T1& v1,
- const T2& v2) {
- if (pred(v1, v2)) return AssertionSuccess();
- return AssertionFailure()
- << pred_text << "(" << e1 << ", " << e2
- << ") evaluates to false, where"
- << "\n"
- << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
- << e2 << " evaluates to " << ::testing::PrintToString(v2);
- }
- #define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\
- GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \
- on_failure)
- #define GTEST_PRED2_(pred, v1, v2, on_failure)\
- GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \
- #v1, \
- #v2, \
- pred, \
- v1, \
- v2), on_failure)
- #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \
- GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_PRED2(pred, v1, v2) \
- GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \
- GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
- #define ASSERT_PRED2(pred, v1, v2) \
- GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)
- template <typename Pred,
- typename T1,
- typename T2,
- typename T3>
- AssertionResult AssertPred3Helper(const char* pred_text,
- const char* e1,
- const char* e2,
- const char* e3,
- Pred pred,
- const T1& v1,
- const T2& v2,
- const T3& v3) {
- if (pred(v1, v2, v3)) return AssertionSuccess();
- return AssertionFailure()
- << pred_text << "(" << e1 << ", " << e2 << ", " << e3
- << ") evaluates to false, where"
- << "\n"
- << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
- << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
- << e3 << " evaluates to " << ::testing::PrintToString(v3);
- }
- #define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\
- GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \
- on_failure)
- #define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\
- GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \
- #v1, \
- #v2, \
- #v3, \
- pred, \
- v1, \
- v2, \
- v3), on_failure)
- #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \
- GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_PRED3(pred, v1, v2, v3) \
- GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \
- GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)
- #define ASSERT_PRED3(pred, v1, v2, v3) \
- GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)
- template <typename Pred,
- typename T1,
- typename T2,
- typename T3,
- typename T4>
- AssertionResult AssertPred4Helper(const char* pred_text,
- const char* e1,
- const char* e2,
- const char* e3,
- const char* e4,
- Pred pred,
- const T1& v1,
- const T2& v2,
- const T3& v3,
- const T4& v4) {
- if (pred(v1, v2, v3, v4)) return AssertionSuccess();
- return AssertionFailure()
- << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
- << ") evaluates to false, where"
- << "\n"
- << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
- << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
- << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
- << e4 << " evaluates to " << ::testing::PrintToString(v4);
- }
- #define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\
- GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \
- on_failure)
- #define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\
- GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \
- #v1, \
- #v2, \
- #v3, \
- #v4, \
- pred, \
- v1, \
- v2, \
- v3, \
- v4), on_failure)
- #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
- GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_PRED4(pred, v1, v2, v3, v4) \
- GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \
- GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
- #define ASSERT_PRED4(pred, v1, v2, v3, v4) \
- GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)
- template <typename Pred,
- typename T1,
- typename T2,
- typename T3,
- typename T4,
- typename T5>
- AssertionResult AssertPred5Helper(const char* pred_text,
- const char* e1,
- const char* e2,
- const char* e3,
- const char* e4,
- const char* e5,
- Pred pred,
- const T1& v1,
- const T2& v2,
- const T3& v3,
- const T4& v4,
- const T5& v5) {
- if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();
- return AssertionFailure()
- << pred_text << "(" << e1 << ", " << e2 << ", " << e3 << ", " << e4
- << ", " << e5 << ") evaluates to false, where"
- << "\n"
- << e1 << " evaluates to " << ::testing::PrintToString(v1) << "\n"
- << e2 << " evaluates to " << ::testing::PrintToString(v2) << "\n"
- << e3 << " evaluates to " << ::testing::PrintToString(v3) << "\n"
- << e4 << " evaluates to " << ::testing::PrintToString(v4) << "\n"
- << e5 << " evaluates to " << ::testing::PrintToString(v5);
- }
- #define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\
- GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \
- on_failure)
- #define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\
- GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \
- #v1, \
- #v2, \
- #v3, \
- #v4, \
- #v5, \
- pred, \
- v1, \
- v2, \
- v3, \
- v4, \
- v5), on_failure)
- #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
- GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \
- GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \
- GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
- #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \
- GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)
- }
- #endif
- namespace testing {
- class GTEST_API_ Test {
- public:
- friend class TestInfo;
-
- virtual ~Test();
-
-
-
-
-
-
- static void SetUpTestSuite() {}
-
-
-
-
-
-
- static void TearDownTestSuite() {}
-
-
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- static void TearDownTestCase() {}
- static void SetUpTestCase() {}
- #endif
-
- static bool HasFatalFailure();
-
- static bool HasNonfatalFailure();
-
- static bool IsSkipped();
-
-
- static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
-
-
-
-
-
-
-
-
-
-
-
-
-
- static void RecordProperty(const std::string& key, const std::string& value);
- static void RecordProperty(const std::string& key, int value);
- protected:
-
- Test();
-
- virtual void SetUp();
-
- virtual void TearDown();
- private:
-
-
- static bool HasSameFixtureClass();
-
-
-
-
-
-
- virtual void TestBody() = 0;
-
- void Run();
-
-
- void DeleteSelf_() { delete this; }
- const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- struct Setup_should_be_spelled_SetUp {};
- virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
- };
- typedef internal::TimeInMillis TimeInMillis;
- class TestProperty {
- public:
-
-
-
- TestProperty(const std::string& a_key, const std::string& a_value) :
- key_(a_key), value_(a_value) {
- }
-
- const char* key() const {
- return key_.c_str();
- }
-
- const char* value() const {
- return value_.c_str();
- }
-
- void SetValue(const std::string& new_value) {
- value_ = new_value;
- }
- private:
-
- std::string key_;
-
- std::string value_;
- };
- class GTEST_API_ TestResult {
- public:
-
- TestResult();
-
- ~TestResult();
-
-
- int total_part_count() const;
-
- int test_property_count() const;
-
- bool Passed() const { return !Skipped() && !Failed(); }
-
- bool Skipped() const;
-
- bool Failed() const;
-
- bool HasFatalFailure() const;
-
- bool HasNonfatalFailure() const;
-
- TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-
- TimeInMillis start_timestamp() const { return start_timestamp_; }
-
-
- const TestPartResult& GetTestPartResult(int i) const;
-
-
-
- const TestProperty& GetTestProperty(int i) const;
- private:
- friend class TestInfo;
- friend class TestSuite;
- friend class UnitTest;
- friend class internal::DefaultGlobalTestPartResultReporter;
- friend class internal::ExecDeathTest;
- friend class internal::TestResultAccessor;
- friend class internal::UnitTestImpl;
- friend class internal::WindowsDeathTest;
- friend class internal::FuchsiaDeathTest;
-
- const std::vector<TestPartResult>& test_part_results() const {
- return test_part_results_;
- }
-
- const std::vector<TestProperty>& test_properties() const {
- return test_properties_;
- }
-
- void set_start_timestamp(TimeInMillis start) { start_timestamp_ = start; }
-
- void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
-
-
-
-
-
-
- void RecordProperty(const std::string& xml_element,
- const TestProperty& test_property);
-
-
-
- static bool ValidateTestProperty(const std::string& xml_element,
- const TestProperty& test_property);
-
- void AddTestPartResult(const TestPartResult& test_part_result);
-
- int death_test_count() const { return death_test_count_; }
-
- int increment_death_test_count() { return ++death_test_count_; }
-
- void ClearTestPartResults();
-
- void Clear();
-
-
- internal::Mutex test_properties_mutex_;
-
- std::vector<TestPartResult> test_part_results_;
-
- std::vector<TestProperty> test_properties_;
-
- int death_test_count_;
-
- TimeInMillis start_timestamp_;
-
- TimeInMillis elapsed_time_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
- };
- class GTEST_API_ TestInfo {
- public:
-
-
- ~TestInfo();
-
- const char* test_suite_name() const { return test_suite_name_.c_str(); }
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const char* test_case_name() const { return test_suite_name(); }
- #endif
-
- const char* name() const { return name_.c_str(); }
-
-
- const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
- return nullptr;
- }
-
-
- const char* value_param() const {
- if (value_param_.get() != nullptr) return value_param_->c_str();
- return nullptr;
- }
-
- const char* file() const { return location_.file.c_str(); }
-
- int line() const { return location_.line; }
-
- bool is_in_another_shard() const { return is_in_another_shard_; }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool should_run() const { return should_run_; }
-
- bool is_reportable() const {
-
-
- return matches_filter_ && !is_in_another_shard_;
- }
-
- const TestResult* result() const { return &result_; }
- private:
- #if GTEST_HAS_DEATH_TEST
- friend class internal::DefaultDeathTestFactory;
- #endif
- friend class Test;
- friend class TestSuite;
- friend class internal::UnitTestImpl;
- friend class internal::StreamingListenerTest;
- friend TestInfo* internal::MakeAndRegisterTestInfo(
- const char* test_suite_name, const char* name, const char* type_param,
- const char* value_param, internal::CodeLocation code_location,
- internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
- internal::TearDownTestSuiteFunc tear_down_tc,
- internal::TestFactoryBase* factory);
-
-
- TestInfo(const std::string& test_suite_name, const std::string& name,
- const char* a_type_param,
- const char* a_value_param,
- internal::CodeLocation a_code_location,
- internal::TypeId fixture_class_id,
- internal::TestFactoryBase* factory);
-
-
- int increment_death_test_count() {
- return result_.increment_death_test_count();
- }
-
-
- void Run();
-
- void Skip();
- static void ClearTestResult(TestInfo* test_info) {
- test_info->result_.Clear();
- }
-
- const std::string test_suite_name_;
- const std::string name_;
-
-
- const std::unique_ptr<const ::std::string> type_param_;
-
-
- const std::unique_ptr<const ::std::string> value_param_;
- internal::CodeLocation location_;
- const internal::TypeId fixture_class_id_;
- bool should_run_;
- bool is_disabled_;
- bool matches_filter_;
-
- bool is_in_another_shard_;
- internal::TestFactoryBase* const factory_;
-
-
-
- TestResult result_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
- };
- class GTEST_API_ TestSuite {
- public:
-
-
-
-
-
-
-
-
-
-
-
-
- TestSuite(const char* name, const char* a_type_param,
- internal::SetUpTestSuiteFunc set_up_tc,
- internal::TearDownTestSuiteFunc tear_down_tc);
-
- virtual ~TestSuite();
-
- const char* name() const { return name_.c_str(); }
-
-
- const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
- return nullptr;
- }
-
- bool should_run() const { return should_run_; }
-
- int successful_test_count() const;
-
- int skipped_test_count() const;
-
- int failed_test_count() const;
-
- int reportable_disabled_test_count() const;
-
- int disabled_test_count() const;
-
- int reportable_test_count() const;
-
- int test_to_run_count() const;
-
- int total_test_count() const;
-
- bool Passed() const { return !Failed(); }
-
- bool Failed() const {
- return failed_test_count() > 0 || ad_hoc_test_result().Failed();
- }
-
- TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-
- TimeInMillis start_timestamp() const { return start_timestamp_; }
-
-
- const TestInfo* GetTestInfo(int i) const;
-
-
- const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
- private:
- friend class Test;
- friend class internal::UnitTestImpl;
-
- std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
-
- const std::vector<TestInfo*>& test_info_list() const {
- return test_info_list_;
- }
-
-
- TestInfo* GetMutableTestInfo(int i);
-
- void set_should_run(bool should) { should_run_ = should; }
-
-
- void AddTestInfo(TestInfo * test_info);
-
- void ClearResult();
-
- static void ClearTestSuiteResult(TestSuite* test_suite) {
- test_suite->ClearResult();
- }
-
- void Run();
-
- void Skip();
-
-
- void RunSetUpTestSuite() {
- if (set_up_tc_ != nullptr) {
- (*set_up_tc_)();
- }
- }
-
-
- void RunTearDownTestSuite() {
- if (tear_down_tc_ != nullptr) {
- (*tear_down_tc_)();
- }
- }
-
- static bool TestPassed(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Passed();
- }
-
- static bool TestSkipped(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Skipped();
- }
-
- static bool TestFailed(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Failed();
- }
-
-
- static bool TestReportableDisabled(const TestInfo* test_info) {
- return test_info->is_reportable() && test_info->is_disabled_;
- }
-
- static bool TestDisabled(const TestInfo* test_info) {
- return test_info->is_disabled_;
- }
-
- static bool TestReportable(const TestInfo* test_info) {
- return test_info->is_reportable();
- }
-
- static bool ShouldRunTest(const TestInfo* test_info) {
- return test_info->should_run();
- }
-
- void ShuffleTests(internal::Random* random);
-
- void UnshuffleTests();
-
- std::string name_;
-
-
- const std::unique_ptr<const ::std::string> type_param_;
-
-
- std::vector<TestInfo*> test_info_list_;
-
-
-
- std::vector<int> test_indices_;
-
- internal::SetUpTestSuiteFunc set_up_tc_;
-
- internal::TearDownTestSuiteFunc tear_down_tc_;
-
- bool should_run_;
-
- TimeInMillis start_timestamp_;
-
- TimeInMillis elapsed_time_;
-
-
- TestResult ad_hoc_test_result_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
- };
- class Environment {
- public:
-
- virtual ~Environment() {}
-
- virtual void SetUp() {}
-
- virtual void TearDown() {}
- private:
-
-
- struct Setup_should_be_spelled_SetUp {};
- virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
- };
- #if GTEST_HAS_EXCEPTIONS
- class GTEST_API_ AssertionException
- : public internal::GoogleTestFailureException {
- public:
- explicit AssertionException(const TestPartResult& result)
- : GoogleTestFailureException(result) {}
- };
- #endif
- class TestEventListener {
- public:
- virtual ~TestEventListener() {}
-
- virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
-
-
-
- virtual void OnTestIterationStart(const UnitTest& unit_test,
- int iteration) = 0;
-
- virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
-
- virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
-
- virtual void OnTestSuiteStart(const TestSuite& ) {}
-
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- virtual void OnTestCaseStart(const TestCase& ) {}
- #endif
-
- virtual void OnTestStart(const TestInfo& test_info) = 0;
-
-
-
- virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
-
- virtual void OnTestEnd(const TestInfo& test_info) = 0;
-
- virtual void OnTestSuiteEnd(const TestSuite& ) {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- virtual void OnTestCaseEnd(const TestCase& ) {}
- #endif
-
- virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
-
- virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
-
- virtual void OnTestIterationEnd(const UnitTest& unit_test,
- int iteration) = 0;
-
- virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
- };
- class EmptyTestEventListener : public TestEventListener {
- public:
- void OnTestProgramStart(const UnitTest& ) override {}
- void OnTestIterationStart(const UnitTest& ,
- int ) override {}
- void OnEnvironmentsSetUpStart(const UnitTest& ) override {}
- void OnEnvironmentsSetUpEnd(const UnitTest& ) override {}
- void OnTestSuiteStart(const TestSuite& ) override {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- void OnTestCaseStart(const TestCase& ) override {}
- #endif
- void OnTestStart(const TestInfo& ) override {}
- void OnTestPartResult(const TestPartResult& ) override {}
- void OnTestEnd(const TestInfo& ) override {}
- void OnTestSuiteEnd(const TestSuite& ) override {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- void OnTestCaseEnd(const TestCase& ) override {}
- #endif
- void OnEnvironmentsTearDownStart(const UnitTest& ) override {}
- void OnEnvironmentsTearDownEnd(const UnitTest& ) override {}
- void OnTestIterationEnd(const UnitTest& ,
- int ) override {}
- void OnTestProgramEnd(const UnitTest& ) override {}
- };
- class GTEST_API_ TestEventListeners {
- public:
- TestEventListeners();
- ~TestEventListeners();
-
-
-
- void Append(TestEventListener* listener);
-
-
-
- TestEventListener* Release(TestEventListener* listener);
-
-
-
-
-
- TestEventListener* default_result_printer() const {
- return default_result_printer_;
- }
-
-
-
-
-
-
-
- TestEventListener* default_xml_generator() const {
- return default_xml_generator_;
- }
- private:
- friend class TestSuite;
- friend class TestInfo;
- friend class internal::DefaultGlobalTestPartResultReporter;
- friend class internal::NoExecDeathTest;
- friend class internal::TestEventListenersAccessor;
- friend class internal::UnitTestImpl;
-
-
- TestEventListener* repeater();
-
-
-
-
-
- void SetDefaultResultPrinter(TestEventListener* listener);
-
-
-
-
-
- void SetDefaultXmlGenerator(TestEventListener* listener);
-
-
- bool EventForwardingEnabled() const;
- void SuppressEventForwarding();
-
- internal::TestEventRepeater* repeater_;
-
- TestEventListener* default_result_printer_;
-
- TestEventListener* default_xml_generator_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
- };
- class GTEST_API_ UnitTest {
- public:
-
-
-
- static UnitTest* GetInstance();
-
-
-
-
-
-
- int Run() GTEST_MUST_USE_RESULT_;
-
-
- const char* original_working_dir() const;
-
-
- const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);
- #endif
-
-
- const TestInfo* current_test_info() const
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- int random_seed() const;
-
-
-
-
- internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- int successful_test_suite_count() const;
-
- int failed_test_suite_count() const;
-
- int total_test_suite_count() const;
-
-
- int test_suite_to_run_count() const;
-
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- int successful_test_case_count() const;
- int failed_test_case_count() const;
- int total_test_case_count() const;
- int test_case_to_run_count() const;
- #endif
-
- int successful_test_count() const;
-
- int skipped_test_count() const;
-
- int failed_test_count() const;
-
- int reportable_disabled_test_count() const;
-
- int disabled_test_count() const;
-
- int reportable_test_count() const;
-
- int total_test_count() const;
-
- int test_to_run_count() const;
-
-
- TimeInMillis start_timestamp() const;
-
- TimeInMillis elapsed_time() const;
-
-
- bool Passed() const;
-
-
- bool Failed() const;
-
-
- const TestSuite* GetTestSuite(int i) const;
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const TestCase* GetTestCase(int i) const;
- #endif
-
-
- const TestResult& ad_hoc_test_result() const;
-
-
- TestEventListeners& listeners();
- private:
-
-
-
-
-
-
-
-
-
- Environment* AddEnvironment(Environment* env);
-
-
-
-
- void AddTestPartResult(TestPartResult::Type result_type,
- const char* file_name,
- int line_number,
- const std::string& message,
- const std::string& os_stack_trace)
- GTEST_LOCK_EXCLUDED_(mutex_);
-
-
-
-
-
- void RecordProperty(const std::string& key, const std::string& value);
-
-
- TestSuite* GetMutableTestSuite(int i);
-
- internal::UnitTestImpl* impl() { return impl_; }
- const internal::UnitTestImpl* impl() const { return impl_; }
-
-
- friend class ScopedTrace;
- friend class Test;
- friend class internal::AssertHelper;
- friend class internal::StreamingListenerTest;
- friend class internal::UnitTestRecordPropertyTestHelper;
- friend Environment* AddGlobalTestEnvironment(Environment* env);
- friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();
- friend internal::UnitTestImpl* internal::GetUnitTestImpl();
- friend void internal::ReportFailureInUnknownLocation(
- TestPartResult::Type result_type,
- const std::string& message);
-
- UnitTest();
-
- virtual ~UnitTest();
-
-
- void PushGTestTrace(const internal::TraceInfo& trace)
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- void PopGTestTrace()
- GTEST_LOCK_EXCLUDED_(mutex_);
-
-
- mutable internal::Mutex mutex_;
-
-
-
-
- internal::UnitTestImpl* impl_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
- };
- inline Environment* AddGlobalTestEnvironment(Environment* env) {
- return UnitTest::GetInstance()->AddEnvironment(env);
- }
- GTEST_API_ void InitGoogleTest(int* argc, char** argv);
- GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
- GTEST_API_ void InitGoogleTest();
- namespace internal {
- template <typename T1, typename T2>
- AssertionResult CmpHelperEQFailure(const char* lhs_expression,
- const char* rhs_expression,
- const T1& lhs, const T2& rhs) {
- return EqFailure(lhs_expression,
- rhs_expression,
- FormatForComparisonFailureMessage(lhs, rhs),
- FormatForComparisonFailureMessage(rhs, lhs),
- false);
- }
- struct faketype {};
- inline bool operator==(faketype, faketype) { return true; }
- inline bool operator!=(faketype, faketype) { return false; }
- template <typename T1, typename T2>
- AssertionResult CmpHelperEQ(const char* lhs_expression,
- const char* rhs_expression,
- const T1& lhs,
- const T2& rhs) {
- if (lhs == rhs) {
- return AssertionSuccess();
- }
- return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
- }
- class EqHelper {
- public:
-
- template <
- typename T1, typename T2,
-
-
- typename std::enable_if<!std::is_integral<T1>::value ||
- !std::is_pointer<T2>::value>::type* = nullptr>
- static AssertionResult Compare(const char* lhs_expression,
- const char* rhs_expression, const T1& lhs,
- const T2& rhs) {
- return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
- }
-
-
-
-
-
-
- static AssertionResult Compare(const char* lhs_expression,
- const char* rhs_expression,
- BiggestInt lhs,
- BiggestInt rhs) {
- return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
- }
- template <typename T>
- static AssertionResult Compare(
- const char* lhs_expression, const char* rhs_expression,
-
- std::nullptr_t , T* rhs) {
-
- return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
- rhs);
- }
- };
- template <typename T1, typename T2>
- AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
- const T1& val1, const T2& val2,
- const char* op) {
- return AssertionFailure()
- << "Expected: (" << expr1 << ") " << op << " (" << expr2
- << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
- << " vs " << FormatForComparisonFailureMessage(val2, val1);
- }
- #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
- template <typename T1, typename T2>\
- AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
- const T1& val1, const T2& val2) {\
- if (val1 op val2) {\
- return AssertionSuccess();\
- } else {\
- return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
- }\
- }
- GTEST_IMPL_CMP_HELPER_(NE, !=)
- GTEST_IMPL_CMP_HELPER_(LE, <=)
- GTEST_IMPL_CMP_HELPER_(LT, <)
- GTEST_IMPL_CMP_HELPER_(GE, >=)
- GTEST_IMPL_CMP_HELPER_(GT, >)
- #undef GTEST_IMPL_CMP_HELPER_
- GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
- const char* s2_expression,
- const wchar_t* s1,
- const wchar_t* s2);
- GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
- const char* s2_expression,
- const wchar_t* s1,
- const wchar_t* s2);
- }
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const char* needle, const char* haystack);
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const wchar_t* needle, const wchar_t* haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const char* needle, const char* haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const wchar_t* needle, const wchar_t* haystack);
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::string& needle, const ::std::string& haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::string& needle, const ::std::string& haystack);
- #if GTEST_HAS_STD_WSTRING
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::wstring& needle, const ::std::wstring& haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::wstring& needle, const ::std::wstring& haystack);
- #endif
- namespace internal {
- template <typename RawType>
- AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
- const char* rhs_expression,
- RawType lhs_value,
- RawType rhs_value) {
- const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
- if (lhs.AlmostEquals(rhs)) {
- return AssertionSuccess();
- }
- ::std::stringstream lhs_ss;
- lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << lhs_value;
- ::std::stringstream rhs_ss;
- rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << rhs_value;
- return EqFailure(lhs_expression,
- rhs_expression,
- StringStreamToString(&lhs_ss),
- StringStreamToString(&rhs_ss),
- false);
- }
- GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
- const char* expr2,
- const char* abs_error_expr,
- double val1,
- double val2,
- double abs_error);
- class GTEST_API_ AssertHelper {
- public:
-
- AssertHelper(TestPartResult::Type type,
- const char* file,
- int line,
- const char* message);
- ~AssertHelper();
-
-
- void operator=(const Message& message) const;
- private:
-
-
-
-
- struct AssertHelperData {
- AssertHelperData(TestPartResult::Type t,
- const char* srcfile,
- int line_num,
- const char* msg)
- : type(t), file(srcfile), line(line_num), message(msg) { }
- TestPartResult::Type const type;
- const char* const file;
- int const line;
- std::string const message;
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
- };
- AssertHelperData* const data_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
- };
- }
- template <typename T>
- class WithParamInterface {
- public:
- typedef T ParamType;
- virtual ~WithParamInterface() {}
-
-
- static const ParamType& GetParam() {
- GTEST_CHECK_(parameter_ != nullptr)
- << "GetParam() can only be called inside a value-parameterized test "
- << "-- did you intend to write TEST_P instead of TEST_F?";
- return *parameter_;
- }
- private:
-
-
- static void SetParam(const ParamType* parameter) {
- parameter_ = parameter;
- }
-
- static const ParamType* parameter_;
-
- template <class TestClass> friend class internal::ParameterizedTestFactory;
- };
- template <typename T>
- const T* WithParamInterface<T>::parameter_ = nullptr;
- template <typename T>
- class TestWithParam : public Test, public WithParamInterface<T> {
- };
- #define GTEST_SKIP() GTEST_SKIP_("")
- #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
- #define ADD_FAILURE_AT(file, line) \
- GTEST_MESSAGE_AT_(file, line, "Failed", \
- ::testing::TestPartResult::kNonFatalFailure)
- #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
- #define GTEST_FAIL_AT(file, line) \
- GTEST_MESSAGE_AT_(file, line, "Failed", \
- ::testing::TestPartResult::kFatalFailure)
- #if !GTEST_DONT_DEFINE_FAIL
- # define FAIL() GTEST_FAIL()
- #endif
- #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
- #if !GTEST_DONT_DEFINE_SUCCEED
- # define SUCCEED() GTEST_SUCCEED()
- #endif
- #define EXPECT_THROW(statement, expected_exception) \
- GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_NO_THROW(statement) \
- GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_ANY_THROW(statement) \
- GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_THROW(statement, expected_exception) \
- GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
- #define ASSERT_NO_THROW(statement) \
- GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
- #define ASSERT_ANY_THROW(statement) \
- GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
- #define GTEST_EXPECT_TRUE(condition) \
- GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
- GTEST_NONFATAL_FAILURE_)
- #define GTEST_EXPECT_FALSE(condition) \
- GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
- GTEST_NONFATAL_FAILURE_)
- #define GTEST_ASSERT_TRUE(condition) \
- GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
- GTEST_FATAL_FAILURE_)
- #define GTEST_ASSERT_FALSE(condition) \
- GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
- GTEST_FATAL_FAILURE_)
- #if !GTEST_DONT_DEFINE_EXPECT_TRUE
- #define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_EXPECT_FALSE
- #define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_TRUE
- #define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_FALSE
- #define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)
- #endif
- #define EXPECT_EQ(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
- #define EXPECT_NE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
- #define EXPECT_LE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
- #define EXPECT_LT(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
- #define EXPECT_GE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
- #define EXPECT_GT(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
- #define GTEST_ASSERT_EQ(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
- #define GTEST_ASSERT_NE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
- #define GTEST_ASSERT_LE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
- #define GTEST_ASSERT_LT(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
- #define GTEST_ASSERT_GE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
- #define GTEST_ASSERT_GT(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
- #if !GTEST_DONT_DEFINE_ASSERT_EQ
- # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_NE
- # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_LE
- # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_LT
- # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_GE
- # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_GT
- # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
- #endif
- #define EXPECT_STREQ(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
- #define EXPECT_STRNE(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
- #define EXPECT_STRCASEEQ(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
- #define EXPECT_STRCASENE(s1, s2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
- #define ASSERT_STREQ(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
- #define ASSERT_STRNE(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
- #define ASSERT_STRCASEEQ(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
- #define ASSERT_STRCASENE(s1, s2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
- #define EXPECT_FLOAT_EQ(val1, val2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
- val1, val2)
- #define EXPECT_DOUBLE_EQ(val1, val2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
- val1, val2)
- #define ASSERT_FLOAT_EQ(val1, val2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
- val1, val2)
- #define ASSERT_DOUBLE_EQ(val1, val2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
- val1, val2)
- #define EXPECT_NEAR(val1, val2, abs_error)\
- EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
- val1, val2, abs_error)
- #define ASSERT_NEAR(val1, val2, abs_error)\
- ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
- val1, val2, abs_error)
- GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
- float val1, float val2);
- GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
- double val1, double val2);
- #if GTEST_OS_WINDOWS
- # define EXPECT_HRESULT_SUCCEEDED(expr) \
- EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
- # define ASSERT_HRESULT_SUCCEEDED(expr) \
- ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
- # define EXPECT_HRESULT_FAILED(expr) \
- EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
- # define ASSERT_HRESULT_FAILED(expr) \
- ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
- #endif
- #define ASSERT_NO_FATAL_FAILURE(statement) \
- GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
- #define EXPECT_NO_FATAL_FAILURE(statement) \
- GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
- class GTEST_API_ ScopedTrace {
- public:
-
-
-
-
- template <typename T>
- ScopedTrace(const char* file, int line, const T& message) {
- PushTrace(file, line, (Message() << message).GetString());
- }
-
- ScopedTrace(const char* file, int line, const char* message) {
- PushTrace(file, line, message ? message : "(null)");
- }
- ScopedTrace(const char* file, int line, const std::string& message) {
- PushTrace(file, line, message);
- }
-
-
-
-
- ~ScopedTrace();
- private:
- void PushTrace(const char* file, int line, std::string message);
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
- } GTEST_ATTRIBUTE_UNUSED_;
-
-
- #define SCOPED_TRACE(message) \
- ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
- __FILE__, __LINE__, (message))
- template <typename T1, typename T2>
- constexpr bool StaticAssertTypeEq() noexcept {
- static_assert(std::is_same<T1, T2>::value, "T1 and T2 are not the same type");
- return true;
- }
- #define GTEST_TEST(test_suite_name, test_name) \
- GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
- ::testing::internal::GetTestTypeId())
- #if !GTEST_DONT_DEFINE_TEST
- #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
- #endif
- #if !GTEST_DONT_DEFINE_TEST
- #define TEST_F(test_fixture, test_name)\
- GTEST_TEST_(test_fixture, test_name, test_fixture, \
- ::testing::internal::GetTypeId<test_fixture>())
- #endif
- GTEST_API_ std::string TempDir();
- #ifdef _MSC_VER
- # pragma warning(pop)
- #endif
- template <int&... ExplicitParameterBarrier, typename Factory>
- TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
- const char* type_param, const char* value_param,
- const char* file, int line, Factory factory) {
- using TestT = typename std::remove_pointer<decltype(factory())>::type;
- class FactoryImpl : public internal::TestFactoryBase {
- public:
- explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
- Test* CreateTest() override { return factory_(); }
- private:
- Factory factory_;
- };
- return internal::MakeAndRegisterTestInfo(
- test_suite_name, test_name, type_param, value_param,
- internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),
- internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(file, line),
- internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(file, line),
- new FactoryImpl{std::move(factory)});
- }
- }
- int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
- inline int RUN_ALL_TESTS() {
- return ::testing::UnitTest::GetInstance()->Run();
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
|