/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 2 ĠSquare , ĠInc . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġokhttp 3 . internal . id n Ċ Ċ import Ġok io . Buffer Ċ import Ġok io . ByteString . Companion . decode Hex Ċ import Ġok io . FileSystem Ċ import Ġok io . Path . Companion . to Path Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ Ċ class ĠString prep Test Ġ{ ĊĠ Ġprivate Ġval Ġreader Ġ= ĠString prep Tables Reader ( FileSystem . RESOURCES ) ĊĠ Ġprivate Ġval Ġr fc 3 4 9 1 Ġ= Ġreader . read Name prep ("/ okhttp 3 / internal / id n ". to Path ()) ĊĠ Ġprivate Ġval Ġstring Prep Ġ= ĠString prep ( ĊĠĠĠ Ġun assigned Ġ= ĠRange List Code Point Set ( listOf ()), ĊĠĠĠ Ġmapping Ġ= Ġr fc 3 4 9 1 . mapping , ĊĠĠĠ Ġpro hibit Set Ġ= Ġr fc 3 4 9 1 . pro hibit Set , ĊĠĠĠ Ġrand al cat Set Ġ= Ġr fc 3 4 9 1 . rand al cat Set , ĊĠĠĠ Ġl cat Set Ġ= Ġr fc 3 4 9 1 . l cat Set , ĊĠ Ġ) ĊĊĠ Ġ@ Test Ġfun Ġmapped To Nothing () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep (" a \ u 0 0 AD z ")). isEqualTo (" az ") ĊĠĠĠ ĠassertThat ( string Prep (" a \ u 2 0 0 Dz ")). isEqualTo (" az ") ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġcase Fold ing () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep (" localhost ")). isEqualTo (" localhost ") ĊĠĠĠ ĠassertThat ( string Prep (" Local host ")). isEqualTo (" localhost ") ĊĠĠĠ ĠassertThat ( string Prep (" LOCAL HOST ")). isEqualTo (" localhost ") ĊĠĠĠ ĠassertThat ( string Prep (" abc 1 2 3 def ")). isEqualTo (" abc 1 2 3 def ") ĊĠĠĠ ĠassertThat ( string Prep (" ÃŁ ")). isEqualTo (" ss ") ĊĠĠĠ ĠassertThat ( string Prep (" Ä° ")). isEqualTo (" i Ì ĩ ") ĊĠĠĠ ĠassertThat ( string Prep (" Ï Ĵ ")). isEqualTo (" Ïħ ") ĊĠĠĠ ĠassertThat ( string Prep (" á½ Ĵ ")). isEqualTo (" Ïħ Ì ĵ ÌĢ ") ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġother Fold ing () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep (" âĦ ī ")). isEqualTo (" Â° f ") ĊĠĠĠ ĠassertThat ( string Prep (" ã į ± ")). isEqualTo (" h pa ") ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Characters Spaces () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep (" Ġ" )). isEqualTo (" Ġ") Ġ// ĠASCII Ġspace Ġnot Ġpro hibited . ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 0 0 3 ")). isNull () Ġ// ĠEM ĠSPACE ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Control Characters () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 0 7 f ")). isEqualTo ("\ u 0 0 7 f ") Ġ// ĠASCII Ġdelete Ġnot Ġpro hibited . ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 0 8 0 ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 0 2 9 ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ ud 8 3 4 \ udd 7 a ")). isNull () Ġ// ĠNote Ġthat Ġthis Ġis Ġone Ġcode Ġpoint . ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Private Use () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ uf 8 ff ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ ud bff \ ud ffd ")). isNull () Ġ// ĠNote Ġthat Ġthis Ġis Ġone Ġcode Ġpoint . ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Non Character () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ uf dd 0 ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ uff fe ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ ud bff \ ud ffe ")). isNull () ĊĠ Ġ} ĊĊĠ Ġ/** ĊĠĠ Ġ* ĠBecause Ġour ĠAPI Ġalways Ġtrans codes Ġthrough ĠUTF - 8 , Ġand Ġthat Ġtrans coding Ġreplaces Ġun paired ĊĠĠ Ġ* Ġsur rog ates Ġwith Ġ' ?', Ġwe Ġcan 't Ġtest Ġthis Ġbehavior Ġwith ĠJava ĠStrings . ĠInstead , Ġpass Ġthe Ġsur rogate ĊĠĠ Ġ* Ġcode Ġitself Ġencoded Ġas ĠUTF - 8 Ġsequence . ĊĠĠ Ġ*/ ĊĠ Ġ@ Test Ġfun Ġpro hib ition Sur rogate Codes () Ġ{ ĊĠĠĠ Ġ// ĠUTF - 8 Ġencoding Ġof Ġthe Ġhigh Ġsur rogate ĠU + D 8 0 0 . ĊĠĠĠ ĠassertThat ( string Prep ( Buffer (). write (" eda 0 8 0 ". decode Hex ())) ). isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition In appro priate For Plain Text () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ uff f 9 ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ uff fc ")). isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Ide o graphic () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 ff 0 ")). isNull () ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 ffb ")). isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Change Display Properties Or Deprecated () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 3 4 0 ")). isNull () Ġ// ĠCOMB IN ING ĠGR AVE ĠT ONE ĠMARK ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 0 0 e ")). isNull () Ġ// ĠLEFT - TO - RIGHT ĠMARK ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 0 6 e ")). isNull () Ġ// ĠN ATION AL ĠDIG IT ĠSH AP ES ĊĠĠĠ ĠassertThat ( string Prep ("\ u 2 0 6 f ")). isNull () Ġ// ĠNO MIN AL ĠDIG IT ĠSH AP ES ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġpro hib ition Tagging Characters () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ ud b 4 0 \ udc 0 1 ")). isNull () Ġ// ĠNote Ġthat Ġthis Ġis Ġone Ġcode Ġpoint . ĊĠĠĠ ĠassertThat ( string Prep ("\ ud b 4 0 \ udc 7 f ")). isNull () Ġ// ĠNote Ġthat Ġthis Ġis Ġone Ġcode Ġpoint . ĊĠ Ġ} ĊĊĠ Ġ/** ĊĠĠ Ġ* ĠFor Ġthis Ġtest : ĊĠĠ Ġ* ĊĠĠ Ġ* Ġ Ġ* ĠU + 0 6 2 7 Ġand ĠU + 0 6 2 8 Ġare ĠRand AL Cat Ġcharacters ĊĠĠ Ġ* Ġ Ġ* Ġ' a ', Ġ' b ', Ġand Ġ' c ' Ġare ĠL Cat Ġcharacters . ĊĠĠ Ġ* Ġ Ġ* Ġ' 1 ', Ġ' 2 ', Ġand Ġ' 3 ' Ġare Ġneither . ĊĠĠ Ġ*/ ĊĠ Ġ@ Test Ġfun Ġbidi Rules () Ġ{ ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 6 2 7 ")). isEqualTo ("\ u 0 6 2 7 ") ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 6 2 7 \ u 0 6 2 8 ")). isEqualTo ("\ u 0 6 2 7 \ u 0 6 2 8 ") ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 6 2 7 1 2 3 \ u 0 6 2 8 ")). isEqualTo ("\ u 0 6 2 7 1 2 3 \ u 0 6 2 8 ") ĊĊĠĠĠ Ġ// ĠL Cat Ġembedded ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 6 2 7 abc \ u 0 6 2 8 ")). isNull () ĊĊĠĠĠ Ġ// ĠRand AL Cat Ġnot Ġlast . ĊĠĠĠ ĠassertThat ( string Prep ("\ u 0 6 2 7 1 2 3 ")). isNull () ĊĊĠĠĠ Ġ// ĠRand AL Cat Ġnot Ġfirst . ĊĠĠĠ ĠassertThat ( string Prep (" 1 2 3 \ u 0 6 2 8 ")). isNull () ĊĠ Ġ} Ċ } Ċ