1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309 |
- using System.Text;
- using UICatalog;
- using Xunit.Abstractions;
- // Alias Console to MockConsole so we don't accidentally use Console
- namespace Terminal.Gui.TextTests;
- public class TextFormatterTests
- {
- public TextFormatterTests (ITestOutputHelper output) { _output = output; }
- private readonly ITestOutputHelper _output;
- [Theory]
- [InlineData ("")]
- [InlineData (null)]
- [InlineData ("test")]
- public void ClipAndJustify_Invalid_Returns_Original (string text)
- {
- string expected = string.IsNullOrEmpty (text) ? text : "";
- Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Start));
- Assert.Equal (expected, TextFormatter.ClipAndJustify (text, 0, Alignment.Start));
- Assert.Throws<ArgumentOutOfRangeException> (
- () =>
- TextFormatter.ClipAndJustify (text, -1, Alignment.Start)
- );
- }
- [Theory]
- [InlineData ("test", "", 0)]
- [InlineData ("test", "te", 2)]
- [InlineData ("test", "test", int.MaxValue)]
- [InlineData ("A sentence has words.", "A sentence has words.", 22)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", 21)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", int.MaxValue)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words", 20)] // Should not fit
- [InlineData ("A sentence has words.", "A sentence", 10)] // Should not fit
- [InlineData ("A\tsentence\thas\twords.", "A sentence has words.", int.MaxValue)]
- [InlineData ("A\tsentence\thas\twords.", "A sentence", 10)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline2\nline3long!", int.MaxValue)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline", 10)]
- [InlineData (" ~ s gui.cs master ↑10", " ~ s ", 10)] // Unicode
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 5)] // should fit
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 4)] // should fit
- [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
- public void ClipAndJustify_Valid_Centered (string text, string justifiedText, int maxWidth)
- {
- var alignment = Alignment.Center;
- var textDirection = TextDirection.LeftRight_TopBottom;
- var tabWidth = 1;
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- Assert.True (justifiedText.GetRuneCount () <= maxWidth);
- Assert.True (justifiedText.GetColumns () <= maxWidth);
- Assert.Equal (expectedClippedWidth, justifiedText.GetRuneCount ());
- Assert.Equal (
- expectedClippedWidth,
- justifiedText.ToRuneList ().Sum (r => Math.Max (r.GetColumns (), 1))
- );
- Assert.True (expectedClippedWidth <= maxWidth);
- Assert.Equal (
- StringExtensions.ToString (justifiedText.ToRunes () [..expectedClippedWidth]),
- justifiedText
- );
- }
- [Theory]
- [InlineData ("test", "", 0)]
- [InlineData ("test", "te", 2)]
- [InlineData ("test", "test", int.MaxValue)] // This doesn't throw because it only create a word with length 1
- [InlineData ("A sentence has words.", "A sentence has words.", 22)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", 21)] // should fit
- [InlineData (
- "A sentence has words.",
- "A sentence has words.",
- 500
- )] // should fit
- [InlineData ("A sentence has words.", "A sentence has words", 20)] // Should not fit
- [InlineData ("A sentence has words.", "A sentence", 10)] // Should not fit
- // Now throw System.OutOfMemoryException. See https://stackoverflow.com/questions/20672920/maxcapacity-of-stringbuilder
- //[InlineData ("A\tsentence\thas\twords.", "A sentence has words.", int.MaxValue)]
- [InlineData ("A\tsentence\thas\twords.", "A sentence", 10)]
- [InlineData (
- "line1\nline2\nline3long!",
- "line1\nline2\nline3long!",
- int.MaxValue
- )] // This doesn't throw because it only create a line with length 1
- [InlineData ("line1\nline2\nline3long!", "line1\nline", 10)]
- [InlineData (" ~ s gui.cs master ↑10", " ~ s ", 10)] // Unicode
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 5)] // should fit
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 4)] // should fit
- [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
- public void ClipAndJustify_Valid_Justified (string text, string justifiedText, int maxWidth)
- {
- var alignment = Alignment.Fill;
- var textDirection = TextDirection.LeftRight_TopBottom;
- var tabWidth = 1;
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- Assert.True (justifiedText.GetRuneCount () <= maxWidth);
- Assert.True (justifiedText.GetColumns () <= maxWidth);
- Assert.Equal (expectedClippedWidth, justifiedText.GetRuneCount ());
- Assert.Equal (
- expectedClippedWidth,
- justifiedText.ToRuneList ().Sum (r => Math.Max (r.GetColumns (), 1))
- );
- Assert.True (expectedClippedWidth <= maxWidth);
- Assert.Equal (
- StringExtensions.ToString (justifiedText.ToRunes () [..expectedClippedWidth]),
- justifiedText
- );
- // see Justify_ tests below
- }
- [Theory]
- [InlineData ("test", "", 0)]
- [InlineData ("test", "te", 2)]
- [InlineData ("test", "test", int.MaxValue)]
- [InlineData ("A sentence has words.", "A sentence has words.", 22)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", 21)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", int.MaxValue)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words", 20)] // Should not fit
- [InlineData ("A sentence has words.", "A sentence", 10)] // Should not fit
- [InlineData ("A\tsentence\thas\twords.", "A sentence has words.", int.MaxValue)]
- [InlineData ("A\tsentence\thas\twords.", "A sentence", 10)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline2\nline3long!", int.MaxValue)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline", 10)]
- [InlineData (" ~ s gui.cs master ↑10", " ~ s ", 10)] // Unicode
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 5)] // should fit
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 4)] // should fit
- [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
- public void ClipAndJustify_Valid_Left (string text, string justifiedText, int maxWidth)
- {
- var alignment = Alignment.Start;
- var textDirection = TextDirection.LeftRight_BottomTop;
- var tabWidth = 1;
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- Assert.True (justifiedText.GetRuneCount () <= maxWidth);
- Assert.True (justifiedText.GetColumns () <= maxWidth);
- Assert.Equal (expectedClippedWidth, justifiedText.GetRuneCount ());
- Assert.Equal (
- expectedClippedWidth,
- justifiedText.ToRuneList ().Sum (r => Math.Max (r.GetColumns (), 1))
- );
- Assert.True (expectedClippedWidth <= maxWidth);
- Assert.Equal (
- StringExtensions.ToString (justifiedText.ToRunes () [..expectedClippedWidth]),
- justifiedText
- );
- }
- [Theory]
- [InlineData ("test", "", 0)]
- [InlineData ("test", "te", 2)]
- [InlineData ("test", "test", int.MaxValue)]
- [InlineData ("A sentence has words.", "A sentence has words.", 22)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", 21)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words.", int.MaxValue)] // should fit
- [InlineData ("A sentence has words.", "A sentence has words", 20)] // Should not fit
- [InlineData ("A sentence has words.", "A sentence", 10)] // Should not fit
- [InlineData ("A\tsentence\thas\twords.", "A sentence has words.", int.MaxValue)]
- [InlineData ("A\tsentence\thas\twords.", "A sentence", 10)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline2\nline3long!", int.MaxValue)]
- [InlineData ("line1\nline2\nline3long!", "line1\nline", 10)]
- [InlineData (" ~ s gui.cs master ↑10", " ~ s ", 10)] // Unicode
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 5)] // should fit
- [InlineData ("Ð ÑÐ", "Ð ÑÐ", 4)] // should fit
- [InlineData ("Ð ÑÐ", "Ð Ñ", 3)] // Should not fit
- public void ClipAndJustify_Valid_Right (string text, string justifiedText, int maxWidth)
- {
- var alignment = Alignment.End;
- var textDirection = TextDirection.LeftRight_BottomTop;
- var tabWidth = 1;
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- int expectedClippedWidth = Math.Min (justifiedText.GetRuneCount (), maxWidth);
- Assert.Equal (
- justifiedText,
- TextFormatter.ClipAndJustify (text, maxWidth, alignment, textDirection, tabWidth)
- );
- Assert.True (justifiedText.GetRuneCount () <= maxWidth);
- Assert.True (justifiedText.GetColumns () <= maxWidth);
- Assert.Equal (expectedClippedWidth, justifiedText.GetRuneCount ());
- Assert.Equal (
- expectedClippedWidth,
- justifiedText.ToRuneList ().Sum (r => Math.Max (r.GetColumns (), 1))
- );
- Assert.True (expectedClippedWidth <= maxWidth);
- Assert.Equal (
- StringExtensions.ToString (justifiedText.ToRunes () [..expectedClippedWidth]),
- justifiedText
- );
- }
- public static IEnumerable<object []> CMGlyphs =>
- new List<object []> { new object [] { $"{CM.Glyphs.LeftBracket} Say Hello 你 {CM.Glyphs.RightBracket}", 16, 15 } };
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 0, "")]
- [InlineData ("A", 1, "A")]
- [InlineData ("A", 2, "A")]
- [InlineData ("A", 3, " A")]
- [InlineData ("AB", 1, "A")]
- [InlineData ("AB", 2, "AB")]
- [InlineData ("ABC", 3, "ABC")]
- [InlineData ("ABC", 4, "ABC")]
- [InlineData ("ABC", 5, " ABC")]
- [InlineData ("ABC", 6, " ABC")]
- [InlineData ("ABC", 9, " ABC")]
- public void Draw_Horizontal_Centered (string text, int width, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.Center
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = 1;
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 0, "")]
- [InlineData ("A", 1, "A")]
- [InlineData ("A", 2, "A")]
- [InlineData ("A B", 3, "A B")]
- [InlineData ("A B", 1, "A")]
- [InlineData ("A B", 2, "A")]
- [InlineData ("A B", 4, "A B")]
- [InlineData ("A B", 5, "A B")]
- [InlineData ("A B", 6, "A B")]
- [InlineData ("A B", 10, "A B")]
- [InlineData ("ABC ABC", 10, "ABC ABC")]
- public void Draw_Horizontal_Justified (string text, int width, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.Fill
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = 1;
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 0, "")]
- [InlineData ("A", 1, "A")]
- [InlineData ("A", 2, "A")]
- [InlineData ("AB", 1, "A")]
- [InlineData ("AB", 2, "AB")]
- [InlineData ("ABC", 3, "ABC")]
- [InlineData ("ABC", 4, "ABC")]
- [InlineData ("ABC", 6, "ABC")]
- public void Draw_Horizontal_Left (string text, int width, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.Start
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = 1;
- tf.Draw (new (0, 0, width, 1), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 0, "")]
- [InlineData ("A", 1, "A")]
- [InlineData ("A", 2, " A")]
- [InlineData ("AB", 1, "B")]
- [InlineData ("AB", 2, "AB")]
- [InlineData ("ABC", 3, "ABC")]
- [InlineData ("ABC", 4, " ABC")]
- [InlineData ("ABC", 6, " ABC")]
- public void Draw_Horizontal_Right (string text, int width, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.End
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = 1;
- tf.Draw (new (Point.Empty, new (width, 1)), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 1, 0, "")]
- [InlineData ("A", 0, 1, "")]
- [InlineData ("AB1 2", 2, 1, "2")]
- [InlineData ("AB12", 5, 1, "21BA")]
- [InlineData ("AB\n12", 5, 2, "21\nBA")]
- [InlineData ("ABC 123 456", 7, 2, "CBA \n654 321")]
- [InlineData ("こんにちは", 1, 1, "")]
- [InlineData ("こんにちは", 2, 1, "は")]
- [InlineData ("こんにちは", 5, 1, "はち")]
- [InlineData ("こんにちは", 10, 1, "はちにんこ")]
- [InlineData ("こんにちは\nAB\n12", 10, 3, "21 \nBA \nはちにんこ")]
- public void Draw_Horizontal_RightLeft_BottomTop (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.RightLeft_BottomTop
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 1, 0, "")]
- [InlineData ("A", 0, 1, "")]
- [InlineData ("AB1 2", 2, 1, "2")]
- [InlineData ("AB12", 5, 1, "21BA")]
- [InlineData ("AB\n12", 5, 2, "BA\n21")]
- [InlineData ("ABC 123 456", 7, 2, "654 321\nCBA ")]
- [InlineData ("こんにちは", 1, 1, "")]
- [InlineData ("こんにちは", 2, 1, "は")]
- [InlineData ("こんにちは", 5, 1, "はち")]
- [InlineData ("こんにちは", 10, 1, "はちにんこ")]
- [InlineData ("こんにちは\nAB\n12", 10, 3, "はちにんこ\nBA \n21 ")]
- public void Draw_Horizontal_RightLeft_TopBottom (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.RightLeft_TopBottom
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- // Horizontal with Alignment.Start
- // LeftRight_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 2 4**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- **0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- *0 2 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- *0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- // LeftRight_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 2 4**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- **0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- *0 2 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- *0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- // RightLeft_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 2 0**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- **4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- *4 2 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- *4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- // RightLeft_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 2 0**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- **4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- *4 2 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- *4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- // Horizontal with Alignment.End
- // LeftRight_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 2 4**")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- **0 2 4")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *0 2 4*")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 2 4")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *0 你 4")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4*")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4")]
- // LeftRight_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 2 4**")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- **0 2 4")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *0 2 4*")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 2 4")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *0 你 4")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4*")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 0 你 4")]
- // RightLeft_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 2 0**")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- **4 2 0")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *4 2 0*")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 2 0")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *4 你 0")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0*")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0")]
- // RightLeft_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 2 0**")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- **4 2 0")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *4 2 0*")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 2 0")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- *4 你 0")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0*")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *******
- *******
- *******
- 4 你 0")]
- // Horizontal with alignment.Centered
- // LeftRight_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- 0 2 4**
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- **0 2 4
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *0 2 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- 0 2 4
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- 0 你 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- *0 你 4
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- 0 你 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.LeftRight_TopBottom,
- @"
- *******
- *******
- *******
- 0 你 4
- *******
- *******
- *******")]
- // LeftRight_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- 0 2 4**
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- **0 2 4
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *0 2 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- 0 2 4
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- 0 你 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- *0 你 4
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- 0 你 4*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.LeftRight_BottomTop,
- @"
- *******
- *******
- *******
- 0 你 4
- *******
- *******
- *******")]
- // RightLeft_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- 4 2 0**
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- **4 2 0
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *4 2 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- 4 2 0
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- 4 你 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- *4 你 0
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- 4 你 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.RightLeft_TopBottom,
- @"
- *******
- *******
- *******
- 4 你 0
- *******
- *******
- *******")]
- // RightLeft_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- 4 2 0**
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- **4 2 0
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *4 2 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- 4 2 0
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- 4 你 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- *4 你 0
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- 4 你 0*
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.RightLeft_BottomTop,
- @"
- *******
- *******
- *******
- 4 你 0
- *******
- *******
- *******")]
- // Horizontal with alignment.Justified
- // LeftRight_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 2 4**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- **0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- *0 2 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- *0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.LeftRight_TopBottom,
- @"
- 0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- // LeftRight_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 2 4**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- **0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- *0 2 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 2 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- *0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.LeftRight_BottomTop,
- @"
- 0 你 4
- *******
- *******
- *******
- *******
- *******
- *******")]
- // RightLeft_TopBottom
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 2 0**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- **4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- *4 2 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- *4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.RightLeft_TopBottom,
- @"
- 4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- // RightLeft_BottomTop
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 2 0**
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- **4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- *4 2 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 2 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- *4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0*
- *******
- *******
- *******
- *******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.RightLeft_BottomTop,
- @"
- 4 你 0
- *******
- *******
- *******
- *******
- *******
- *******")]
- // Vertical with alignment.Left
- // TopBottom_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- 2******
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- 0******
- ******
- 2******
- ******
- 4******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- 0******
- ******
- 2******
- ******
- 4******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- ******
- 2******
- ******
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- 你*****
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- 0******
- ******
- 你*****
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- 0******
- ******
- 你*****
- ******
- 4******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- ******
- 你*****
- ******
- ******
- 4******")]
- // TopBottom_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- 2******
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- 0******
- ******
- 2******
- ******
- 4******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- 0******
- ******
- 2******
- ******
- 4******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- ******
- 2******
- ******
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- 你*****
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- 0******
- ******
- 你*****
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- 0******
- ******
- 你*****
- ******
- 4******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- ******
- 你*****
- ******
- ******
- 4******")]
- // BottomTop_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- 2******
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- 4******
- ******
- 2******
- ******
- 0******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- 4******
- ******
- 2******
- ******
- 0******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- ******
- 2******
- ******
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- 你*****
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- 4******
- ******
- 你*****
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- 4******
- ******
- 你*****
- ******
- 0******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- ******
- 你*****
- ******
- ******
- 0******")]
- // BottomTop_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- 2******
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- 4******
- ******
- 2******
- ******
- 0******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- 4******
- ******
- 2******
- ******
- 0******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- ******
- 2******
- ******
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- 你*****
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- 4******
- ******
- 你*****
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- 4******
- ******
- 你*****
- ******
- 0******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Start,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- ******
- 你*****
- ******
- ******
- 0******")]
- // Vertical with alignment.Right
- // TopBottom_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- ******0
- ******
- ******2
- ******
- ******4
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- ******0
- ******
- ******2
- ******
- ******4")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- ******0
- ******
- ******2
- ******
- ******4
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- ******0
- ******
- ******
- ******2
- ******
- ******
- ******4")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- *****0*
- ***** *
- *****你
- ***** *
- *****4*
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- *****0*
- ***** *
- *****你
- ***** *
- *****4*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *****0*
- ***** *
- *****你
- ***** *
- *****4*
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- *****0*
- ***** *
- ***** *
- *****你
- ***** *
- ***** *
- *****4*")]
- // TopBottom_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- ******0
- ******
- ******2
- ******
- ******4
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- ******0
- ******
- ******2
- ******
- ******4")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- ******0
- ******
- ******2
- ******
- ******4
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- ******0
- ******
- ******
- ******2
- ******
- ******
- ******4")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- *****0*
- ***** *
- *****你
- ***** *
- *****4*
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- *****0*
- ***** *
- *****你
- ***** *
- *****4*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *****0*
- ***** *
- *****你
- ***** *
- *****4*
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- *****0*
- ***** *
- ***** *
- *****你
- ***** *
- ***** *
- *****4*")]
- // BottomTop_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- ******4
- ******
- ******2
- ******
- ******0
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- ******4
- ******
- ******2
- ******
- ******0")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- ******4
- ******
- ******2
- ******
- ******0
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- ******4
- ******
- ******
- ******2
- ******
- ******
- ******0")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- *****4*
- ***** *
- *****你
- ***** *
- *****0*
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- *****4*
- ***** *
- *****你
- ***** *
- *****0*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *****4*
- ***** *
- *****你
- ***** *
- *****0*
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- *****4*
- ***** *
- ***** *
- *****你
- ***** *
- ***** *
- *****0*")]
- // BottomTop_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- ******4
- ******
- ******2
- ******
- ******0
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- ******4
- ******
- ******2
- ******
- ******0")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- ******4
- ******
- ******2
- ******
- ******0
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- ******4
- ******
- ******
- ******2
- ******
- ******
- ******0")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- *****4*
- ***** *
- *****你
- ***** *
- *****0*
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- *****4*
- ***** *
- *****你
- ***** *
- *****0*")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *****4*
- ***** *
- *****你
- ***** *
- *****0*
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.End,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- *****4*
- ***** *
- ***** *
- *****你
- ***** *
- ***** *
- *****0*")]
- // Vertical with alignment.Centered
- // TopBottom_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- ***0***
- *** ***
- *** ***
- ***2***
- *** ***
- *** ***
- ***4***")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- **0****
- ** ****
- **你***
- ** ****
- **4****
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- **0****
- ** ****
- **你***
- ** ****
- **4****")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- **0****
- ** ****
- **你***
- ** ****
- **4****
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- **0****
- ** ****
- ** ****
- **你***
- ** ****
- ** ****
- **4****")]
- // TopBottom_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- ***0***
- *** ***
- ***2***
- *** ***
- ***4***
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- ***0***
- *** ***
- *** ***
- ***2***
- *** ***
- *** ***
- ***4***")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- **0****
- ** ****
- **你***
- ** ****
- **4****
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- **0****
- ** ****
- **你***
- ** ****
- **4****")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- **0****
- ** ****
- **你***
- ** ****
- **4****
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- **0****
- ** ****
- ** ****
- **你***
- ** ****
- ** ****
- **4****")]
- // BottomTop_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- ***4***
- *** ***
- *** ***
- ***2***
- *** ***
- *** ***
- ***0***")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- **4****
- ** ****
- **你***
- ** ****
- **0****
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- **4****
- ** ****
- **你***
- ** ****
- **0****")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- **4****
- ** ****
- **你***
- ** ****
- **0****
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- **4****
- ** ****
- ** ****
- **你***
- ** ****
- ** ****
- **0****")]
- // BottomTop_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- ***4***
- *** ***
- ***2***
- *** ***
- ***0***
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- ***4***
- *** ***
- *** ***
- ***2***
- *** ***
- *** ***
- ***0***")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- **4****
- ** ****
- **你***
- ** ****
- **0****
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- **4****
- ** ****
- **你***
- ** ****
- **0****")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- **4****
- ** ****
- **你***
- ** ****
- **0****
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Center,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- **4****
- ** ****
- ** ****
- **你***
- ** ****
- ** ****
- **0****")]
- // Vertical with alignment.Justified
- // TopBottom_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- 2******
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- 0******
- ******
- 2******
- ******
- 4******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- 0******
- ******
- 2******
- ******
- 4******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- ******
- 2******
- ******
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- 你*****
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- *******
- 0******
- ******
- 你*****
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.TopBottom_LeftRight,
- @"
- *******
- 0******
- ******
- 你*****
- ******
- 4******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.TopBottom_LeftRight,
- @"
- 0******
- ******
- ******
- 你*****
- ******
- ******
- 4******")]
- // TopBottom_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- 2******
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- 0******
- ******
- 2******
- ******
- 4******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- 0******
- ******
- 2******
- ******
- 4******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- ******
- 2******
- ******
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- 你*****
- ******
- 4******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- *******
- 0******
- ******
- 你*****
- ******
- 4******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.TopBottom_RightLeft,
- @"
- *******
- 0******
- ******
- 你*****
- ******
- 4******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.TopBottom_RightLeft,
- @"
- 0******
- ******
- ******
- 你*****
- ******
- ******
- 4******")]
- // BottomTop_LeftRight
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- 2******
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- 4******
- ******
- 2******
- ******
- 0******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- 4******
- ******
- 2******
- ******
- 0******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- ******
- 2******
- ******
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- 你*****
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- *******
- 4******
- ******
- 你*****
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.BottomTop_LeftRight,
- @"
- *******
- 4******
- ******
- 你*****
- ******
- 0******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.BottomTop_LeftRight,
- @"
- 4******
- ******
- ******
- 你*****
- ******
- ******
- 0******")]
- // BottomTop_RightLeft
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- 2******
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- 4******
- ******
- 2******
- ******
- 0******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- 4******
- ******
- 2******
- ******
- 0******
- *******")]
- [InlineData (
- "0 2 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- ******
- 2******
- ******
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Start,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- 你*****
- ******
- 0******
- *******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.End,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- *******
- 4******
- ******
- 你*****
- ******
- 0******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Center,
- TextDirection.BottomTop_RightLeft,
- @"
- *******
- 4******
- ******
- 你*****
- ******
- 0******
- *******")]
- [InlineData (
- "0 你 4",
- Alignment.Fill,
- Alignment.Fill,
- TextDirection.BottomTop_RightLeft,
- @"
- 4******
- ******
- ******
- 你*****
- ******
- ******
- 0******")]
- public void Draw_Text_Justification (string text, Alignment horizontalTextAlignment, Alignment alignment, TextDirection textDirection, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Alignment = horizontalTextAlignment,
- VerticalAlignment = alignment,
- Direction = textDirection,
- ConstrainToSize = new (7, 7),
- Text = text
- };
- Application.Driver?.FillRect (new (0, 0, 7, 7), (Rune)'*');
- tf.Draw (new (0, 0, 7, 7), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 0, 1, "", 0)]
- [InlineData ("A", 1, 1, "A", 0)]
- [InlineData ("A", 2, 2, " A", 1)]
- [InlineData ("AB", 1, 1, "B", 0)]
- [InlineData ("AB", 2, 2, " A\n B", 0)]
- [InlineData ("ABC", 3, 2, " B\n C", 0)]
- [InlineData ("ABC", 4, 2, " B\n C", 0)]
- [InlineData ("ABC", 6, 2, " B\n C", 0)]
- [InlineData ("こんにちは", 0, 1, "", 0)]
- [InlineData ("こんにちは", 1, 0, "", 0)]
- [InlineData ("こんにちは", 1, 1, "", 0)]
- [InlineData ("こんにちは", 2, 1, "は", 0)]
- [InlineData ("こんにちは", 2, 2, "ち\nは", 0)]
- [InlineData ("こんにちは", 2, 3, "に\nち\nは", 0)]
- [InlineData ("こんにちは", 2, 4, "ん\nに\nち\nは", 0)]
- [InlineData ("こんにちは", 2, 5, "こ\nん\nに\nち\nは", 0)]
- [InlineData ("こんにちは", 2, 6, "こ\nん\nに\nち\nは", 1)]
- [InlineData ("ABCD\nこんにちは", 4, 7, " こ\n Aん\n Bに\n Cち\n Dは", 2)]
- [InlineData ("こんにちは\nABCD", 3, 7, "こ \nんA\nにB\nちC\nはD", 2)]
- public void Draw_Vertical_Bottom_Horizontal_Right (string text, int width, int height, string expectedText, int expectedY)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.End,
- Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = Alignment.End
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (Point.Empty, new (width, height)), Attribute.Default, Attribute.Default);
- Rectangle rect = TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- Assert.Equal (expectedY, rect.Y);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 1, 0, "")]
- [InlineData ("A", 0, 1, "")]
- [InlineData ("AB1 2", 1, 2, "2")]
- [InlineData ("AB12", 1, 5, "2\n1\nB\nA")]
- [InlineData ("AB\n12", 2, 5, "B2\nA1")]
- [InlineData ("ABC 123 456", 2, 7, "6C\n5B\n4A\n \n3 \n2 \n1 ")]
- [InlineData ("こんにちは", 1, 1, "")]
- [InlineData ("こんにちは", 2, 1, "は")]
- [InlineData ("こんにちは", 2, 5, "は\nち\nに\nん\nこ")]
- [InlineData ("こんにちは", 2, 10, "は\nち\nに\nん\nこ")]
- [InlineData ("こんにちは\nAB\n12", 4, 10, "はB2\nちA1\nに \nん \nこ ")]
- public void Draw_Vertical_BottomTop_LeftRight (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.BottomTop_LeftRight
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 1, 0, "")]
- [InlineData ("A", 0, 1, "")]
- [InlineData ("AB1 2", 1, 2, "2")]
- [InlineData ("AB12", 1, 5, "2\n1\nB\nA")]
- [InlineData ("AB\n12", 2, 5, "2B\n1A")]
- [InlineData ("ABC 123 456", 2, 7, "C6\nB5\nA4\n \n 3\n 2\n 1")]
- [InlineData ("こんにちは", 1, 1, "")]
- [InlineData ("こんにちは", 2, 1, "は")]
- [InlineData ("こんにちは", 2, 5, "は\nち\nに\nん\nこ")]
- [InlineData ("こんにちは", 2, 10, "は\nち\nに\nん\nこ")]
- [InlineData ("こんにちは\nAB\n12", 4, 10, "2Bは\n1Aち\n に\n ん\n こ")]
- public void Draw_Vertical_BottomTop_RightLeft (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.BottomTop_RightLeft
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- // Draw tests - Note that these depend on View
- [Fact]
- [TestRespondersDisposed]
- public void Draw_Vertical_Throws_IndexOutOfRangeException_With_Negative_Bounds ()
- {
- Application.Init (new FakeDriver ());
- Dialog.DefaultShadow = ShadowStyle.None;
- Button.DefaultShadow = ShadowStyle.None;
- Toplevel top = new ();
- var view = new View { Y = -2, Height = 10, TextDirection = TextDirection.TopBottom_LeftRight, Text = "view" };
- top.Add (view);
- Application.Iteration += (s, a) =>
- {
- Assert.Equal (-2, view.Y);
- Application.RequestStop ();
- };
- try
- {
- Application.Run (top);
- }
- catch (IndexOutOfRangeException ex)
- {
- // After the fix this exception will not be caught.
- Assert.IsType<IndexOutOfRangeException> (ex);
- }
- top.Dispose ();
- // Shutdown must be called to safely clean up Application if Init has been called
- Application.Shutdown ();
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 5, 5, "A")]
- [InlineData (
- "AB12",
- 5,
- 5,
- @"
- A
- B
- 1
- 2")]
- [InlineData (
- "AB\n12",
- 5,
- 5,
- @"
- A1
- B2")]
- [InlineData ("", 5, 1, "")]
- [InlineData (
- "Hello Worlds",
- 1,
- 12,
- @"
- H
- e
- l
- l
- o
-
- W
- o
- r
- l
- d
- s")]
- [InlineData ("Hello Worlds", 12, 1, @"HelloWorlds")]
- public void Draw_Vertical_TopBottom_LeftRight (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.TopBottom_LeftRight
- };
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, 20, 20), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [SetupFakeDriver]
- [Theory]
- // The expectedY param is to probe that the expectedText param start at that Y coordinate
- [InlineData ("A", 0, "", 0)]
- [InlineData ("A", 1, "A", 0)]
- [InlineData ("A", 2, "A", 0)]
- [InlineData ("A", 3, "A", 1)]
- [InlineData ("AB", 1, "A", 0)]
- [InlineData ("AB", 2, "A\nB", 0)]
- [InlineData ("ABC", 2, "A\nB", 0)]
- [InlineData ("ABC", 3, "A\nB\nC", 0)]
- [InlineData ("ABC", 4, "A\nB\nC", 0)]
- [InlineData ("ABC", 5, "A\nB\nC", 1)]
- [InlineData ("ABC", 6, "A\nB\nC", 1)]
- [InlineData ("ABC", 9, "A\nB\nC", 3)]
- [InlineData ("ABCD", 2, "B\nC", 0)]
- [InlineData ("こんにちは", 0, "", 0)]
- [InlineData ("こんにちは", 1, "に", 0)]
- [InlineData ("こんにちは", 2, "ん\nに", 0)]
- [InlineData ("こんにちは", 3, "ん\nに\nち", 0)]
- [InlineData ("こんにちは", 4, "こ\nん\nに\nち", 0)]
- [InlineData ("こんにちは", 5, "こ\nん\nに\nち\nは", 0)]
- [InlineData ("こんにちは", 6, "こ\nん\nに\nち\nは", 0)]
- [InlineData ("ABCD\nこんにちは", 7, "Aこ\nBん\nCに\nDち\n は", 1)]
- [InlineData ("こんにちは\nABCD", 7, "こA\nんB\nにC\nちD\nは ", 1)]
- public void Draw_Vertical_TopBottom_LeftRight_Middle (string text, int height, string expectedText, int expectedY)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = Alignment.Center
- };
- int width = text.ToRunes ().Max (r => r.GetColumns ());
- if (text.Contains ("\n"))
- {
- width++;
- }
- tf.ConstrainToWidth = width;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default);
- Rectangle rect = TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- Assert.Equal (expectedY, rect.Y);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("A", 5, "A")]
- [InlineData (
- "AB12",
- 5,
- @"
- A
- B
- 1
- 2")]
- [InlineData (
- "AB\n12",
- 5,
- @"
- A1
- B2")]
- [InlineData ("", 1, "")]
- [InlineData (
- "AB1 2",
- 2,
- @"
- A12
- B ")]
- [InlineData (
- "こんにちは",
- 1,
- @"
- こん")]
- [InlineData (
- "こんにちは",
- 2,
- @"
- こに
- んち")]
- [InlineData (
- "こんにちは",
- 5,
- @"
- こ
- ん
- に
- ち
- は")]
- public void Draw_Vertical_TopBottom_LeftRight_Top (string text, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.TopBottom_LeftRight
- };
- tf.ConstrainToWidth = 5;
- tf.ConstrainToHeight = height;
- tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [Theory]
- [InlineData (14, 1, TextDirection.LeftRight_TopBottom, "Les Misęrables")]
- [InlineData (1, 14, TextDirection.TopBottom_LeftRight, "L\ne\ns\n \nM\ni\ns\nę\nr\na\nb\nl\ne\ns")]
- [InlineData (
- 4,
- 4,
- TextDirection.TopBottom_LeftRight,
- @"
- LMre
- eias
- ssb
- ęl "
- )]
- public void Draw_With_Combining_Runes (int width, int height, TextDirection textDirection, string expected)
- {
- var driver = new FakeDriver ();
- driver.Init ();
- var text = "Les Mise\u0328\u0301rables";
- var tf = new TextFormatter ();
- tf.Direction = textDirection;
- tf.Text = text;
- Assert.True (tf.WordWrap);
- tf.ConstrainToSize = new (width, height);
- tf.Draw (
- new (0, 0, width, height),
- new (ColorName16.White, ColorName16.Black),
- new (ColorName16.Blue, ColorName16.Black),
- default (Rectangle),
- driver
- );
- TestHelpers.AssertDriverContentsWithFrameAre (expected, _output, driver);
- driver.End ();
- }
- [Fact]
- [SetupFakeDriver]
- public void FillRemaining_True_False ()
- {
- ((FakeDriver)Application.Driver!).SetBufferSize (22, 5);
- Attribute [] attrs =
- {
- Attribute.Default, new (ColorName16.Green, ColorName16.BrightMagenta),
- new (ColorName16.Blue, ColorName16.Cyan)
- };
- var tf = new TextFormatter { ConstrainToSize = new (14, 3), Text = "Test\nTest long\nTest long long\n", MultiLine = true };
- tf.Draw (
- new (1, 1, 19, 3),
- attrs [1],
- attrs [2]);
- Assert.False (tf.FillRemaining);
- TestHelpers.AssertDriverContentsWithFrameAre (
- @"
- Test
- Test long
- Test long long",
- _output);
- TestHelpers.AssertDriverAttributesAre (
- @"
- 000000000000000000000
- 011110000000000000000
- 011111111100000000000
- 011111111111111000000
- 000000000000000000000",
- _output,
- null,
- attrs);
- tf.FillRemaining = true;
- tf.Draw (
- new (1, 1, 19, 3),
- attrs [1],
- attrs [2]);
- TestHelpers.AssertDriverAttributesAre (
- @"
- 000000000000000000000
- 011111111111111111110
- 011111111111111111110
- 011111111111111111110
- 000000000000000000000",
- _output,
- null,
- attrs);
- }
- [Theory]
- [InlineData ("_k Before", true, 0, (KeyCode)'K')] // lower case should return uppercase Hotkey
- [InlineData ("a_k Second", true, 1, (KeyCode)'K')]
- [InlineData ("Last _k", true, 5, (KeyCode)'K')]
- [InlineData ("After k_", false, -1, KeyCode.Null)]
- [InlineData ("Multiple _k and _R", true, 9, (KeyCode)'K')]
- [InlineData ("Non-english: _кдать", true, 13, (KeyCode)'к')] // Lower case Cryllic K (к)
- [InlineData ("_k Before", true, 0, (KeyCode)'K', true)] // Turn on FirstUpperCase and verify same results
- [InlineData ("a_k Second", true, 1, (KeyCode)'K', true)]
- [InlineData ("Last _k", true, 5, (KeyCode)'K', true)]
- [InlineData ("After k_", false, -1, KeyCode.Null, true)]
- [InlineData ("Multiple _k and _r", true, 9, (KeyCode)'K', true)]
- [InlineData ("Non-english: _кдать", true, 13, (KeyCode)'к', true)] // Cryllic K (К)
- public void FindHotKey_AlphaLowerCase_Succeeds (
- string text,
- bool expectedResult,
- int expectedHotPos,
- KeyCode expectedKey,
- bool supportFirstUpperCase = false
- )
- {
- var hotKeySpecifier = (Rune)'_';
- bool result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out int hotPos,
- out Key hotKey,
- supportFirstUpperCase
- );
- if (expectedResult)
- {
- Assert.True (result);
- }
- else
- {
- Assert.False (result);
- }
- Assert.Equal (expectedResult, result);
- Assert.Equal (expectedHotPos, hotPos);
- Assert.Equal (expectedKey, hotKey);
- }
- [Theory]
- [InlineData ("_K Before", true, 0, (KeyCode)'K')]
- [InlineData ("a_K Second", true, 1, (KeyCode)'K')]
- [InlineData ("Last _K", true, 5, (KeyCode)'K')]
- [InlineData ("After K_", false, -1, KeyCode.Null)]
- [InlineData ("Multiple _K and _R", true, 9, (KeyCode)'K')]
- [InlineData ("Non-english: _Кдать", true, 13, (KeyCode)'К')] // Cryllic K (К)
- [InlineData ("_K Before", true, 0, (KeyCode)'K', true)] // Turn on FirstUpperCase and verify same results
- [InlineData ("a_K Second", true, 1, (KeyCode)'K', true)]
- [InlineData ("Last _K", true, 5, (KeyCode)'K', true)]
- [InlineData ("After K_", false, -1, KeyCode.Null, true)]
- [InlineData ("Multiple _K and _R", true, 9, (KeyCode)'K', true)]
- [InlineData ("Non-english: _Кдать", true, 13, (KeyCode)'К', true)] // Cryllic K (К)
- public void FindHotKey_AlphaUpperCase_Succeeds (
- string text,
- bool expectedResult,
- int expectedHotPos,
- KeyCode expectedKey,
- bool supportFirstUpperCase = false
- )
- {
- var hotKeySpecifier = (Rune)'_';
- bool result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out int hotPos,
- out Key hotKey,
- supportFirstUpperCase
- );
- if (expectedResult)
- {
- Assert.True (result);
- }
- else
- {
- Assert.False (result);
- }
- Assert.Equal (expectedResult, result);
- Assert.Equal (expectedHotPos, hotPos);
- Assert.Equal (expectedKey, hotKey);
- }
- [Theory]
- [InlineData (null)]
- [InlineData ("")]
- [InlineData ("no hotkey")]
- [InlineData ("No hotkey, Upper Case")]
- [InlineData ("Non-english: Сохранить")]
- public void FindHotKey_Invalid_ReturnsFalse (string text)
- {
- var hotKeySpecifier = (Rune)'_';
- var supportFirstUpperCase = false;
- var hotPos = 0;
- Key hotKey = KeyCode.Null;
- var result = false;
- result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out hotPos,
- out hotKey,
- supportFirstUpperCase
- );
- Assert.False (result);
- Assert.Equal (-1, hotPos);
- Assert.Equal (KeyCode.Null, hotKey);
- }
- [Theory]
- [InlineData ("\"k before")]
- [InlineData ("ak second")]
- [InlineData ("last k")]
- [InlineData ("multiple k and r")]
- [InlineData ("12345")]
- [InlineData ("`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?")] // punctuation
- [InlineData (" ~ s gui.cs master ↑10")] // ~IsLetterOrDigit + Unicode
- [InlineData ("non-english: кдать")] // Lower case Cryllic K (к)
- public void FindHotKey_Legacy_FirstUpperCase_NotFound_Returns_False (string text)
- {
- var supportFirstUpperCase = true;
- var hotKeySpecifier = (Rune)0;
- bool result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out int hotPos,
- out Key hotKey,
- supportFirstUpperCase
- );
- Assert.False (result);
- Assert.Equal (-1, hotPos);
- Assert.Equal (KeyCode.Null, hotKey);
- }
- [Theory]
- [InlineData ("K Before", true, 0, (KeyCode)'K')]
- [InlineData ("aK Second", true, 1, (KeyCode)'K')]
- [InlineData ("last K", true, 5, (KeyCode)'K')]
- [InlineData ("multiple K and R", true, 9, (KeyCode)'K')]
- [InlineData ("non-english: Кдать", true, 13, (KeyCode)'К')] // Cryllic K (К)
- public void FindHotKey_Legacy_FirstUpperCase_Succeeds (
- string text,
- bool expectedResult,
- int expectedHotPos,
- KeyCode expectedKey
- )
- {
- var supportFirstUpperCase = true;
- var hotKeySpecifier = (Rune)0;
- bool result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out int hotPos,
- out Key hotKey,
- supportFirstUpperCase
- );
- if (expectedResult)
- {
- Assert.True (result);
- }
- else
- {
- Assert.False (result);
- }
- Assert.Equal (expectedResult, result);
- Assert.Equal (expectedHotPos, hotPos);
- Assert.Equal (expectedKey, hotKey);
- }
- [Theory]
- [InlineData ("_1 Before", true, 0, (KeyCode)'1')] // Digits
- [InlineData ("a_1 Second", true, 1, (KeyCode)'1')]
- [InlineData ("Last _1", true, 5, (KeyCode)'1')]
- [InlineData ("After 1_", false, -1, KeyCode.Null)]
- [InlineData ("Multiple _1 and _2", true, 9, (KeyCode)'1')]
- [InlineData ("_1 Before", true, 0, (KeyCode)'1', true)] // Turn on FirstUpperCase and verify same results
- [InlineData ("a_1 Second", true, 1, (KeyCode)'1', true)]
- [InlineData ("Last _1", true, 5, (KeyCode)'1', true)]
- [InlineData ("After 1_", false, -1, KeyCode.Null, true)]
- [InlineData ("Multiple _1 and _2", true, 9, (KeyCode)'1', true)]
- public void FindHotKey_Numeric_Succeeds (
- string text,
- bool expectedResult,
- int expectedHotPos,
- KeyCode expectedKey,
- bool supportFirstUpperCase = false
- )
- {
- var hotKeySpecifier = (Rune)'_';
- bool result = TextFormatter.FindHotKey (
- text,
- hotKeySpecifier,
- out int hotPos,
- out Key hotKey,
- supportFirstUpperCase
- );
- if (expectedResult)
- {
- Assert.True (result);
- }
- else
- {
- Assert.False (result);
- }
- Assert.Equal (expectedResult, result);
- Assert.Equal (expectedHotPos, hotPos);
- Assert.Equal (expectedKey, hotKey);
- }
- [Theory]
- [InlineData ("_\"k before", true, (KeyCode)'"')] // BUGBUG: Not sure why this fails. " is a normal char
- [InlineData ("\"_k before", true, KeyCode.K)]
- [InlineData ("_`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (KeyCode)'`')]
- [InlineData ("`_~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?", true, (KeyCode)'~')]
- [InlineData (
- "`~!@#$%^&*()-__=+[{]}\\|;:'\",<.>/?",
- true,
- (KeyCode)'='
- )] // BUGBUG: Not sure why this fails. Ignore the first and consider the second
- [InlineData ("_ ~ s gui.cs master ↑10", true, (KeyCode)'')] // ~IsLetterOrDigit + Unicode
- [InlineData (" ~ s gui.cs _ master ↑10", true, (KeyCode)'')] // ~IsLetterOrDigit + Unicode
- [InlineData ("non-english: _кдать", true, (KeyCode)'к')] // Lower case Cryllic K (к)
- public void FindHotKey_Symbols_Returns_Symbol (string text, bool found, KeyCode expected)
- {
- var hotKeySpecifier = (Rune)'_';
- bool result = TextFormatter.FindHotKey (text, hotKeySpecifier, out int _, out Key hotKey);
- Assert.Equal (found, result);
- Assert.Equal (expected, hotKey);
- }
- [Fact]
- public void Format_Dont_Throw_ArgumentException_With_WordWrap_As_False_And_Keep_End_Spaces_As_True ()
- {
- Exception exception = Record.Exception (
- () =>
- TextFormatter.Format (
- "Some text",
- 4,
- Alignment.Start,
- false,
- true
- )
- );
- Assert.Null (exception);
- }
- [Theory]
- [InlineData (
- "Hello world, how are you today? Pretty neat!",
- 44,
- 80,
- "Hello world, how are you today? Pretty neat!"
- )]
- public void Format_Justified_Always_Returns_Text_Width_Equal_To_Passed_Width_Horizontal (
- string text,
- int runeCount,
- int maxWidth,
- string justifiedText
- )
- {
- Assert.Equal (runeCount, text.GetRuneCount ());
- var fmtText = string.Empty;
- for (int i = text.GetRuneCount (); i < maxWidth; i++)
- {
- fmtText = TextFormatter.Format (text, i, Alignment.Fill, true) [0];
- Assert.Equal (i, fmtText.GetRuneCount ());
- char c = fmtText [^1];
- Assert.True (text.EndsWith (c));
- }
- Assert.Equal (justifiedText, fmtText);
- }
- [Theory]
- [InlineData (
- "Hello world, how are you today? Pretty neat!",
- 44,
- 80,
- "Hello world, how are you today? Pretty neat!"
- )]
- public void Format_Justified_Always_Returns_Text_Width_Equal_To_Passed_Width_Vertical (
- string text,
- int runeCount,
- int maxWidth,
- string justifiedText
- )
- {
- Assert.Equal (runeCount, text.GetRuneCount ());
- var fmtText = string.Empty;
- for (int i = text.GetRuneCount (); i < maxWidth; i++)
- {
- fmtText = TextFormatter.Format (
- text,
- i,
- Alignment.Fill,
- false,
- true,
- 0,
- TextDirection.TopBottom_LeftRight
- ) [0];
- Assert.Equal (i, fmtText.GetRuneCount ());
- char c = fmtText [^1];
- Assert.True (text.EndsWith (c));
- }
- Assert.Equal (justifiedText, fmtText);
- }
- [Theory]
- [InlineData ("Truncate", 3, "Tru")]
- [InlineData ("デモエムポンズ", 3, "デ")]
- public void Format_Truncate_Simple_And_Wide_Runes (string text, int width, string expected)
- {
- List<string> list = TextFormatter.Format (text, width, false, false);
- Assert.Equal (expected, list [^1]);
- }
- [Theory]
- [MemberData (nameof (FormatEnvironmentNewLine))]
- public void Format_With_PreserveTrailingSpaces_And_Without_PreserveTrailingSpaces (
- string text,
- int width,
- IEnumerable<string> expected
- )
- {
- var preserveTrailingSpaces = false;
- List<string> formated = TextFormatter.Format (text, width, false, true, preserveTrailingSpaces);
- Assert.Equal (expected, formated);
- preserveTrailingSpaces = true;
- formated = TextFormatter.Format (text, width, false, true, preserveTrailingSpaces);
- Assert.Equal (expected, formated);
- }
- [Theory]
- [InlineData (
- " A sentence has words. \n This is the second Line - 2. ",
- 4,
- -50,
- Alignment.Start,
- true,
- false,
- new [] { " A", "sent", "ence", "has", "word", "s. ", " Thi", "s is", "the", "seco", "nd", "Line", "- 2." },
- " Asentencehaswords. This isthesecondLine- 2."
- )]
- [InlineData (
- " A sentence has words. \n This is the second Line - 2. ",
- 4,
- -50,
- Alignment.Start,
- true,
- true,
- new []
- {
- " A ",
- "sent",
- "ence",
- " ",
- "has ",
- "word",
- "s. ",
- " ",
- "This",
- " is ",
- "the ",
- "seco",
- "nd ",
- "Line",
- " - ",
- "2. "
- },
- " A sentence has words. This is the second Line - 2. "
- )]
- public void Format_WordWrap_PreserveTrailingSpaces (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- bool preserveTrailingSpaces,
- IEnumerable<string> resultLines,
- string expectedWrappedText
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
- Assert.Equal (list.Count, resultLines.Count ());
- Assert.Equal (resultLines, list);
- var wrappedText = string.Empty;
- foreach (string txt in list)
- {
- wrappedText += txt;
- }
- Assert.Equal (expectedWrappedText, wrappedText);
- }
- [Theory]
- [InlineData (
- "Les Mise\u0301rables",
- 14,
- -1,
- false,
- new [] { "Les Misérables" },
- "Les Misérables"
- )]
- [InlineData (
- "Les Mise\u0328\u0301rables",
- 14,
- -2,
- false,
- new [] { "Les Misę́rables" },
- "Les Misę́rables"
- )]
- public void Format_Combining_Marks_Alignments (
- string text,
- int maxWidth,
- int widthOffset,
- bool wrap,
- IEnumerable<string> resultLines,
- string expectedText
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- // Horizontal text direction
- foreach (Alignment alignment in Enum.GetValues (typeof (Alignment)))
- {
- TextFormatter tf = new () { Text = text, ConstrainToSize = new (maxWidth, 1), WordWrap = wrap, Alignment = alignment };
- List<string> list = TextFormatter.Format (
- text,
- maxWidth,
- alignment,
- wrap,
- tf.PreserveTrailingSpaces,
- tf.TabWidth,
- tf.Direction,
- tf.MultiLine,
- tf);
- Assert.Equal (list.Count, resultLines.Count ());
- Assert.Equal (resultLines, list);
- var formattedText = string.Empty;
- foreach (string txt in list)
- {
- formattedText += txt;
- }
- Assert.Equal (expectedText, formattedText);
- }
- // Vertical text direction
- foreach (Alignment alignment in Enum.GetValues (typeof (Alignment)))
- {
- TextFormatter tf = new ()
- { Text = text, ConstrainToSize = new (1, maxWidth), WordWrap = wrap, VerticalAlignment = alignment, Direction = TextDirection.TopBottom_LeftRight };
- List<string> list = TextFormatter.Format (
- text,
- maxWidth,
- alignment,
- wrap,
- tf.PreserveTrailingSpaces,
- tf.TabWidth,
- tf.Direction,
- tf.MultiLine,
- tf);
- Assert.Equal (list.Count, resultLines.Count ());
- Assert.Equal (resultLines, list);
- var formattedText = string.Empty;
- foreach (string txt in list)
- {
- formattedText += txt;
- }
- Assert.Equal (expectedText, formattedText);
- }
- }
- public static IEnumerable<object []> FormatEnvironmentNewLine =>
- new List<object []>
- {
- new object []
- {
- $"Line1{Environment.NewLine}Line2{Environment.NewLine}Line3{Environment.NewLine}",
- 60,
- new [] { "Line1", "Line2", "Line3" }
- }
- };
- [Theory]
- [InlineData ("Hello World", 11)]
- [InlineData ("こんにちは世界", 14)]
- public void GetColumns_Simple_And_Wide_Runes (string text, int width) { Assert.Equal (width, text.GetColumns ()); }
- [Theory]
- [InlineData (new [] { "0123456789" }, 1)]
- [InlineData (new [] { "Hello World" }, 1)]
- [InlineData (new [] { "Hello", "World" }, 2)]
- [InlineData (new [] { "こんにちは", "世界" }, 4)]
- public void GetColumnsRequiredForVerticalText_List_GetsWidth (IEnumerable<string> text, int expectedWidth)
- {
- Assert.Equal (expectedWidth, TextFormatter.GetColumnsRequiredForVerticalText (text.ToList ()));
- }
- [Theory]
- [InlineData (new [] { "Hello World" }, 1, 0, 1, 1)]
- [InlineData (new [] { "Hello", "World" }, 2, 1, 1, 1)]
- [InlineData (new [] { "こんにちは", "世界" }, 4, 1, 1, 2)]
- public void GetColumnsRequiredForVerticalText_List_Simple_And_Wide_Runes (
- IEnumerable<string> text,
- int expectedWidth,
- int index,
- int length,
- int expectedIndexWidth
- )
- {
- Assert.Equal (expectedWidth, TextFormatter.GetColumnsRequiredForVerticalText (text.ToList ()));
- Assert.Equal (expectedIndexWidth, TextFormatter.GetColumnsRequiredForVerticalText (text.ToList (), index, length));
- }
- [Fact]
- public void GetColumnsRequiredForVerticalText_List_With_Combining_Runes ()
- {
- List<string> text = new () { "Les Mis", "e\u0328\u0301", "rables" };
- Assert.Equal (1, TextFormatter.GetColumnsRequiredForVerticalText (text, 1, 1));
- }
- [Theory]
- [InlineData ("Hello World", 6, 6)]
- [InlineData ("こんにちは 世界", 6, 3)]
- [MemberData (nameof (CMGlyphs))]
- public void GetLengthThatFits_List_Simple_And_Wide_Runes (string text, int columns, int expectedLength)
- {
- List<Rune> runes = text.ToRuneList ();
- Assert.Equal (expectedLength, TextFormatter.GetLengthThatFits (runes, columns));
- }
- [Theory]
- [InlineData ("test", 3, 3)]
- [InlineData ("test", 4, 4)]
- [InlineData ("test", 10, 4)]
- public void GetLengthThatFits_Runelist (string text, int columns, int expectedLength)
- {
- List<Rune> runes = text.ToRuneList ();
- Assert.Equal (expectedLength, TextFormatter.GetLengthThatFits (runes, columns));
- }
- [Theory]
- [InlineData ("Hello World", 6, 6)]
- [InlineData ("こんにちは 世界", 6, 3)]
- public void GetLengthThatFits_Simple_And_Wide_Runes (string text, int columns, int expectedLength)
- {
- Assert.Equal (expectedLength, TextFormatter.GetLengthThatFits (text, columns));
- }
- [Theory]
- [InlineData ("test", 3, 3)]
- [InlineData ("test", 4, 4)]
- [InlineData ("test", 10, 4)]
- [InlineData ("test", 1, 1)]
- [InlineData ("test", 0, 0)]
- [InlineData ("test", -1, 0)]
- [InlineData (null, -1, 0)]
- [InlineData ("", -1, 0)]
- public void GetLengthThatFits_String (string text, int columns, int expectedLength)
- {
- Assert.Equal (expectedLength, TextFormatter.GetLengthThatFits (text, columns));
- }
- [Fact]
- public void GetLengthThatFits_With_Combining_Runes ()
- {
- var text = "Les Mise\u0328\u0301rables";
- Assert.Equal (16, TextFormatter.GetLengthThatFits (text, 14));
- }
- [Fact]
- public void GetMaxColsForWidth_With_Combining_Runes ()
- {
- List<string> text = new () { "Les Mis", "e\u0328\u0301", "rables" };
- Assert.Equal (1, TextFormatter.GetMaxColsForWidth (text, 1));
- }
- //[Fact]
- //public void GetWidestLineLength_With_Combining_Runes ()
- //{
- // var text = "Les Mise\u0328\u0301rables";
- // Assert.Equal (1, TextFormatter.GetWidestLineLength (text, 1, 1));
- //}
- [Fact]
- public void Internal_Tests ()
- {
- var tf = new TextFormatter ();
- Assert.Equal (KeyCode.Null, tf.HotKey);
- tf.HotKey = KeyCode.CtrlMask | KeyCode.Q;
- Assert.Equal (KeyCode.CtrlMask | KeyCode.Q, tf.HotKey);
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("Hello World", 15, 1, "Hello World")]
- [InlineData (
- "Well Done\nNice Work",
- 15,
- 2,
- @"
- Well Done
- Nice Work")]
- [InlineData ("你好 世界", 15, 1, "你好 世界")]
- [InlineData (
- "做 得好\n幹 得好",
- 15,
- 2,
- @"
- 做 得好
- 幹 得好")]
- public void Justify_Horizontal (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Alignment = Alignment.Fill,
- ConstrainToSize = new Size (width, height),
- MultiLine = true
- };
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [Theory]
- [InlineData ("")]
- [InlineData (null)]
- [InlineData ("test")]
- public void Justify_Invalid (string text)
- {
- Assert.Equal (text, TextFormatter.Justify (text, 0));
- Assert.Equal (text, TextFormatter.Justify (text, 0));
- Assert.Throws<ArgumentOutOfRangeException> (() => TextFormatter.Justify (text, -1));
- }
- [Theory]
- // Even # of spaces
- // 0123456789
- [InlineData ("012 456 89", "012 456 89", 10, 0, "+", true)]
- [InlineData ("012 456 89", "012++456+89", 11, 1)]
- [InlineData ("012 456 89", "012 456 89", 12, 2, "++", true)]
- [InlineData ("012 456 89", "012+++456++89", 13, 3)]
- [InlineData ("012 456 89", "012 456 89", 14, 4, "+++", true)]
- [InlineData ("012 456 89", "012++++456+++89", 15, 5)]
- [InlineData ("012 456 89", "012 456 89", 16, 6, "++++", true)]
- [InlineData ("012 456 89", "012 456 89", 30, 20, "+++++++++++", true)]
- [InlineData ("012 456 89", "012+++++++++++++456++++++++++++89", 33, 23)]
- // Odd # of spaces
- // 01234567890123
- [InlineData ("012 456 89 end", "012 456 89 end", 14, 0, "+", true)]
- [InlineData ("012 456 89 end", "012++456+89+end", 15, 1)]
- [InlineData ("012 456 89 end", "012++456++89+end", 16, 2)]
- [InlineData ("012 456 89 end", "012 456 89 end", 17, 3, "++", true)]
- [InlineData ("012 456 89 end", "012+++456++89++end", 18, 4)]
- [InlineData ("012 456 89 end", "012+++456+++89++end", 19, 5)]
- [InlineData ("012 456 89 end", "012 456 89 end", 20, 6, "+++", true)]
- [InlineData ("012 456 89 end", "012++++++++456++++++++89+++++++end", 34, 20)]
- [InlineData ("012 456 89 end", "012+++++++++456+++++++++89++++++++end", 37, 23)]
- // Unicode
- // Even # of chars
- // 0123456789
- [InlineData ("пÑРвРÑ", "пÑРвРÑ", 10, 0, "+", true)]
- [InlineData ("пÑРвРÑ", "пÑÐ++вÐ+Ñ", 11, 1)]
- [InlineData ("пÑРвРÑ", "пÑРвРÑ", 12, 2, "++", true)]
- [InlineData ("пÑРвРÑ", "пÑÐ+++вÐ++Ñ", 13, 3)]
- [InlineData ("пÑРвРÑ", "пÑРвРÑ", 14, 4, "+++", true)]
- [InlineData ("пÑРвРÑ", "пÑÐ++++вÐ+++Ñ", 15, 5)]
- [InlineData ("пÑРвРÑ", "пÑРвРÑ", 16, 6, "++++", true)]
- [InlineData ("пÑРвРÑ", "пÑРвРÑ", 30, 20, "+++++++++++", true)]
- [InlineData ("пÑРвРÑ", "пÑÐ+++++++++++++вÐ++++++++++++Ñ", 33, 23)]
- // Unicode
- // Odd # of chars
- // 0123456789
- [InlineData ("Ð ÑРвРÑ", "Ð ÑРвРÑ", 10, 0, "+", true)]
- [InlineData ("Ð ÑРвРÑ", "Ð++ÑÐ+вÐ+Ñ", 11, 1)]
- [InlineData ("Ð ÑРвРÑ", "Ð++ÑÐ++вÐ+Ñ", 12, 2)]
- [InlineData ("Ð ÑРвРÑ", "Ð ÑРвРÑ", 13, 3, "++", true)]
- [InlineData ("Ð ÑРвРÑ", "Ð+++ÑÐ++вÐ++Ñ", 14, 4)]
- [InlineData ("Ð ÑРвРÑ", "Ð+++ÑÐ+++вÐ++Ñ", 15, 5)]
- [InlineData ("Ð ÑРвРÑ", "Ð ÑРвРÑ", 16, 6, "+++", true)]
- [InlineData ("Ð ÑРвРÑ", "Ð++++++++ÑÐ++++++++вÐ+++++++Ñ", 30, 20)]
- [InlineData ("Ð ÑРвРÑ", "Ð+++++++++ÑÐ+++++++++вÐ++++++++Ñ", 33, 23)]
- public void Justify_Sentence (
- string text,
- string justifiedText,
- int forceToWidth,
- int widthOffset,
- string replaceWith = null,
- bool replace = false
- )
- {
- var fillChar = '+';
- Assert.Equal (forceToWidth, text.GetRuneCount () + widthOffset);
- if (replace)
- {
- justifiedText = text.Replace (" ", replaceWith);
- }
- Assert.Equal (justifiedText, TextFormatter.Justify (text, forceToWidth, fillChar));
- Assert.True (Math.Abs (forceToWidth - justifiedText.GetRuneCount ()) < text.Count (s => s == ' '));
- Assert.True (Math.Abs (forceToWidth - justifiedText.GetColumns ()) < text.Count (s => s == ' '));
- }
- [Theory]
- [InlineData ("word")] // Even # of chars
- [InlineData ("word.")] // Odd # of chars
- [InlineData ("пÑивеÑ")] // Unicode (even #)
- [InlineData ("пÑивеÑ.")] // Unicode (odd # of chars)
- public void Justify_SingleWord (string text)
- {
- string justifiedText = text;
- var fillChar = '+';
- int width = text.GetRuneCount ();
- Assert.Equal (justifiedText, TextFormatter.Justify (text, width, fillChar));
- width = text.GetRuneCount () + 1;
- Assert.Equal (justifiedText, TextFormatter.Justify (text, width, fillChar));
- width = text.GetRuneCount () + 2;
- Assert.Equal (justifiedText, TextFormatter.Justify (text, width, fillChar));
- width = text.GetRuneCount () + 10;
- Assert.Equal (justifiedText, TextFormatter.Justify (text, width, fillChar));
- width = text.GetRuneCount () + 11;
- Assert.Equal (justifiedText, TextFormatter.Justify (text, width, fillChar));
- }
- [SetupFakeDriver]
- [Theory]
- [InlineData ("Hello World", 1, 15, "H\ne\nl\nl\no\n \n \n \n \n \nW\no\nr\nl\nd")]
- [InlineData (
- "Well Done\nNice Work",
- 2,
- 15,
- @"
- WN
- ei
- lc
- le
-
-
-
-
-
-
-
- DW
- oo
- nr
- ek")]
- [InlineData ("你好 世界", 2, 15, "你\n好\n \n \n \n \n \n \n \n \n \n \n \n世\n界")]
- [InlineData (
- "做 得好\n幹 得好",
- 4,
- 15,
- @"
- 做幹
-
-
-
-
-
-
-
-
-
-
-
-
- 得得
- 好好")]
- public void Justify_Vertical (string text, int width, int height, string expectedText)
- {
- TextFormatter tf = new ()
- {
- Text = text,
- Direction = TextDirection.TopBottom_LeftRight,
- VerticalAlignment = Alignment.Fill,
- ConstrainToSize = new Size (width, height),
- MultiLine = true
- };
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
- }
- [Theory]
- [InlineData ("Single Line 界", 14)]
- [InlineData ("First Line 界\nSecond Line 界\nThird Line 界\n", 14)]
- public void MaxWidthLine_With_And_Without_Newlines (string text, int expected) { Assert.Equal (expected, TextFormatter.GetWidestLineLength (text)); }
- [Theory]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 0,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 1,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 1,
- 0,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 0,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 1,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 1,
- 0,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 6,
- 5,
- false,
- new [] { "First " }
- )]
- [InlineData ("1\n2\n3\n4\n5\n6", 6, 5, false, new [] { "1 2 3 " })]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 6,
- 5,
- true,
- new [] { "First ", "Second", "Third ", "Forty ", "Fiftee" }
- )]
- [InlineData ("第一行\n第二行\n第三行\n四十行\n第十五行\n七十行", 5, 5, false, new [] { "第一" })]
- [InlineData ("第一行\n第二行\n第三行\n四十行\n第十五行\n七十行", 5, 5, true, new [] { "第一", "第二", "第三", "四十", "第十" })]
- public void MultiLine_WordWrap_False_Horizontal_Direction (
- string text,
- int maxWidth,
- int maxHeight,
- bool multiLine,
- IEnumerable<string> resultLines
- )
- {
- var tf = new TextFormatter
- {
- Text = text, ConstrainToSize = new (maxWidth, maxHeight), WordWrap = false, MultiLine = multiLine
- };
- Assert.False (tf.WordWrap);
- Assert.True (tf.MultiLine == multiLine);
- Assert.Equal (TextDirection.LeftRight_TopBottom, tf.Direction);
- List<string> splitLines = tf.GetLines ();
- Assert.Equal (splitLines.Count, resultLines.Count ());
- Assert.Equal (splitLines, resultLines);
- }
- [Theory]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 0,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 1,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 1,
- 0,
- false,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 0,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 0,
- 1,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 1,
- 0,
- true,
- new [] { "" }
- )]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 6,
- 5,
- false,
- new [] { "First" }
- )]
- [InlineData ("1\n2\n3\n4\n5\n6", 6, 5, false, new [] { "1 2 3" })]
- [InlineData (
- "First Line\nSecond Line\nThird Line\nForty Line\nFifteenth Line\nSeventy Line",
- 6,
- 5,
- true,
- new [] { "First", "Secon", "Third", "Forty", "Fifte", "Seven" }
- )]
- [InlineData ("第一行\n第二行\n第三行\n四十行\n第十五行\n七十行", 5, 5, false, new [] { "第一行 第" })]
- [InlineData ("第一行\n第二行\n第三行\n四十行\n第十五行\n七十行", 5, 5, true, new [] { "第一行", "第二行" })]
- public void MultiLine_WordWrap_False_Vertical_Direction (
- string text,
- int maxWidth,
- int maxHeight,
- bool multiLine,
- IEnumerable<string> resultLines
- )
- {
- var tf = new TextFormatter
- {
- Text = text,
- ConstrainToSize = new (maxWidth, maxHeight),
- WordWrap = false,
- MultiLine = multiLine,
- Direction = TextDirection.TopBottom_LeftRight
- };
- Assert.False (tf.WordWrap);
- Assert.True (tf.MultiLine == multiLine);
- Assert.Equal (TextDirection.TopBottom_LeftRight, tf.Direction);
- List<string> splitLines = tf.GetLines ();
- Assert.Equal (splitLines.Count, resultLines.Count ());
- Assert.Equal (splitLines, resultLines);
- }
- [Fact]
- public void NeedsFormat_Sets ()
- {
- var testText = "test";
- var testBounds = new Rectangle (0, 0, 100, 1);
- var tf = new TextFormatter ();
- tf.Text = "test";
- Assert.True (tf.NeedsFormat); // get_Lines causes a Format
- Assert.NotEmpty (tf.GetLines ());
- Assert.False (tf.NeedsFormat); // get_Lines causes a Format
- Assert.Equal (testText, tf.Text);
- tf.Draw (testBounds, new (), new ());
- Assert.False (tf.NeedsFormat);
- tf.ConstrainToSize = new (1, 1);
- Assert.True (tf.NeedsFormat);
- Assert.NotEmpty (tf.GetLines ());
- Assert.False (tf.NeedsFormat); // get_Lines causes a Format
- tf.Alignment = Alignment.Center;
- Assert.True (tf.NeedsFormat);
- Assert.NotEmpty (tf.GetLines ());
- Assert.False (tf.NeedsFormat); // get_Lines causes a Format
- }
- // Test that changing TextFormatter does not impact View dimensions if Dim.Auto is not in play
- [Fact]
- public void Not_Used_TextFormatter_Does_Not_Change_View_Size ()
- {
- View view = new ()
- {
- Text = "_1234"
- };
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.Text = "ABC";
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.Alignment = Alignment.Fill;
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.VerticalAlignment = Alignment.Center;
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.HotKeySpecifier = (Rune)'*';
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextFormatter.Text = "*ABC";
- Assert.Equal (Size.Empty, view.Frame.Size);
- }
- [Fact]
- public void Not_Used_TextSettings_Do_Not_Change_View_Size ()
- {
- View view = new ()
- {
- Text = "_1234"
- };
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.TextAlignment = Alignment.Fill;
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.VerticalTextAlignment = Alignment.Center;
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.HotKeySpecifier = (Rune)'*';
- Assert.Equal (Size.Empty, view.Frame.Size);
- view.Text = "*ABC";
- Assert.Equal (Size.Empty, view.Frame.Size);
- }
- [Theory]
- [InlineData ("", -1, Alignment.Start, false, 0)]
- [InlineData (null, 0, Alignment.Start, false, 1)]
- [InlineData (null, 0, Alignment.Start, true, 1)]
- [InlineData ("", 0, Alignment.Start, false, 1)]
- [InlineData ("", 0, Alignment.Start, true, 1)]
- public void Reformat_Invalid (string text, int maxWidth, Alignment alignment, bool wrap, int linesCount)
- {
- if (maxWidth < 0)
- {
- Assert.Throws<ArgumentOutOfRangeException> (
- () =>
- TextFormatter.Format (text, maxWidth, alignment, wrap)
- );
- }
- else
- {
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap);
- Assert.NotEmpty (list);
- Assert.True (list.Count == linesCount);
- Assert.Equal (string.Empty, list [0]);
- }
- }
- [Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true)]
- [InlineData ("A sentence has words.\nLine 2.", 1, -28, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 5, -24, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 28, -1, Alignment.Start, false, 1, false)]
- // no clip
- [InlineData ("A sentence has words.\nLine 2.", 29, 0, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\nLine 2.", 30, 1, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true)]
- [InlineData ("A sentence has words.\r\nLine 2.", 1, -29, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 5, -25, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 29, -1, Alignment.Start, false, 1, false, 1)]
- [InlineData ("A sentence has words.\r\nLine 2.", 30, 0, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.\r\nLine 2.", 31, 1, Alignment.Start, false, 1, false)]
- public void Reformat_NoWordrap_NewLines_MultiLine_False (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- int linesCount,
- bool stringEmpty,
- int clipWidthOffset = 0
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth) + clipWidthOffset;
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap);
- Assert.NotEmpty (list);
- Assert.True (list.Count == linesCount);
- if (stringEmpty)
- {
- Assert.Equal (string.Empty, list [0]);
- }
- else
- {
- Assert.NotEqual (string.Empty, list [0]);
- }
- if (text.Contains ("\r\n") && maxWidth > 0)
- {
- Assert.Equal (
- StringExtensions.ToString (text.ToRunes () [..expectedClippedWidth])
- .Replace ("\r\n", " "),
- list [0]
- );
- }
- else if (text.Contains ('\n') && maxWidth > 0)
- {
- Assert.Equal (
- StringExtensions.ToString (text.ToRunes () [..expectedClippedWidth])
- .Replace ("\n", " "),
- list [0]
- );
- }
- else
- {
- Assert.Equal (StringExtensions.ToString (text.ToRunes () [..expectedClippedWidth]), list [0]);
- }
- }
- [Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true, new [] { "" })]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 1,
- -28,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A", "L" }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 5,
- -24,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sen", "Line " }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 28,
- -1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- //// no clip
- [InlineData (
- "A sentence has words.\nLine 2.",
- 29,
- 0,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 30,
- 1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true, new [] { "" })]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 1,
- -29,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A", "L" }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 5,
- -25,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sen", "Line " }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 29,
- -1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 30,
- 0,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 31,
- 1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- public void Reformat_NoWordrap_NewLines_MultiLine_True (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- int linesCount,
- bool stringEmpty,
- IEnumerable<string> resultLines
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List<string> list = TextFormatter.Format (
- text,
- maxWidth,
- alignment,
- wrap,
- false,
- 0,
- TextDirection.LeftRight_TopBottom,
- true
- );
- Assert.NotEmpty (list);
- Assert.True (list.Count == linesCount);
- if (stringEmpty)
- {
- Assert.Equal (string.Empty, list [0]);
- }
- else
- {
- Assert.NotEqual (string.Empty, list [0]);
- }
- Assert.Equal (list, resultLines);
- }
- [Theory]
- [InlineData ("A sentence has words.\nLine 2.", 0, -29, Alignment.Start, false, 1, true, new [] { "" })]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 1,
- -28,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A", "L" }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 5,
- -24,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sen", "Line " }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 28,
- -1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- //// no clip
- [InlineData (
- "A sentence has words.\nLine 2.",
- 29,
- 0,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\nLine 2.",
- 30,
- 1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData ("A sentence has words.\r\nLine 2.", 0, -30, Alignment.Start, false, 1, true, new [] { "" })]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 1,
- -29,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A", "L" }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 5,
- -25,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sen", "Line " }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 29,
- -1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 30,
- 0,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- [InlineData (
- "A sentence has words.\r\nLine 2.",
- 31,
- 1,
- Alignment.Start,
- false,
- 2,
- false,
- new [] { "A sentence has words.", "Line 2." }
- )]
- public void Reformat_NoWordrap_NewLines_MultiLine_True_Vertical (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- int linesCount,
- bool stringEmpty,
- IEnumerable<string> resultLines
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List<string> list = TextFormatter.Format (
- text,
- maxWidth,
- alignment,
- wrap,
- false,
- 0,
- TextDirection.TopBottom_LeftRight,
- true
- );
- Assert.NotEmpty (list);
- Assert.True (list.Count == linesCount);
- if (stringEmpty)
- {
- Assert.Equal (string.Empty, list [0]);
- }
- else
- {
- Assert.NotEqual (string.Empty, list [0]);
- }
- Assert.Equal (list, resultLines);
- }
- [Theory]
- [InlineData ("", 0, 0, Alignment.Start, false, 1, true)]
- [InlineData ("", 1, 1, Alignment.Start, false, 1, true)]
- [InlineData ("A sentence has words.", 0, -21, Alignment.Start, false, 1, true)]
- [InlineData ("A sentence has words.", 1, -20, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.", 5, -16, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.", 20, -1, Alignment.Start, false, 1, false)]
- // no clip
- [InlineData ("A sentence has words.", 21, 0, Alignment.Start, false, 1, false)]
- [InlineData ("A sentence has words.", 22, 1, Alignment.Start, false, 1, false)]
- public void Reformat_NoWordrap_SingleLine (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- int linesCount,
- bool stringEmpty
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap);
- Assert.NotEmpty (list);
- Assert.True (list.Count == linesCount);
- if (stringEmpty)
- {
- Assert.Equal (string.Empty, list [0]);
- }
- else
- {
- Assert.NotEqual (string.Empty, list [0]);
- }
- Assert.Equal (StringExtensions.ToString (text.ToRunes () [..expectedClippedWidth]), list [0]);
- }
- [Theory]
- // Unicode
- [InlineData (
- "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
- 8,
- -1,
- Alignment.Start,
- true,
- false,
- new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
- )]
- // no clip
- [InlineData (
- "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
- 9,
- 0,
- Alignment.Start,
- true,
- false,
- new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
- )]
- [InlineData (
- "\u2460\u2461\u2462\n\u2460\u2461\u2462\u2463\u2464",
- 10,
- 1,
- Alignment.Start,
- true,
- false,
- new [] { "\u2460\u2461\u2462", "\u2460\u2461\u2462\u2463\u2464" }
- )]
- public void Reformat_Unicode_Wrap_Spaces_NewLines (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- bool preserveTrailingSpaces,
- IEnumerable<string> resultLines
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
- Assert.Equal (list.Count, resultLines.Count ());
- Assert.Equal (resultLines, list);
- }
- [Theory]
- // Unicode
- // Even # of chars
- // 0123456789
- [InlineData ("\u2660пÑРвРÑ", 10, -1, Alignment.Start, true, false, new [] { "\u2660пÑРвÐ", "Ñ" })]
- // no clip
- [InlineData ("\u2660пÑРвРÑ", 11, 0, Alignment.Start, true, false, new [] { "\u2660пÑРвРÑ" })]
- [InlineData ("\u2660пÑРвРÑ", 12, 1, Alignment.Start, true, false, new [] { "\u2660пÑРвРÑ" })]
- // Unicode
- // Odd # of chars
- // 0123456789
- [InlineData ("\u2660 ÑРвРÑ", 9, -1, Alignment.Start, true, false, new [] { "\u2660 ÑРвÐ", "Ñ" })]
- // no clip
- [InlineData ("\u2660 ÑРвРÑ", 10, 0, Alignment.Start, true, false, new [] { "\u2660 ÑРвРÑ" })]
- [InlineData ("\u2660 ÑРвРÑ", 11, 1, Alignment.Start, true, false, new [] { "\u2660 ÑРвРÑ" })]
- public void Reformat_Unicode_Wrap_Spaces_No_NewLines (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- bool preserveTrailingSpaces,
- IEnumerable<string> resultLines
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
- Assert.Equal (list.Count, resultLines.Count ());
- Assert.Equal (resultLines, list);
- }
- [Theory]
- // Even # of spaces
- // 0123456789
- [InlineData ("012 456 89", 0, -10, Alignment.Start, true, true, true, new [] { "" })]
- [InlineData (
- "012 456 89",
- 1,
- -9,
- Alignment.Start,
- true,
- true,
- false,
- new [] { "0", "1", "2", " ", "4", "5", "6", " ", "8", "9" },
- "01245689"
- )]
- [InlineData ("012 456 89", 5, -5, Alignment.Start, true, true, false, new [] { "012 ", "456 ", "89" })]
- [InlineData ("012 456 89", 9, -1, Alignment.Start, true, true, false, new [] { "012 456 ", "89" })]
- // no clip
- [InlineData ("012 456 89", 10, 0, Alignment.Start, true, true, false, new [] { "012 456 89" })]
- [InlineData ("012 456 89", 11, 1, Alignment.Start, true, true, false, new [] { "012 456 89" })]
- // Odd # of spaces
- // 01234567890123
- [InlineData ("012 456 89 end", 13, -1, Alignment.Start, true, true, false, new [] { "012 456 89 ", "end" })]
- // no clip
- [InlineData ("012 456 89 end", 14, 0, Alignment.Start, true, true, false, new [] { "012 456 89 end" })]
- [InlineData ("012 456 89 end", 15, 1, Alignment.Start, true, true, false, new [] { "012 456 89 end" })]
- public void Reformat_Wrap_Spaces_No_NewLines (
- string text,
- int maxWidth,
- int widthOffset,
- Alignment alignment,
- bool wrap,
- bool preserveTrailingSpaces,
- bool stringEmpty,
- IEnumerable<string> resultLines,
- string noSpaceText = ""
- )
- {
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- List<string> list = TextFormatter.Format (text, maxWidth, alignment, wrap, preserveTrailingSpaces);
- Assert.NotEmpty (list);
- Assert.True (list.Count == resultLines.Count ());
- if (stringEmpty)
- {
- Assert.Equal (string.Empty, list [0]);
- }
- else
- {
- Assert.NotEqual (string.Empty, list [0]);
- }
- Assert.Equal (resultLines, list);
- if (maxWidth > 0)
- {
- // remove whitespace chars
- if (maxWidth < 5)
- {
- expectedClippedWidth = text.GetRuneCount () - text.Sum (r => r == ' ' ? 1 : 0);
- }
- else
- {
- expectedClippedWidth = Math.Min (
- text.GetRuneCount (),
- maxWidth - text.Sum (r => r == ' ' ? 1 : 0)
- );
- }
- list = TextFormatter.Format (text, maxWidth, Alignment.Start, wrap);
- if (maxWidth == 1)
- {
- Assert.Equal (expectedClippedWidth, list.Count);
- Assert.Equal (noSpaceText, string.Concat (list.ToArray ()));
- }
- if (maxWidth > 1 && maxWidth < 10)
- {
- Assert.Equal (
- StringExtensions.ToString (text.ToRunes () [..expectedClippedWidth]),
- list [0]
- );
- }
- }
- }
- [Theory]
- [InlineData (null)]
- [InlineData ("")]
- [InlineData ("a")]
- public void RemoveHotKeySpecifier_InValid_ReturnsOriginal (string text)
- {
- var hotKeySpecifier = (Rune)'_';
- if (text == null)
- {
- Assert.Null (TextFormatter.RemoveHotKeySpecifier (text, 0, hotKeySpecifier));
- Assert.Null (TextFormatter.RemoveHotKeySpecifier (text, -1, hotKeySpecifier));
- Assert.Null (TextFormatter.RemoveHotKeySpecifier (text, 100, hotKeySpecifier));
- }
- else
- {
- Assert.Equal (text, TextFormatter.RemoveHotKeySpecifier (text, 0, hotKeySpecifier));
- Assert.Equal (text, TextFormatter.RemoveHotKeySpecifier (text, -1, hotKeySpecifier));
- Assert.Equal (text, TextFormatter.RemoveHotKeySpecifier (text, 100, hotKeySpecifier));
- }
- }
- [Theory]
- [InlineData ("all lower case", 0)]
- [InlineData ("K Before", 0)]
- [InlineData ("aK Second", 1)]
- [InlineData ("Last K", 5)]
- [InlineData ("fter K", 7)]
- [InlineData ("Multiple K and R", 9)]
- [InlineData ("Non-english: Кдать", 13)]
- public void RemoveHotKeySpecifier_Valid_Legacy_ReturnsOriginal (string text, int hotPos)
- {
- var hotKeySpecifier = (Rune)'_';
- Assert.Equal (text, TextFormatter.RemoveHotKeySpecifier (text, hotPos, hotKeySpecifier));
- }
- [Theory]
- [InlineData ("_K Before", 0, "K Before")]
- [InlineData ("a_K Second", 1, "aK Second")]
- [InlineData ("Last _K", 5, "Last K")]
- [InlineData ("After K_", 7, "After K")]
- [InlineData ("Multiple _K and _R", 9, "Multiple K and _R")]
- [InlineData ("Non-english: _Кдать", 13, "Non-english: Кдать")]
- public void RemoveHotKeySpecifier_Valid_ReturnsStripped (string text, int hotPos, string expectedText)
- {
- var hotKeySpecifier = (Rune)'_';
- Assert.Equal (expectedText, TextFormatter.RemoveHotKeySpecifier (text, hotPos, hotKeySpecifier));
- }
- [Theory]
- [InlineData ("test", 0, 't', "test")]
- [InlineData ("test", 1, 'e', "test")]
- [InlineData ("Ok", 0, 'O', "Ok")]
- [InlineData ("[◦ Ok ◦]", 3, 'O', "[◦ Ok ◦]")]
- [InlineData ("^k", 0, '^', "^k")]
- public void ReplaceHotKeyWithTag (string text, int hotPos, uint tag, string expected)
- {
- var tf = new TextFormatter ();
- List<Rune> runes = text.ToRuneList ();
- Rune rune;
- if (Rune.TryGetRuneAt (text, hotPos, out rune))
- {
- Assert.Equal (rune, (Rune)tag);
- }
- string result = TextFormatter.ReplaceHotKeyWithTag (text, hotPos);
- Assert.Equal (result, expected);
- Assert.Equal ((Rune)tag, result.ToRunes () [hotPos]);
- Assert.Equal (text.GetRuneCount (), runes.Count);
- Assert.Equal (text, StringExtensions.ToString (runes));
- }
- public static IEnumerable<object []> SplitEnvironmentNewLine =>
- new List<object []>
- {
- new object []
- {
- $"First Line 界{Environment.NewLine}Second Line 界{Environment.NewLine}Third Line 界",
- new [] { "First Line 界", "Second Line 界", "Third Line 界" }
- },
- new object []
- {
- $"First Line 界{Environment.NewLine}Second Line 界{Environment.NewLine}Third Line 界{Environment.NewLine}",
- new [] { "First Line 界", "Second Line 界", "Third Line 界", "" }
- }
- };
- [Theory]
- [MemberData (nameof (SplitEnvironmentNewLine))]
- public void SplitNewLine_Ending__With_Or_Without_NewLine_Probably_CRLF (
- string text,
- IEnumerable<string> expected
- )
- {
- List<string> splited = TextFormatter.SplitNewLine (text);
- Assert.Equal (expected, splited);
- }
- [Theory]
- [InlineData (
- "First Line 界\nSecond Line 界\nThird Line 界\n",
- new [] { "First Line 界", "Second Line 界", "Third Line 界", "" }
- )]
- public void SplitNewLine_Ending_With_NewLine_Only_LF (string text, IEnumerable<string> expected)
- {
- List<string> splited = TextFormatter.SplitNewLine (text);
- Assert.Equal (expected, splited);
- }
- [Theory]
- [InlineData (
- "First Line 界\nSecond Line 界\nThird Line 界",
- new [] { "First Line 界", "Second Line 界", "Third Line 界" }
- )]
- public void SplitNewLine_Ending_Without_NewLine_Only_LF (string text, IEnumerable<string> expected)
- {
- List<string> splited = TextFormatter.SplitNewLine (text);
- Assert.Equal (expected, splited);
- }
- [Theory]
- [InlineData ("New Test 你", 10, 10, 20320, 20320, 9, "你")]
- [InlineData ("New Test \U0001d539", 10, 11, 120121, 55349, 9, "𝔹")]
- public void String_Array_Is_Not_Always_Equal_ToRunes_Array (
- string text,
- int runesLength,
- int stringLength,
- int runeValue,
- int stringValue,
- int index,
- string expected
- )
- {
- Rune [] usToRunes = text.ToRunes ();
- Assert.Equal (runesLength, usToRunes.Length);
- Assert.Equal (stringLength, text.Length);
- Assert.Equal (runeValue, usToRunes [index].Value);
- Assert.Equal (stringValue, text [index]);
- Assert.Equal (expected, usToRunes [index].ToString ());
- if (char.IsHighSurrogate (text [index]))
- {
- // Rune array length isn't equal to string array
- Assert.Equal (expected, new (new [] { text [index], text [index + 1] }));
- }
- else
- {
- // Rune array length is equal to string array
- Assert.Equal (expected, text [index].ToString ());
- }
- }
- [Theory]
- [InlineData (17, 1, TextDirection.LeftRight_TopBottom, 4, "This is a Tab")]
- [InlineData (1, 17, TextDirection.TopBottom_LeftRight, 4, "T\nh\ni\ns\n \ni\ns\n \na\n \n \n \n \n \nT\na\nb")]
- [InlineData (13, 1, TextDirection.LeftRight_TopBottom, 0, "This is a Tab")]
- [InlineData (1, 13, TextDirection.TopBottom_LeftRight, 0, "T\nh\ni\ns\n \ni\ns\n \na\n \nT\na\nb")]
- public void TabWith_PreserveTrailingSpaces_False (
- int width,
- int height,
- TextDirection textDirection,
- int tabWidth,
- string expected
- )
- {
- var driver = new FakeDriver ();
- driver.Init ();
- var text = "This is a \tTab";
- var tf = new TextFormatter ();
- tf.Direction = textDirection;
- tf.TabWidth = tabWidth;
- tf.Text = text;
- tf.ConstrainToWidth = 20;
- tf.ConstrainToHeight = 20;
- Assert.True (tf.WordWrap);
- Assert.False (tf.PreserveTrailingSpaces);
- tf.Draw (
- new (0, 0, width, height),
- new (ColorName16.White, ColorName16.Black),
- new (ColorName16.Blue, ColorName16.Black),
- default (Rectangle),
- driver
- );
- TestHelpers.AssertDriverContentsWithFrameAre (expected, _output, driver);
- driver.End ();
- }
- [Theory]
- [InlineData (17, 1, TextDirection.LeftRight_TopBottom, 4, "This is a Tab")]
- [InlineData (1, 17, TextDirection.TopBottom_LeftRight, 4, "T\nh\ni\ns\n \ni\ns\n \na\n \n \n \n \n \nT\na\nb")]
- [InlineData (13, 1, TextDirection.LeftRight_TopBottom, 0, "This is a Tab")]
- [InlineData (1, 13, TextDirection.TopBottom_LeftRight, 0, "T\nh\ni\ns\n \ni\ns\n \na\n \nT\na\nb")]
- public void TabWith_PreserveTrailingSpaces_True (
- int width,
- int height,
- TextDirection textDirection,
- int tabWidth,
- string expected
- )
- {
- var driver = new FakeDriver ();
- driver.Init ();
- var text = "This is a \tTab";
- var tf = new TextFormatter ();
- tf.Direction = textDirection;
- tf.TabWidth = tabWidth;
- tf.PreserveTrailingSpaces = true;
- tf.Text = text;
- tf.ConstrainToWidth = 20;
- tf.ConstrainToHeight = 20;
- Assert.True (tf.WordWrap);
- tf.Draw (
- new (0, 0, width, height),
- new (ColorName16.White, ColorName16.Black),
- new (ColorName16.Blue, ColorName16.Black),
- default (Rectangle),
- driver
- );
- TestHelpers.AssertDriverContentsWithFrameAre (expected, _output, driver);
- driver.End ();
- }
- [Theory]
- [InlineData (17, 1, TextDirection.LeftRight_TopBottom, 4, "This is a Tab")]
- [InlineData (1, 17, TextDirection.TopBottom_LeftRight, 4, "T\nh\ni\ns\n \ni\ns\n \na\n \n \n \n \n \nT\na\nb")]
- [InlineData (13, 1, TextDirection.LeftRight_TopBottom, 0, "This is a Tab")]
- [InlineData (1, 13, TextDirection.TopBottom_LeftRight, 0, "T\nh\ni\ns\n \ni\ns\n \na\n \nT\na\nb")]
- public void TabWith_WordWrap_True (
- int width,
- int height,
- TextDirection textDirection,
- int tabWidth,
- string expected
- )
- {
- var driver = new FakeDriver ();
- driver.Init ();
- var text = "This is a \tTab";
- var tf = new TextFormatter ();
- tf.Direction = textDirection;
- tf.TabWidth = tabWidth;
- tf.WordWrap = true;
- tf.Text = text;
- tf.ConstrainToWidth = 20;
- tf.ConstrainToHeight = 20;
- Assert.False (tf.PreserveTrailingSpaces);
- tf.Draw (
- new (0, 0, width, height),
- new (ColorName16.White, ColorName16.Black),
- new (ColorName16.Blue, ColorName16.Black),
- default (Rectangle),
- driver
- );
- TestHelpers.AssertDriverContentsWithFrameAre (expected, _output, driver);
- driver.End ();
- }
- [Theory]
- [InlineData ("123456789", 3, "123")]
- [InlineData ("Hello World", 8, "Hello Wo")]
- public void TestClipOrPad_LongWord (string text, int fillPad, string expectedText)
- {
- // word is long but we want it to fill # space only
- Assert.Equal (expectedText, TextFormatter.ClipOrPad (text, fillPad));
- }
- [Theory]
- [InlineData ("fff", 6, "fff ")]
- [InlineData ("Hello World", 16, "Hello World ")]
- public void TestClipOrPad_ShortWord (string text, int fillPad, string expectedText)
- {
- // word is short but we want it to fill # so it should be padded
- Assert.Equal (expectedText, TextFormatter.ClipOrPad (text, fillPad));
- }
- [Theory]
- [InlineData ("你", TextDirection.LeftRight_TopBottom, 2, 1)]
- [InlineData ("你", TextDirection.TopBottom_LeftRight, 2, 1)]
- [InlineData ("你你", TextDirection.LeftRight_TopBottom, 4, 1)]
- [InlineData ("你你", TextDirection.TopBottom_LeftRight, 2, 2)]
- public void Text_Set_SizeIsCorrect (string text, TextDirection textDirection, int expectedWidth, int expectedHeight)
- {
- var tf = new TextFormatter { Direction = textDirection, Text = text };
- tf.ConstrainToWidth = 10;
- tf.ConstrainToHeight = 10;
- Assert.Equal (new (expectedWidth, expectedHeight), tf.FormatAndGetSize ());
- }
- [Fact]
- [SetupFakeDriver]
- public void UICatalog_AboutBox_Text ()
- {
- TextFormatter tf = new ()
- {
- Text = UICatalogApp.GetAboutBoxMessage (),
- Alignment = Alignment.Center,
- VerticalAlignment = Alignment.Start,
- WordWrap = false,
- MultiLine = true,
- HotKeySpecifier = (Rune)0xFFFF
- };
- Size tfSize = tf.FormatAndGetSize ();
- Assert.Equal (new (58, 13), tfSize);
- ((FakeDriver)Application.Driver).SetBufferSize (tfSize.Width, tfSize.Height);
- Application.Driver.FillRect (Application.Screen, (Rune)'*');
- tf.Draw (Application.Screen, Attribute.Default, Attribute.Default);
- var expectedText = """
- ******UI Catalog: A comprehensive sample library for******
- **********************************************************
- _______ _ _ _____ _
- |__ __| (_) | | / ____| (_)
- | | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _
- | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
- | | __/ | | | | | | | | | | | (_| | || |__| | |_| | |
- |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
- **********************************************************
- **********************v2 - Pre-Alpha**********************
- **********************************************************
- **********https://github.com/gui-cs/Terminal.Gui**********
- **********************************************************
- """;
- TestHelpers.AssertDriverContentsAre (expectedText.ReplaceLineEndings (), _output);
- }
- [Fact]
- public void WordWrap_BigWidth ()
- {
- List<string> wrappedLines;
- var text = "Constantinople";
- wrappedLines = TextFormatter.WordWrapText (text, 100);
- Assert.True (wrappedLines.Count == 1);
- Assert.Equal ("Constantinople", wrappedLines [0]);
- }
- [Fact]
- public void WordWrap_Invalid ()
- {
- var text = string.Empty;
- var width = 0;
- Assert.Empty (TextFormatter.WordWrapText (null, width));
- Assert.Empty (TextFormatter.WordWrapText (text, width));
- Assert.Throws<ArgumentOutOfRangeException> (() => TextFormatter.WordWrapText (text, -1));
- }
- [Theory]
- [InlineData ("A sentence has words.", 3, -18, new [] { "A", "sen", "ten", "ce", "has", "wor", "ds." })]
- [InlineData (
- "A sentence has words.",
- 2,
- -19,
- new [] { "A", "se", "nt", "en", "ce", "ha", "s", "wo", "rd", "s." }
- )]
- [InlineData (
- "A sentence has words.",
- 1,
- -20,
- new [] { "A", "s", "e", "n", "t", "e", "n", "c", "e", "h", "a", "s", "w", "o", "r", "d", "s", "." }
- )]
- public void WordWrap_Narrow_Default (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- // Calls WordWrapText (text, width) and thus preserveTrailingSpaces defaults to false
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("A sentence has words.", 21, 0, new [] { "A sentence has words." })]
- [InlineData ("A sentence has words.", 20, -1, new [] { "A sentence has", "words." })]
- [InlineData ("A sentence has words.", 15, -6, new [] { "A sentence has", "words." })]
- [InlineData ("A sentence has words.", 14, -7, new [] { "A sentence has", "words." })]
- [InlineData ("A sentence has words.", 13, -8, new [] { "A sentence", "has words." })]
- // Unicode
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 42,
- 0,
- new [] { "A Unicode sentence (пÑивеÑ) has words." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 41,
- -1,
- new [] { "A Unicode sentence (пÑивеÑ) has", "words." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 36,
- -6,
- new [] { "A Unicode sentence (пÑивеÑ) has", "words." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 35,
- -7,
- new [] { "A Unicode sentence (пÑивеÑ) has", "words." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 34,
- -8,
- new [] { "A Unicode sentence (пÑивеÑ)", "has words." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.",
- 25,
- -17,
- new [] { "A Unicode sentence", "(пÑивеÑ) has words." }
- )]
- public void WordWrap_NoNewLines_Default (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- // Calls WordWrapText (text, width) and thus preserveTrailingSpaces defaults to false
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("これが最初の行です。 こんにちは世界。 これが2行目です。", 29, 0, new [] { "これが最初の行です。", "こんにちは世界。", "これが2行目です。" })]
- public void WordWrap_PreserveTrailingSpaces_False_Unicode_Wide_Runes (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("文に は言葉 があり ます。", 14, 0, new [] { "文に は言葉", "があり ます。" })]
- [InlineData ("文に は言葉 があり ます。", 3, -11, new [] { "文", "に", "は", "言", "葉", "が", "あ", "り", "ま", "す", "。" })]
- [InlineData ("文に は言葉 があり ます。", 2, -12, new [] { "文", "に", "は", "言", "葉", "が", "あ", "り", "ま", "す", "。" })]
- [InlineData (
- "文に は言葉 があり ます。",
- 1,
- -13,
- new [] { " ", " ", " " }
- )] // Just Spaces; should result in a single space for each line
- public void WordWrap_PreserveTrailingSpaces_False_Wide_Runes (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData (null, 1, new string [] { })] // null input
- [InlineData ("", 1, new string [] { })] // Empty input
- [InlineData ("1 34", 1, new [] { "1", "3", "4" })] // Single Spaces
- [InlineData ("1", 1, new [] { "1" })] // Short input
- [InlineData ("12", 1, new [] { "1", "2" })]
- [InlineData ("123", 1, new [] { "1", "2", "3" })]
- [InlineData ("123456", 1, new [] { "1", "2", "3", "4", "5", "6" })] // No spaces
- [InlineData (" ", 1, new [] { " " })] // Just Spaces; should result in a single space
- [InlineData (" ", 1, new [] { " " })]
- [InlineData (" ", 1, new [] { " ", " " })]
- [InlineData (" ", 1, new [] { " ", " " })]
- [InlineData ("12 456", 1, new [] { "1", "2", "4", "5", "6" })] // Single Spaces
- [InlineData (" 2 456", 1, new [] { " ", "2", "4", "5", "6" })] // Leading spaces should be preserved.
- [InlineData (" 2 456 8", 1, new [] { " ", "2", "4", "5", "6", "8" })]
- [InlineData (
- "A sentence has words. ",
- 1,
- new [] { "A", "s", "e", "n", "t", "e", "n", "c", "e", "h", "a", "s", "w", "o", "r", "d", "s", "." }
- )] // Complex example
- [InlineData ("12 567", 1, new [] { "1", "2", " ", "5", "6", "7" })] // Double Spaces
- [InlineData (" 3 567", 1, new [] { " ", "3", "5", "6", "7" })] // Double Leading spaces should be preserved.
- [InlineData (" 3 678 1", 1, new [] { " ", "3", " ", "6", "7", "8", " ", "1" })]
- [InlineData ("1 456", 1, new [] { "1", " ", "4", "5", "6" })]
- [InlineData (
- "A sentence has words. ",
- 1,
- new []
- {
- "A", " ", "s", "e", "n", "t", "e", "n", "c", "e", " ", "h", "a", "s", "w", "o", "r", "d", "s", ".", " "
- }
- )] // Double space Complex example
- public void WordWrap_PreserveTrailingSpaces_False_With_Simple_Runes_Width_1 (
- string text,
- int width,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines = TextFormatter.WordWrapText (text, width);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.Equal (resultLines, wrappedLines);
- var breakLines = "";
- foreach (string line in wrappedLines)
- {
- breakLines += $"{line}{Environment.NewLine}";
- }
- var expected = string.Empty;
- foreach (string line in resultLines)
- {
- expected += $"{line}{Environment.NewLine}";
- }
- Assert.Equal (expected, breakLines);
- }
- [Theory]
- [InlineData (null, 3, new string [] { })] // null input
- [InlineData ("", 3, new string [] { })] // Empty input
- [InlineData ("1", 3, new [] { "1" })] // Short input
- [InlineData ("12", 3, new [] { "12" })]
- [InlineData ("123", 3, new [] { "123" })]
- [InlineData ("123456", 3, new [] { "123", "456" })] // No spaces
- [InlineData ("1234567", 3, new [] { "123", "456", "7" })] // No spaces
- [InlineData (" ", 3, new [] { " " })] // Just Spaces; should result in a single space
- [InlineData (" ", 3, new [] { " " })]
- [InlineData (" ", 3, new [] { " " })]
- [InlineData (" ", 3, new [] { " " })]
- [InlineData ("12 456", 3, new [] { "12", "456" })] // Single Spaces
- [InlineData (" 2 456", 3, new [] { " 2", "456" })] // Leading spaces should be preserved.
- [InlineData (" 2 456 8", 3, new [] { " 2", "456", "8" })]
- [InlineData (
- "A sentence has words. ",
- 3,
- new [] { "A", "sen", "ten", "ce", "has", "wor", "ds." }
- )] // Complex example
- [InlineData ("12 567", 3, new [] { "12 ", "567" })] // Double Spaces
- [InlineData (" 3 567", 3, new [] { " 3", "567" })] // Double Leading spaces should be preserved.
- [InlineData (" 3 678 1", 3, new [] { " 3", " 67", "8 ", "1" })]
- [InlineData ("1 456", 3, new [] { "1 ", "456" })]
- [InlineData (
- "A sentence has words. ",
- 3,
- new [] { "A ", "sen", "ten", "ce ", " ", "has", "wor", "ds.", " " }
- )] // Double space Complex example
- public void WordWrap_PreserveTrailingSpaces_False_With_Simple_Runes_Width_3 (
- string text,
- int width,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines = TextFormatter.WordWrapText (text, width);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.Equal (resultLines, wrappedLines);
- var breakLines = "";
- foreach (string line in wrappedLines)
- {
- breakLines += $"{line}{Environment.NewLine}";
- }
- var expected = string.Empty;
- foreach (string line in resultLines)
- {
- expected += $"{line}{Environment.NewLine}";
- }
- Assert.Equal (expected, breakLines);
- }
- [Theory]
- [InlineData (null, 50, new string [] { })] // null input
- [InlineData ("", 50, new string [] { })] // Empty input
- [InlineData ("1", 50, new [] { "1" })] // Short input
- [InlineData ("12", 50, new [] { "12" })]
- [InlineData ("123", 50, new [] { "123" })]
- [InlineData ("123456", 50, new [] { "123456" })] // No spaces
- [InlineData ("1234567", 50, new [] { "1234567" })] // No spaces
- [InlineData (" ", 50, new [] { " " })] // Just Spaces; should result in a single space
- [InlineData (" ", 50, new [] { " " })]
- [InlineData (" ", 50, new [] { " " })]
- [InlineData ("12 456", 50, new [] { "12 456" })] // Single Spaces
- [InlineData (" 2 456", 50, new [] { " 2 456" })] // Leading spaces should be preserved.
- [InlineData (" 2 456 8", 50, new [] { " 2 456 8" })]
- [InlineData ("A sentence has words. ", 50, new [] { "A sentence has words. " })] // Complex example
- [InlineData ("12 567", 50, new [] { "12 567" })] // Double Spaces
- [InlineData (" 3 567", 50, new [] { " 3 567" })] // Double Leading spaces should be preserved.
- [InlineData (" 3 678 1", 50, new [] { " 3 678 1" })]
- [InlineData ("1 456", 50, new [] { "1 456" })]
- [InlineData (
- "A sentence has words. ",
- 50,
- new [] { "A sentence has words. " }
- )] // Double space Complex example
- public void WordWrap_PreserveTrailingSpaces_False_With_Simple_Runes_Width_50 (
- string text,
- int width,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines = TextFormatter.WordWrapText (text, width);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.Equal (resultLines, wrappedLines);
- var breakLines = "";
- foreach (string line in wrappedLines)
- {
- breakLines += $"{line}{Environment.NewLine}";
- }
- var expected = string.Empty;
- foreach (string line in resultLines)
- {
- expected += $"{line}{Environment.NewLine}";
- }
- Assert.Equal (expected, breakLines);
- }
- [Theory]
- [InlineData ("A sentence has words.", 14, -7, new [] { "A sentence ", "has words." })]
- [InlineData ("A sentence has words.", 8, -13, new [] { "A ", "sentence", " has ", "words." })]
- [InlineData ("A sentence has words.", 6, -15, new [] { "A ", "senten", "ce ", "has ", "words." })]
- [InlineData ("A sentence has words.", 3, -18, new [] { "A ", "sen", "ten", "ce ", "has", " ", "wor", "ds." })]
- [InlineData (
- "A sentence has words.",
- 2,
- -19,
- new [] { "A ", "se", "nt", "en", "ce", " ", "ha", "s ", "wo", "rd", "s." }
- )]
- [InlineData (
- "A sentence has words.",
- 1,
- -20,
- new []
- {
- "A", " ", "s", "e", "n", "t", "e", "n", "c", "e", " ", "h", "a", "s", " ", "w", "o", "r", "d", "s", "."
- }
- )]
- public void WordWrap_PreserveTrailingSpaces_True (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth, true);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("文に は言葉 があり ます。", 14, 0, new [] { "文に は言葉 ", "があり ます。" })]
- [InlineData ("文に は言葉 があり ます。", 3, -11, new [] { "文", "に ", "は", "言", "葉 ", "が", "あ", "り ", "ま", "す", "。" })]
- [InlineData (
- "文に は言葉 があり ます。",
- 2,
- -12,
- new [] { "文", "に", " ", "は", "言", "葉", " ", "が", "あ", "り", " ", "ま", "す", "。" }
- )]
- [InlineData ("文に は言葉 があり ます。", 1, -13, new string [] { })]
- public void WordWrap_PreserveTrailingSpaces_True_Wide_Runes (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth, true);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("A sentence has words. ", 3, new [] { "A ", "sen", "ten", "ce ", "has", " ", "wor", "ds.", " " })]
- [InlineData (
- "A sentence has words. ",
- 3,
- new [] { "A ", " ", "sen", "ten", "ce ", " ", " ", " ", "has", " ", "wor", "ds.", " " }
- )]
- public void WordWrap_PreserveTrailingSpaces_True_With_Simple_Runes_Width_3 (
- string text,
- int width,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines = TextFormatter.WordWrapText (text, width, true);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.Equal (resultLines, wrappedLines);
- var breakLines = "";
- foreach (string line in wrappedLines)
- {
- breakLines += $"{line}{Environment.NewLine}";
- }
- var expected = string.Empty;
- foreach (string line in resultLines)
- {
- expected += $"{line}{Environment.NewLine}";
- }
- Assert.Equal (expected, breakLines);
- // Double space Complex example - this is how VS 2022 does it
- //text = "A sentence has words. ";
- //breakLines = "";
- //wrappedLines = TextFormatter.WordWrapText (text, width, preserveTrailingSpaces: true);
- //foreach (var line in wrappedLines) {
- // breakLines += $"{line}{Environment.NewLine}";
- //}
- //expected = "A " + Environment.NewLine +
- // " se" + Environment.NewLine +
- // " nt" + Environment.NewLine +
- // " en" + Environment.NewLine +
- // " ce" + Environment.NewLine +
- // " " + Environment.NewLine +
- // " " + Environment.NewLine +
- // " " + Environment.NewLine +
- // " ha" + Environment.NewLine +
- // " s " + Environment.NewLine +
- // " wo" + Environment.NewLine +
- // " rd" + Environment.NewLine +
- // " s." + Environment.NewLine;
- //Assert.Equal (expected, breakLines);
- }
- [Theory]
- [InlineData ("A sentence\t\t\t has words.", 14, -10, new [] { "A sentence\t", "\t\t has ", "words." })]
- [InlineData (
- "A sentence\t\t\t has words.",
- 8,
- -16,
- new [] { "A ", "sentence", "\t\t", "\t ", "has ", "words." }
- )]
- [InlineData (
- "A sentence\t\t\t has words.",
- 3,
- -21,
- new [] { "A ", "sen", "ten", "ce", "\t", "\t", "\t", " ", "has", " ", "wor", "ds." }
- )]
- [InlineData (
- "A sentence\t\t\t has words.",
- 2,
- -22,
- new [] { "A ", "se", "nt", "en", "ce", "\t", "\t", "\t", " ", "ha", "s ", "wo", "rd", "s." }
- )]
- [InlineData (
- "A sentence\t\t\t has words.",
- 1,
- -23,
- new []
- {
- "A",
- " ",
- "s",
- "e",
- "n",
- "t",
- "e",
- "n",
- "c",
- "e",
- "\t",
- "\t",
- "\t",
- " ",
- "h",
- "a",
- "s",
- " ",
- "w",
- "o",
- "r",
- "d",
- "s",
- "."
- }
- )]
- public void WordWrap_PreserveTrailingSpaces_True_With_Tab (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines,
- int tabWidth = 4
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth, true, tabWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("Constantinople", 14, 0, new [] { "Constantinople" })]
- [InlineData ("Constantinople", 12, -2, new [] { "Constantinop", "le" })]
- [InlineData ("Constantinople", 9, -5, new [] { "Constanti", "nople" })]
- [InlineData ("Constantinople", 7, -7, new [] { "Constan", "tinople" })]
- [InlineData ("Constantinople", 5, -9, new [] { "Const", "antin", "ople" })]
- [InlineData ("Constantinople", 4, -10, new [] { "Cons", "tant", "inop", "le" })]
- [InlineData (
- "Constantinople",
- 1,
- -13,
- new [] { "C", "o", "n", "s", "t", "a", "n", "t", "i", "n", "o", "p", "l", "e" }
- )]
- public void WordWrap_SingleWordLine (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("This\u00A0is\n\u00A0a\u00A0sentence.", 20, 0, new [] { "This\u00A0is\u00A0a\u00A0sentence." })]
- [InlineData ("This\u00A0is\n\u00A0a\u00A0sentence.", 19, -1, new [] { "This\u00A0is\u00A0a\u00A0sentence." })]
- [InlineData (
- "\u00A0\u00A0\u00A0\u00A0\u00A0test\u00A0sentence.",
- 19,
- 0,
- new [] { "\u00A0\u00A0\u00A0\u00A0\u00A0test\u00A0sentence." }
- )]
- public void WordWrap_Unicode_2LinesWithNonBreakingSpace (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData ("This\u00A0is\u00A0a\u00A0sentence.", 19, 0, new [] { "This\u00A0is\u00A0a\u00A0sentence." })]
- [InlineData ("This\u00A0is\u00A0a\u00A0sentence.", 18, -1, new [] { "This\u00A0is\u00A0a\u00A0sentence", "." })]
- [InlineData ("This\u00A0is\u00A0a\u00A0sentence.", 17, -2, new [] { "This\u00A0is\u00A0a\u00A0sentenc", "e." })]
- [InlineData ("This\u00A0is\u00A0a\u00A0sentence.", 14, -5, new [] { "This\u00A0is\u00A0a\u00A0sent", "ence." })]
- [InlineData ("This\u00A0is\u00A0a\u00A0sentence.", 10, -9, new [] { "This\u00A0is\u00A0a\u00A0", "sentence." })]
- [InlineData (
- "This\u00A0is\u00A0a\u00A0sentence.",
- 7,
- -12,
- new [] { "This\u00A0is", "\u00A0a\u00A0sent", "ence." }
- )]
- [InlineData (
- "This\u00A0is\u00A0a\u00A0sentence.",
- 5,
- -14,
- new [] { "This\u00A0", "is\u00A0a\u00A0", "sente", "nce." }
- )]
- [InlineData (
- "This\u00A0is\u00A0a\u00A0sentence.",
- 1,
- -18,
- new []
- {
- "T", "h", "i", "s", "\u00A0", "i", "s", "\u00A0", "a", "\u00A0", "s", "e", "n", "t", "e", "n", "c", "e", "."
- }
- )]
- public void WordWrap_Unicode_LineWithNonBreakingSpace (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- [Theory]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 51,
- 0,
- new [] { "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 50,
- -1,
- new [] { "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 46,
- -5,
- new [] { "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮ", "ฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 26,
- -25,
- new [] { "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบ", "ปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 17,
- -34,
- new [] { "กขฃคฅฆงจฉชซฌญฎฏฐฑ", "ฒณดตถทธนบปผฝพฟภมย", "รฤลฦวศษสหฬอฮฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 13,
- -38,
- new [] { "กขฃคฅฆงจฉชซฌญ", "ฎฏฐฑฒณดตถทธนบ", "ปผฝพฟภมยรฤลฦว", "ศษสหฬอฮฯะัาำ" }
- )]
- [InlineData (
- "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ",
- 1,
- -50,
- new []
- {
- "ก",
- "ข",
- "ฃ",
- "ค",
- "ฅ",
- "ฆ",
- "ง",
- "จ",
- "ฉ",
- "ช",
- "ซ",
- "ฌ",
- "ญ",
- "ฎ",
- "ฏ",
- "ฐ",
- "ฑ",
- "ฒ",
- "ณ",
- "ด",
- "ต",
- "ถ",
- "ท",
- "ธ",
- "น",
- "บ",
- "ป",
- "ผ",
- "ฝ",
- "พ",
- "ฟ",
- "ภ",
- "ม",
- "ย",
- "ร",
- "ฤ",
- "ล",
- "ฦ",
- "ว",
- "ศ",
- "ษ",
- "ส",
- "ห",
- "ฬ",
- "อ",
- "ฮ",
- "ฯ",
- "ะั",
- "า",
- "ำ"
- }
- )]
- public void WordWrap_Unicode_SingleWordLine (
- string text,
- int maxWidth,
- int widthOffset,
- IEnumerable<string> resultLines
- )
- {
- List<string> wrappedLines;
- IEnumerable<Rune> zeroWidth = text.EnumerateRunes ().Where (r => r.GetColumns () == 0);
- Assert.Single (zeroWidth);
- Assert.Equal ('ั', zeroWidth.ElementAt (0).Value);
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth
- >= (wrappedLines.Count > 0
- ? wrappedLines.Max (
- l => l.GetRuneCount ()
- + zeroWidth.Count ()
- - 1
- + widthOffset
- )
- : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- /// <summary>WordWrap strips CRLF</summary>
- [Theory]
- [InlineData (
- "A sentence has words.\nA paragraph has lines.",
- 44,
- 0,
- new [] { "A sentence has words.A paragraph has lines." }
- )]
- [InlineData (
- "A sentence has words.\nA paragraph has lines.",
- 43,
- -1,
- new [] { "A sentence has words.A paragraph has lines." }
- )]
- [InlineData (
- "A sentence has words.\nA paragraph has lines.",
- 38,
- -6,
- new [] { "A sentence has words.A paragraph has", "lines." }
- )]
- [InlineData (
- "A sentence has words.\nA paragraph has lines.",
- 34,
- -10,
- new [] { "A sentence has words.A paragraph", "has lines." }
- )]
- [InlineData (
- "A sentence has words.\nA paragraph has lines.",
- 27,
- -17,
- new [] { "A sentence has words.A", "paragraph has lines." }
- )]
- // Unicode
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.\nA Unicode Пункт has Линии.",
- 69,
- 0,
- new [] { "A Unicode sentence (пÑивеÑ) has words.A Unicode Пункт has Линии." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.\nA Unicode Пункт has Линии.",
- 68,
- -1,
- new [] { "A Unicode sentence (пÑивеÑ) has words.A Unicode Пункт has Линии." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.\nA Unicode Пункт has Линии.",
- 63,
- -6,
- new [] { "A Unicode sentence (пÑивеÑ) has words.A Unicode Пункт has", "Линии." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.\nA Unicode Пункт has Линии.",
- 59,
- -10,
- new [] { "A Unicode sentence (пÑивеÑ) has words.A Unicode Пункт", "has Линии." }
- )]
- [InlineData (
- "A Unicode sentence (пÑивеÑ) has words.\nA Unicode Пункт has Линии.",
- 52,
- -17,
- new [] { "A Unicode sentence (пÑивеÑ) has words.A Unicode", "Пункт has Линии." }
- )]
- public void WordWrap_WithNewLines (string text, int maxWidth, int widthOffset, IEnumerable<string> resultLines)
- {
- List<string> wrappedLines;
- Assert.Equal (maxWidth, text.GetRuneCount () + widthOffset);
- int expectedClippedWidth = Math.Min (text.GetRuneCount (), maxWidth);
- wrappedLines = TextFormatter.WordWrapText (text, maxWidth);
- Assert.Equal (wrappedLines.Count, resultLines.Count ());
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetRuneCount ()) : 0)
- );
- Assert.True (
- expectedClippedWidth >= (wrappedLines.Count > 0 ? wrappedLines.Max (l => l.GetColumns ()) : 0)
- );
- Assert.Equal (resultLines, wrappedLines);
- }
- #region FormatAndGetSizeTests
- // TODO: Add multi-line examples
- // TODO: Add other TextDirection examples
- [Theory]
- [SetupFakeDriver]
- [InlineData ("界1234", 10, 10, TextDirection.LeftRight_TopBottom, 6, 1, @"界1234")]
- [InlineData ("01234", 10, 10, TextDirection.LeftRight_TopBottom, 5, 1, @"01234")]
- [InlineData (
- "界1234",
- 10,
- 10,
- TextDirection.TopBottom_LeftRight,
- 2,
- 5,
- """
- 界
- 1
- 2
- 3
- 4
- """)]
- [InlineData (
- "01234",
- 10,
- 10,
- TextDirection.TopBottom_LeftRight,
- 1,
- 5,
- """
- 0
- 1
- 2
- 3
- 4
- """)]
- [InlineData (
- "界1234",
- 3,
- 3,
- TextDirection.LeftRight_TopBottom,
- 3,
- 2,
- """
- 界1
- 234
- """)]
- [InlineData (
- "01234",
- 3,
- 3,
- TextDirection.LeftRight_TopBottom,
- 3,
- 2,
- """
- 012
- 34
- """)]
- [InlineData (
- "界1234",
- 3,
- 3,
- TextDirection.TopBottom_LeftRight,
- 3,
- 3,
- """
- 界3
- 1 4
- 2
- """)]
- [InlineData (
- "01234",
- 3,
- 3,
- TextDirection.TopBottom_LeftRight,
- 2,
- 3,
- """
- 03
- 14
- 2
- """)]
- [InlineData ("01234", 2, 1, TextDirection.LeftRight_TopBottom, 2, 1, @"01")]
- public void FormatAndGetSize_Returns_Correct_Size (
- string text,
- int width,
- int height,
- TextDirection direction,
- int expectedWidth,
- int expectedHeight,
- string expectedDraw
- )
- {
- TextFormatter tf = new ()
- {
- Direction = direction,
- ConstrainToWidth = width,
- ConstrainToHeight = height,
- Text = text
- };
- Assert.True (tf.WordWrap);
- Size size = tf.FormatAndGetSize ();
- Assert.Equal (new (expectedWidth, expectedHeight), size);
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedDraw, _output);
- }
- [Theory]
- [SetupFakeDriver]
- [InlineData ("界1234", 10, 10, TextDirection.LeftRight_TopBottom, 6, 1, @"界1234")]
- [InlineData ("01234", 10, 10, TextDirection.LeftRight_TopBottom, 5, 1, @"01234")]
- [InlineData (
- "界1234",
- 10,
- 10,
- TextDirection.TopBottom_LeftRight,
- 2,
- 5,
- """
- 界
- 1
- 2
- 3
- 4
- """)]
- [InlineData (
- "01234",
- 10,
- 10,
- TextDirection.TopBottom_LeftRight,
- 1,
- 5,
- """
- 0
- 1
- 2
- 3
- 4
- """)]
- [InlineData ("界1234", 3, 3, TextDirection.LeftRight_TopBottom, 3, 1, @"界1")]
- [InlineData ("01234", 3, 3, TextDirection.LeftRight_TopBottom, 3, 1, @"012")]
- [InlineData (
- "界1234",
- 3,
- 3,
- TextDirection.TopBottom_LeftRight,
- 2,
- 3,
- """
- 界
- 1
- 2
- """)]
- [InlineData (
- "01234",
- 3,
- 3,
- TextDirection.TopBottom_LeftRight,
- 1,
- 3,
- """
- 0
- 1
- 2
- """)]
- public void FormatAndGetSize_WordWrap_False_Returns_Correct_Size (
- string text,
- int width,
- int height,
- TextDirection direction,
- int expectedWidth,
- int expectedHeight,
- string expectedDraw
- )
- {
- TextFormatter tf = new ()
- {
- Direction = direction,
- ConstrainToSize = new (width, height),
- Text = text,
- WordWrap = false
- };
- Assert.False (tf.WordWrap);
- Size size = tf.FormatAndGetSize ();
- Assert.Equal (new (expectedWidth, expectedHeight), size);
- tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default);
- TestHelpers.AssertDriverContentsWithFrameAre (expectedDraw, _output);
- }
- #endregion
- }
|