/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠBack base ĠR & D ĠB . V . Ċ Ġ* Ċ Ġ* Ġ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 Ġcom . back base . deferred resources . text Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . graphics . drawable . Color Drawable Ċ import Ġcom . back base . deferred resources . Deferred Formatted Pl urals Ċ import Ġcom . back base . deferred resources . test . Specific Locale Test Ċ import Ġcom . back base . deferred resources . test . test Parcelable Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . junit . Assert . assert Throws Ċ import Ġorg . junit . Test Ċ Ċ internal Ġclass ĠForm att ed Deferred Pl urals Test Ġ: ĠSpecific Locale Test () Ġ{ ĊĊĠĠĠ Ġ@ Test Ġfun Ġwith Format Args _ pro duces Instance Equals To Normal Constructor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġformatted Pl urals Ġ= ĠDeferred Formatted Pl urals . Constant ("% s Ġand Ġ% s ") ĊĊĠĠĠĠĠĠĠ Ġval Ġwith Format Args Ġ= Ġformatted Pl urals . with Format Args (" A ", Ġ" B ") ĊĠĠĠĠĠĠĠ Ġval Ġconstructed Ġ= ĠForm att ed Deferred Pl urals ( formatted Pl urals , Ġ" A ", Ġ" B ") ĊĠĠĠĠĠĠĠ ĠassertThat ( with Format Args ). isEqualTo ( construct ed ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġresolve _ format sWith Format Args () Ġ{ ĊĠĠĠĠĠĠĠ Ġset Test Language (" en ") ĊĊĠĠĠĠĠĠĠ Ġval Ġformatted String Ġ= ĠDeferred Formatted Pl urals . Constant ( one Ġ= Ġ"% s Ġs cone ", Ġother Ġ= Ġ"% s Ġs con es ") ĊĊĠĠĠĠĠĠĠ Ġval Ġdeferred Ġ= ĠForm att ed Deferred Pl urals ( formatted String , Ġ" T asty ") ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred . resolve ( context , Ġ 1 )). isEqualTo (" T asty Ġs cone ") ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred . resolve ( context , Ġ 1 0 )). isEqualTo (" T asty Ġs con es ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġequals _ different Formatted Pl urals _ not Equals () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdeferred A Ġ= ĠForm att ed Deferred Pl urals ( Deferred Formatted Pl urals . Constant (" A ")) ĊĠĠĠĠĠĠĠ Ġval Ġdeferred B Ġ= ĠForm att ed Deferred Pl urals ( Deferred Formatted Pl urals . Constant (" B ")) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A ). isNot EqualTo ( deferred B ) ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A . hashCode ()). isNot EqualTo ( deferred B . hashCode ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġequals _ different Format Args _ not Equals () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġformatted String Ġ= ĠDeferred Formatted Pl urals . Constant ("% s ") ĊĠĠĠĠĠĠĠ Ġval Ġdeferred A Ġ= ĠForm att ed Deferred Pl urals ( formatted String , Ġ" A ") ĊĠĠĠĠĠĠĠ Ġval Ġdeferred B Ġ= ĠForm att ed Deferred Pl urals ( formatted String , Ġ" B ") ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A ). isNot EqualTo ( deferred B ) ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A . hashCode ()). isNot EqualTo ( deferred B . hashCode ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġequals _ same Formatted Pl urals And Format Args _ equals () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġformatted String Ġ= ĠDeferred Formatted Pl urals . Constant ("% s ") ĊĠĠĠĠĠĠĠ Ġval Ġdeferred A Ġ= ĠForm att ed Deferred Pl urals ( formatted String , Ġ" 1 0 0 ") ĊĠĠĠĠĠĠĠ Ġval Ġdeferred B Ġ= ĠForm att ed Deferred Pl urals ( formatted String , Ġ" 1 0 0 ") ĊĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A ). isEqualTo ( deferred B ) ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred A . hashCode ()). isEqualTo ( deferred B . hashCode ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun ĠtoString _ includes Formatted String And Format Args () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġformatted Pl urals Ġ= ĠDeferred Formatted Pl urals . Constant ("% s ") ĊĠĠĠĠĠĠĠ Ġval Ġdeferred Ġ= ĠForm att ed Deferred Pl urals ( formatted Pl urals , Ġ" Yes ") ĊĠĠĠĠĠĠĠ ĠassertThat ( deferred . toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo (" Formatted Deferred Pl urals ( wrapped =$ formatted Pl urals , Ġformat Args =[ Yes ]) ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġformatted _ parcel s Through Bundle () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Parcelable < Parcelable Deferred Pl urals >( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠForm att ed Deferred Pl urals ( Deferred Formatted Pl urals . Constant ("% s "), Ġ" Cool ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġformatted _ with Non Parcelable Pl urals _ throws When Marshal led () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnon Parcelable Pl urals Ġ= Ġobject Ġ: ĠDeferred Formatted Pl urals Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġresolve ( context : ĠContext , Ġquantity : ĠInt , Ġvar arg Ġformat Args : ĠAny ): ĠString Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"$ quantity Ġ${ format Args . toList () }" ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// ĠCon struction Ġand Ġresolution Ġwork Ġnormally : ĊĠĠĠĠĠĠĠ Ġval Ġformatted Ġ= ĠForm att ed Deferred Pl urals ( non Parcelable Pl urals , Ġ" Arg ") ĊĠĠĠĠĠĠĠ ĠassertThat ( formatted . resolve ( context , Ġ 1 9 )). isEqualTo (" 1 9 Ġ[ Arg ]") ĊĊĠĠĠĠĠĠĠ Ġ// ĠOnly Ġmarshall ing Ġdoes Ġnot Ġwork : ĊĠĠĠĠĠĠĠ Ġval Ġexception Ġ= ĠassertThrows ( RuntimeException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Parcelable < Parcelable Deferred Pl urals >( formatted ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( exception . message ). isEqualTo (" Parcel : Ġunable Ġto Ġmarshal Ġvalue Ġ$ non Parcelable Pl urals ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġformatted _ with Non Parcelable Arg _ throws When Marshal led () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpl urals Ġ= ĠDeferred Formatted Pl urals . Constant ("% d Ġ% s ") ĊĠĠĠĠĠĠĠ Ġval Ġnon Parcelable Arg Ġ= ĠColor Drawable () ĊĊĠĠĠĠĠĠĠ Ġ// ĠCon struction Ġand Ġresolution Ġwork Ġnormally : ĊĠĠĠĠĠĠĠ Ġval Ġformatted Ġ= ĠForm att ed Deferred Pl urals ( plurals , Ġ 4 4 , Ġnon Parcelable Arg ) ĊĠĠĠĠĠĠĠ ĠassertThat ( formatted . resolve ( context , Ġ 1 9 )). isEqualTo (" 4 4 Ġ$ non Parcelable Arg ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠOnly Ġmarshall ing Ġdoes Ġnot Ġwork : ĊĠĠĠĠĠĠĠ Ġval Ġexception Ġ= ĠassertThrows ( RuntimeException :: class . java ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Parcelable < Parcelable Deferred Pl urals >( formatted ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( exception . message ). isEqualTo (" Parcel : Ġunable Ġto Ġmarshal Ġvalue Ġ$ non Parcelable Arg ") ĊĠĠĠ Ġ} Ċ } Ċ