package Ġcom . android . a apt compiler Ċ Ċ import Ġcom . android . a apt compiler . android . Res Value Ċ import Ġcom . android . a apt . Resources Ċ import Ġcom . android . resources . Resource Visibility Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ const Ġval ĠXML _ PRE AM BLE Ġ= Ġ"<? xml Ġversion =\" 1 . 0 \" Ġencoding =\" utf - 8 \" ?> \ n " Ċ Ċ class ĠTable Extractor Test Ġ{ ĊĊĠ Ġlateinit Ġvar Ġtable : ĠResource Table ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġtable Ġ= ĠResource Table () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġtest Parse ( ĊĠĠĠĠĠ Ġinput : ĠString , ĊĠĠĠĠĠ Ġconfig : ĠConfig Description Ġ= ĠConfig Description (), ĊĠĠĠĠĠ Ġmock Logger : ĠBl ame Logger Test . Mock Logger ? Ġ= Ġnull ĊĠ Ġ): ĠBoolean Ġ{ ĊĠĠĠ Ġval Ġparse Input Ġ= ĊĠĠĠĠĠ Ġ""" $ XML _ PRE AM BLE ĊĠĠĠĠĠ Ġ< resources > ĊĠĠĠĠĠ Ġ$ input ĊĠĠĠĠĠ Ġ</ resources > ĊĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠ Ġval Ġbl ame Logger Ġ= Ġif Ġ( mock Logger Ġ!= Ġnull ) Ġget Mock Bl ame Logger ( mock Logger ) Ġelse Ġnull ĊĊĠĠĠ Ġval Ġextractor Ġ= ĊĠĠĠĠĠ ĠTable Extractor ( table , ĠSource (" test . xml "), Ġconfig , ĠTable Extractor Options (), Ġbl ame Logger ) ĊĊĠĠĠ Ġreturn Ġextractor . extract ( parse Input . byte InputStream ()) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠgetValue ( ĊĠĠĠ Ġres Name : ĠString , ĊĠĠĠ Ġconfig : ĠConfig Description Ġ= ĠConfig Description (), ĊĠĠĠ Ġproduct Name : ĠString Ġ= Ġ"") Ġ= ĊĠĠĠ ĠgetValue ( table , Ġres Name , Ġconfig , Ġproduct Name ) ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Empty Input () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ"$ XML _ PRE AM BLE \ n " ĊĊĠĠĠ Ġval Ġmock Logger Ġ= ĠBl ame Logger Test . Mock Logger () ĊĊĠĠĠ Ġval Ġextractor Ġ= ĊĠĠĠĠĠ ĠTable Extractor ( ĊĠĠĠĠĠĠĠĠĠ Ġtable , ĊĠĠĠĠĠĠĠĠĠ ĠSource (" test . xml "), ĊĠĠĠĠĠĠĠĠĠ ĠConfig Description (), ĊĠĠĠĠĠĠĠĠĠ ĠTable Extractor Options (), ĊĠĠĠĠĠĠĠĠĠ Ġget Mock Bl ame Logger ( mock Logger )) ĊĊĠĠĠ ĠassertThat ( extractor . extract ( input . byte InputStream ())). isTrue () ĊĠĠĠ ĠassertThat ( mock Logger . errors ). isEmpty () ĊĠĠĠ ĠassertThat ( mock Logger . warnings ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġfail To Parse With No Root () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" $ XML _ PRE AM BLE < attr Ġname =" foo "/> """ ĊĠĠĠ Ġval Ġmock Logger Ġ= ĠBl ame Logger Test . Mock Logger () ĊĠĠĠ Ġval Ġbl ame Logger Ġ= Ġget Mock Bl ame Logger ( mock Logger ) ĊĠĠĠ Ġval Ġextractor Ġ= ĊĠĠĠĠĠ ĠTable Extractor ( ĊĠĠĠĠĠĠĠĠĠ Ġtable , ĠSource (" test . xml "), ĠConfig Description (), ĠTable Extractor Options (), Ġbl ame Logger ) ĊĊĠĠĠ ĠassertThat ( extractor . extract ( input . byte InputStream ())). isFalse () ĊĠĠĠ ĠassertThat ( mock Logger . errors ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( mock Logger . errors . single (). first ). contains ( ĊĠĠĠĠĠĠĠ Ġ" test . xml . re written : 0 : 1 : ĠRoot Ġxml Ġelement Ġof Ġresource Ġtable Ġnot Ġlabeled Ġ\" resources \" ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġfail To Parse Duplicates () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠ Ġ< attr Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bar " Ġvalue =" 0 "/> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bar " Ġvalue =" 1 "/> ĊĠĠĠ Ġ</ attr > ĊĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠĠĠ Ġval Ġmock Logger Ġ= ĠBl ame Logger Test . Mock Logger () ĊĠĠĠĠĠ ĠassertThat ( test Parse ( input , Ġmock Logger Ġ= Ġmock Logger )). isFalse () ĊĠĠĠĠĠ ĠassertThat ( mock Logger . errors ). has Size ( 1 ) ĊĠĠĠĠĠ Ġval Ġerror Msg Ġ= Ġmock Logger . errors . single (). first ĊĊĠĠĠĠĠ ĠassertThat ( error Msg ). contains ( ĊĠĠĠĠĠĠĠĠĠ Ġ" test . xml . re written : 7 : 1 : ĠDuplicate Ġsymbol Ġ' id / bar ' Ġdefined Ġhere :") ĊĠĠĠĠĠ ĠassertThat ( error Msg ). contains ( ĊĠĠĠĠĠĠĠĠĠ Ġ" test . xml . re written : 7 : 1 : Ġ Ġand Ġhere :") ĊĠĠĠĠĠ ĠassertThat ( error Msg ) ĊĠĠĠĠĠĠĠĠĠ Ġ. contains (" test . xml . re written : 6 : 1 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Boolean () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< bool Ġname =" a "> true </ bool > ĊĠĠĠĠĠ Ġ< bool Ġname =" b "> false </ bool > """. trim Indent () ĊĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġbool A Ġ= ĠgetValue (" bool / a ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( bool A ). isNotNull () ĊĠĠĠ ĠassertThat ( bool A !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ BOOLEAN ) ĊĠĠĠ ĠassertThat ( bool A . res Value . data ). isEqualTo (- 1 ) ĊĊĠĠĠ Ġval Ġbool B Ġ= ĠgetValue (" bool / b ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( bool B ). isNotNull () ĊĠĠĠ ĠassertThat ( bool B !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ BOOLEAN ) ĊĠĠĠ ĠassertThat ( bool B . res Value . data ). isEqualTo ( 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Color () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< color Ġname =" a "># 7 fa 8 7 f </ color > ĊĠĠĠĠĠ Ġ< color Ġname =" b ">@ android : color / black </ color > ĊĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġcolor A Ġ= ĠgetValue (" color / a ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( color A ). isNotNull () ĊĠĠĠ ĠassertThat ( color A !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ COLOR _ RGB 8 ) ĊĠĠĠ ĠassertThat ( color A . res Value . data ). isEqualTo ( 0 xff 7 fa 8 7 f . toInt ()) ĊĊĠĠĠ Ġval Ġcolor B Ġ= ĠgetValue (" color / b ") Ġas ? ĠReference ĊĠĠĠ ĠassertThat ( color B ). isNotNull () ĊĠĠĠ ĠassertThat ( color B !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" android : color / black ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġparse Dim en () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ Ġ""" ĊĠĠĠĠĠĠĠ Ġ< dim en Ġname =" a "> 1 6 dp </ dim en > ĊĠĠĠĠĠĠĠ Ġ< dim en Ġname =" b ">@ dim en / abc _ control _ padding _ material </ dim en > ĊĠĠĠĠĠĠĠ Ġ< item Ġname =" c " Ġtype =" dim en "> 1 0 %</ item > ĊĠĠĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġdim en A Ġ= ĠgetValue (" dim en / a ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( dim en A ). isNotNull () ĊĠĠĠ ĠassertThat ( dim en A !!. res Value . dataType ). isEqualTo ( Res Value . DataType . DIMENSION ) ĊĠĠĠ ĠassertThat ( dim en A . res Value . data ). isEqualTo ( 0 x 1 0 0 1 ) ĊĊĠĠĠ Ġval Ġdim en B Ġ= ĠgetValue (" dim en / b ") Ġas ? ĠReference ĊĠĠĠ ĠassertThat ( dim en B ). isNotNull () ĊĠĠĠ ĠassertThat ( dim en B !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" dim en / abc _ control _ padding _ material ") !!. resourceName ) ĊĊĠĠĠ Ġval Ġdim en C Ġ= ĠgetValue (" dim en / c ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( dim en C ). isNotNull () ĊĠĠĠ ĠassertThat ( dim en C !!. res Value . dataType ). isEqualTo ( Res Value . DataType . FR ACTION ) ĊĠĠĠ Ġ// Ġ 0 ĠĠĠĠĠĠĠĠĠĠĠ 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 ĠĠĠĠĠ 0 0 1 1 ĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 0 0 0 ĊĠĠĠ Ġ// Ġ^ Ġpositive Ġ Ġ^ Ġ 1 0 % Ġor Ġ. 1 Ġwith Ġrounding . Ġ Ġ^ ĠRad ix Ġ 0 p 2 3 Ġ( all Ġfraction ) Ġ^ Ġnon - parent Ġfraction ĊĠĠĠ Ġ// Ġi . e . Ġ 0 x 0 cccc d 3 0 ĊĠĠĠ ĠassertThat ( dim en C . res Value . data ). isEqualTo ( 0 x 0 cccc d 3 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Drawable () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < drawable Ġname =" foo "># 0 c ffffff </ drawable > "" ")). isTrue () ĊĊĠĠĠ Ġval Ġdrawable Ġ= ĠgetValue (" drawable / foo ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( drawable ). isNotNull () ĊĠĠĠ ĠassertThat ( drawable !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ COLOR _ ARGB 8 ) ĊĠĠĠ ĠassertThat ( drawable . res Value . data ). isEqualTo ( 0 xc ffffff ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Integer () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< integer Ġname =" a "> 1 0 </ integer > ĊĠĠĠĠĠ Ġ< integer Ġname =" b "> 0 x 1 0 </ integer > ĊĠĠĠĠĠ Ġ< item Ġname =" c " Ġtype =" integer "> 0 xA </ item > ĊĠĠĠ Ġ""" . trim Indent () ĊĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġinteger A Ġ= ĠgetValue (" integer / a ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( integer A ). isNotNull () ĊĠĠĠ ĠassertThat ( integer A !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ DEC ) ĊĠĠĠ ĠassertThat ( integer A . res Value . data ). isEqualTo ( 1 0 ) ĊĊĠĠĠ Ġval Ġinteger B Ġ= ĠgetValue (" integer / b ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( integer B ). isNotNull () ĊĠĠĠ ĠassertThat ( integer B !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ HEX ) ĊĠĠĠ ĠassertThat ( integer B . res Value . data ). isEqualTo ( 1 6 ) ĊĊĠĠĠ Ġval Ġinteger C Ġ= ĠgetValue (" integer / c ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( integer C ). isNotNull () ĊĠĠĠ ĠassertThat ( integer C !!. res Value . dataType ). isEqualTo ( Res Value . DataType . INT _ HEX ) ĊĠĠĠ ĠassertThat ( integer C . res Value . data ). isEqualTo ( 1 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Id () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < item Ġname =" foo " Ġtype =" id "/> "" ")). isTrue () ĊĠĠĠ ĠassertThat ( getValue (" id / foo ") Ġas ? ĠId ). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parsing Non ItemId () Ġ{ ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" < id Ġname =" foo "/> "" ")). isTrue () ĊĠĠĠĠĠ ĠassertThat ( getValue (" id / foo ") Ġas ? ĠId ). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Quoted String () Ġ{ ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo "> ĠĠ Ġ" Ġ Ġhe y Ġthere Ġ" Ġ</ string > "" ")). isTrue () ĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Ġ Ġhe y Ġthere Ġ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" bar "> Is n \' t Ġit Ġcool ?</ string > "" ")). isTrue () ĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / bar ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Is n 't Ġit Ġcool ?") ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" baz ">" Is n 't Ġit Ġcool ?" </ string > "" ")). isTrue () ĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / baz ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Is n 't Ġit Ġcool ?") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse C Data String () Ġ{ ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo ">< ![ CDATA [ basic ]] ></ string > "" ")). isTrue () ĊĠĠĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" basic ") ĊĠĠĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" bar ">< ![ CDATA [< span > Try Ġspan </ span > ]] ></ string > "" ")). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / bar ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("< span > Try Ġspan </ span >") ĊĊĠĠĠĠĠ Ġ// ĠTesting Ġmultiple ĠC DATA Ġspans Ġand Ġwhitespace Ġbehavior Ġacross Ġspans . ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" baz ">< ![ CDATA [ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ< t > trial </ t > ]] > multiple Ġ<![ CDATA [ Ġ< t > trials </ t > ]] ></ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / baz ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("< t > trial </ t > multiple Ġ< t > trials </ t >") ĊĊĠĠĠĠĠ Ġ// ĠQu otes Ġare Ġhandled Ġas Ġexpected . ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" bat ">" Ġ Ġ<![ CDATA [ Let 's Ġgo ! ]] > Ġ Ġ"</ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())) ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / bat ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Ġ ĠLet 's Ġgo ! Ġ Ġ") ĊĊĠĠĠĠĠ Ġ// ĠQu otes Ġare Ġhandle Ġthe Ġsame Ġinside Ġor Ġout Ġof ĠC DATA . ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" bat 2 ">< ![ CDATA [" Ġ ĠLet 's Ġgo ! Ġ Ġ" ]] ></ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / bat 2 ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Ġ ĠLet 's Ġgo ! Ġ Ġ") ĊĊĠĠĠĠĠ Ġ// ĠOr Ġacross Ġthe ĠC DATA Ġborder . ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" bat 3 ">" Ġ<![ CDATA [ ĠLet 's Ġgo ! Ġ] ]> Ġ"</ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / bat 3 ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Ġ ĠLet 's Ġgo ! Ġ Ġ") ĊĊĠĠĠĠĠ Ġ// ĠInvalid Ġxml Ġin ĠC DATA Ġis Ġokay . ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" b ax ">< ![ CDATA [< invalid > xml ]] ></ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / b ax ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("< invalid > xml ") ĊĊĠĠĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠĠĠ Ġ< string Ġname =" b av ">< ![ CDATA [\" Ġ ĠQU OTE ĠTIME Ġ Ġ\ "]] ></ string > ĊĠĠĠĠĠ Ġ""" . trim Indent ())). isTrue () ĊĠĠĠĠĠ Ġstr Ġ= ĠgetValue (" string / b av ") Ġas ĠBasic String ĊĠĠĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\" ĠQU OTE ĠTIME Ġ\" ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Esc aped String () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo ">\ ? 1 2 3 </ string > "" ")). isTrue () ĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" ? 1 2 3 ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" bar "> This Ġisn \' t Ġa Ġbad Ġstring </ string > "" ")) ĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / bar ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" This Ġisn 't Ġa Ġbad Ġstring ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Formatted String () Ġ{ ĊĠĠĠ Ġval Ġmock Logger Ġ= ĠBl ame Logger Test . Mock Logger () ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠĠĠ Ġtest Parse (""" < string Ġname =" foo ">% 1 ${ "$ "} d Ġ% 2 ${ "$ "} s </ string > """, Ġmock Logger Ġ= Ġmock Logger )) ĊĠĠĠĠĠĠĠ Ġ. isTrue () ĊĠĠĠ ĠassertThat ( mock Logger . errors ). isEmpty () ĊĠĠĠ ĠassertThat ( mock Logger . warnings ). isEmpty () ĊĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠĠĠ Ġtest Parse (""" < string Ġname =" foo ">% d Ġ% s </ string > """, Ġmock Logger Ġ= Ġmock Logger )). isFalse () ĊĠĠĠ ĠassertThat ( mock Logger . errors ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( mock Logger . errors . single (). first ). contains ( ĊĠĠĠĠĠĠĠ Ġ" test . xml . re written : 5 : 1 : ĠMultiple Ġsubstitution s Ġspecified Ġin Ġnon - positional Ġformat Ġof Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" string Ġresource Ġstring / foo . Ġ") ĊĠĠĠ ĠassertThat ( mock Logger . warnings ). isEmpty () ĊĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Un formatted String () Ġ{ ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" tested ">% 1 0 </ string > "" ")). isTrue () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Non Ascii String () Ġ{ ĊĠĠĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" theme _ light _ default "> à¤ ¡ à¤¿ à¤ « à¤ ¼ à¥ ī à¤² à¥į à¤ Ł </ string > "" ")). isTrue () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Styled String () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= ĊĠĠĠĠĠ Ġ"< string Ġname =\" foo \"> This Ġis Ġmy Ġa unt \ u 2 0 1 9 s Ġ< b > f ick le Ġ< small > string </ small ></ b ></ string >" ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠStyled String ĊĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" This Ġis Ġmy Ġa unt \ u 2 0 1 9 s Ġf ick le Ġstring ") ĊĠĠĠ ĠassertThat ( str . spans ()). has Size ( 2 ) ĊĠĠĠ ĠassertThat ( str . un trans latable Sections ). isEmpty () ĊĊĠĠĠ Ġval Ġspan 0 Ġ= Ġstr . spans ()[ 0 ] ĊĠĠĠ ĠassertThat ( span 0 . name . value ()). isEqualTo (" b ") ĊĠĠĠ ĠassertThat ( span 0 . first Char ). isEqualTo ( 1 8 ) ĊĠĠĠ ĠassertThat ( span 0 . last Char ). isEqualTo ( 3 0 ) ĊĊĠĠĠ Ġval Ġspan 1 Ġ= Ġstr . spans ()[ 1 ] ĊĠĠĠ ĠassertThat ( span 1 . name . value ()). isEqualTo (" small ") ĊĠĠĠ ĠassertThat ( span 1 . first Char ). isEqualTo ( 2 5 ) ĊĠĠĠ ĠassertThat ( span 1 . last Char ). isEqualTo ( 3 0 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse String With Whitespace () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo "> Ġ ĠThis Ġis Ġwhat ĠĠ ĠI Ġthink Ġ Ġ</ string > "" ")) ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" This Ġis Ġwhat ĠI Ġthink ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < string Ġname =" foo 2 ">" Ġ ĠThis Ġis Ġwhat ĠĠ ĠI Ġthink Ġ Ġ"</ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 2 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Ġ ĠThis Ġis Ġwhat ĠĠ ĠI Ġthink Ġ Ġ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < string Ġname =" foo 3 "> "\ n Hello Ġworld \ n \ n "</ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 3 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\ n Hello Ġworld \ n \ n ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse String With Explicit New Lines () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo ">\ n \ n Test \ n \ n </ string > "" ")) ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\ n \ n Test \ n \ n ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 2 "> ĠĠĠĠĠ Ġ\ n ĠĠĠĠĠ Ġ</ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 2 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\ n ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 3 ">\ n \ n \ n \ n \ n \ n \ n \ n \ n </ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 3 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\ n \ n \ n \ n \ n \ n \ n \ n \ n ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse String With Basic Line Break ing () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠ Ġ< string Ġname =" foo "> ĊĊĠĠĠĠĠĠĠĠĠ ĠHello ĊĠĠĠĠĠĠĠĠĠ Ġworld ĊĊĊĠĠĠ Ġ</ string > """. trim Margin ())) ĊĊĠĠĠ Ġval Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" Hello Ġworld ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest String Of Wh ites p aces () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo "> ĠĠĠĠĠ Ġ</ string > "" ")) ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEmpty () ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" ĊĠĠĠĠĠĠĠ Ġ< string Ġname =" foo 2 "> ĊĊĊĊĠĠĠĠĠĠĠ Ġ</ string > ĊĠĠĠ Ġ""" . trim Margin ())) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 2 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEmpty () ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest EmptyString () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo "></ string > "" ")) ĊĊĠĠĠ Ġval Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEmpty () ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Short Strings () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo "> a </ string > "" ")) ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" a ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 2 ">\ n </ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 2 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("\ n ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 3 "> "</ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 3 ") Ġas ĠBasic String ĊĠĠĠ Ġ// A AP T 2 Ġremoves Ġthe Ġsingle Ġquotes , Ġso Ġshould Ġbe Ġempty . ĊĠĠĠ ĠassertThat ( str . toString ()). isEmpty () ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest String With Slash () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo ">\ </ string > "" ")) ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 2 ">\ woo \ </ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 2 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" woo ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo 3 ">\ @ \' \\ </ string > "" ")) ĊĊĠĠĠ Ġstr Ġ= ĠgetValue (" string / foo 3 ") Ġas ĠBasic String ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo ("@ ' \\ ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Ignore Xl iff Tags Other Than G () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġxmlns : xl iff =" urn : oasis : names : tc : xl iff : document : 1 . 2 "> ĊĠĠĠĠĠĠĠĠĠ ĠThere Ġare Ġ< xl iff : source > no </ xl iff : source > Ġapp les </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġvar Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( str ). isNotNull () ĊĠĠĠ Ġstr Ġ= Ġstr !! ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" There Ġare Ġno Ġapp les ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġfail To Parse Nested Xl iff G Tags () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġxmlns : xl iff =" urn : oasis : names : tc : xl iff : document : 1 . 2 "> ĊĠĠĠĠĠĠĠĠĠ ĠDo Ġnot Ġ< xl iff : g > translate Ġ< xl iff : g > this </ xl iff : g ></ xl iff : g ></ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Un trans latable Sections () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġxmlns : xl iff =" urn : oasis : names : tc : xl iff : document : 1 . 2 "> ĊĠĠĠĠĠĠĠĠĠ ĠThere Ġare Ġ< xl iff : g Ġid =" count ">% 1 ${ "$ "} d </ xl iff : g > Ġapp les </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( str ). isNotNull () ĊĠĠĠ Ġstr !! ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" There Ġare Ġ% 1 \$ d Ġapp les ") ĊĠĠĠ ĠassertThat ( str . un trans lat ables ). has Size ( 1 ) ĊĊĠĠĠ Ġval Ġun trans lat ables 0 Ġ= Ġstr . un trans lat ables [ 0 ] ĊĠĠĠ ĠassertThat ( un trans lat ables 0 . startIndex ). isEqualTo ( 1 0 ) ĊĠĠĠ ĠassertThat ( un trans lat ables 0 . end Index ). isEqualTo ( 1 4 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Un trans lat ables In Styled String () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġxmlns : xl iff =" urn : oasis : names : tc : xl iff : document : 1 . 2 "> ĊĠĠĠĠĠĠĠĠĠ ĠThere Ġare Ġ< b >< xl iff : g Ġid =" count ">% 1 ${ "$ "} d </ xl iff : g ></ b > Ġapp les </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstr Ġ= ĠgetValue (" string / foo ") Ġas ? ĠStyled String ĊĠĠĠ ĠassertThat ( str ). isNotNull () ĊĠĠĠ Ġstr !! ĊĠĠĠ ĠassertThat ( str . toString ()). isEqualTo (" ĠThere Ġare Ġ% 1 \$ d Ġapp les ") ĊĠĠĠ ĠassertThat ( str . spans ()). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( str . un trans latable Sections ). has Size ( 1 ) ĊĊĠĠĠ Ġval Ġun trans lat ables 0 Ġ= Ġstr . un trans latable Sections [ 0 ] ĊĠĠĠ ĠassertThat ( un trans lat ables 0 . startIndex ). isEqualTo ( 1 1 ) ĊĠĠĠ ĠassertThat ( un trans lat ables 0 . end Index ). isEqualTo ( 1 5 ) ĊĊĠĠĠ Ġval Ġspan 0 Ġ= Ġstr . spans ()[ 0 ] ĊĠĠĠ ĠassertThat ( span 0 . name . value ()). isEqualTo (" b ") ĊĠĠĠ ĠassertThat ( span 0 . first Char ). isEqualTo ( 1 1 ) ĊĠĠĠ ĠassertThat ( span 0 . last Char ). isEqualTo ( 1 4 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Null () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" < integer Ġname =" foo ">@ null </ integer > """ ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġ// ĠThe ĠAndroid Ġruntime Ġtre ats Ġa Ġvalue Ġof Ġandroid :: Res _ value :: TYPE _ NULL Ġas Ġa Ġnon - existing Ġvalue , ĊĠĠĠ Ġ// Ġand Ġthis Ġcauses Ġproblems Ġin Ġstyles Ġwhen Ġtrying Ġto Ġresolve Ġan Ġattribute . ĠNull Ġvalues Ġmust Ġbe ĊĠĠĠ Ġ// Ġencoded Ġas Ġandroid :: Res _ value :: TYPE _ REFERENCE Ġwith Ġa Ġdata Ġvalue Ġof Ġ 0 . ĊĠĠĠ Ġval Ġnull Ref Ġ= ĠgetValue (" integer / foo ") Ġas ? ĠReference ĊĠĠĠ ĠassertThat ( null Ref ). isNotNull () ĊĠĠĠ Ġnull Ref !! ĊĠĠĠ ĠassertThat ( null Ref . name ). isEqualTo ( ResourceName ("", ĠA apt ResourceType . RAW , Ġ"")) ĊĠĠĠ ĠassertThat ( null Ref . id ). isNull () ĊĠĠĠ ĠassertThat ( null Ref . reference Type ). isEqualTo ( Reference . Type . RESOURCE ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Empty Value () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" < integer Ġname =" foo ">@ empty </ integer > """ ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġinteger Ġ= ĠgetValue (" integer / foo ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( integer ). isNotNull () ĊĠĠĠ Ġinteger !! ĊĠĠĠ ĠassertThat ( integer . res Value . dataType ). isEqualTo ( Res Value . DataType . NULL ) ĊĠĠĠ ĠassertThat ( integer . res Value . data ). isEqualTo ( Res Value . Null Format . EMPTY ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Attr () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġformat =" string "/> ĊĠĠĠĠĠ Ġ< attr Ġname =" bar "/> ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr 1 Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr 1 ). isNotNull () ĊĠĠĠ Ġattr 1 !! ĊĠĠĠ ĠassertThat ( attr 1 . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . STRING _ VALUE ) ĊĊĠĠĠ Ġval Ġattr 2 Ġ= ĠgetValue (" attr / bar ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr 2 ). isNotNull () ĊĠĠĠ Ġattr 2 !! ĊĠĠĠ ĠassertThat ( attr 2 . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . ANY _ VALUE ) ĊĠ Ġ} ĊĊĠ Ġ// ĠOld ĠA AP T Ġallowed Ġattributes Ġto Ġbe Ġdefined Ġunder Ġdifferent Ġconfigurations , Ġbut Ġultimately ĊĠ Ġ// Ġstored Ġthem Ġwith Ġthe Ġdefault Ġconfiguration . ĠCheck Ġthat Ġwe Ġhave Ġthe Ġsame Ġbehavior . ĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Attr And Declare Style able Under Config But Record As No Config () Ġ{ ĊĠĠĠ Ġval Ġwatch Config Ġ= Ġparse (" watch ") ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġ/> ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" bar "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" baz " Ġ/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input , Ġwatch Config )). isTrue () ĊĊĠĠĠ ĠassertThat ( getValue (" attr / foo ", Ġwatch Config )). isNull () ĊĠĠĠ ĠassertThat ( getValue (" attr / baz ", Ġwatch Config )). isNull () ĊĠĠĠ ĠassertThat ( getValue (" style able / bar ", Ġwatch Config )). isNull () ĊĊĠĠĠ ĠassertThat ( getValue (" attr / foo ")). isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" attr / baz ")). isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" style able / bar ")). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Attr With MinMax () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" < attr Ġname =" foo " Ġmin =" 1 0 " Ġmax =" 2 3 " Ġformat =" integer "/> """ ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ Ġattr !! ĊĠĠĠ ĠassertThat ( attr . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . INTEGER _ VALUE ) ĊĠĠĠ ĠassertThat ( attr . min Int ). isEqualTo ( 1 0 ) ĊĠĠĠ ĠassertThat ( attr . max Int ). isEqualTo ( 2 3 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġfail To Parse Attr With MinMax But Not Integer () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" < attr Ġname =" foo " Ġmin =" 1 0 " Ġmax =" 2 3 " Ġformat =" string "/> """ ĊĠĠĠ ĠassertThat ( test Parse ( input )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Use And Declaration Of Attr () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" Style able "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġ/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġformat =" string "/> ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ Ġattr !! ĊĠĠĠ ĠassertThat ( attr . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . STRING _ VALUE ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Double Use Of Attr () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" Theme "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġ/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" Window "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" foo " Ġformat =" boolean "/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ Ġattr !! ĊĠĠĠ ĠassertThat ( attr . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . BOOLEAN _ VALUE ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Enum Attr () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< attr Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bar " Ġvalue =" 0 "/> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bat " Ġvalue =" 1 "/> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" baz " Ġvalue =" 2 "/> ĊĠĠĠĠĠ Ġ</ attr > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ Ġattr !! ĊĠĠĠ ĠassertThat ( attr . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . ENUM _ VALUE ) ĊĠĠĠ ĠassertThat ( attr . symbols ). has Size ( 3 ) ĊĊĠĠĠ Ġval Ġsymbol 0 Ġ= Ġattr . symbols [ 0 ] ĊĠĠĠ ĠassertThat ( symbol 0 . symbol . name . entry ). isEqualTo (" bar ") ĊĠĠĠ ĠassertThat ( symbol 0 . value ). isEqualTo ( 0 ) ĊĊĠĠĠ Ġval Ġsymbol 1 Ġ= Ġattr . symbols [ 1 ] ĊĠĠĠ ĠassertThat ( symbol 1 . symbol . name . entry ). isEqualTo (" bat ") ĊĠĠĠ ĠassertThat ( symbol 1 . value ). isEqualTo ( 1 ) ĊĊĠĠĠ Ġval Ġsymbol 2 Ġ= Ġattr . symbols [ 2 ] ĊĠĠĠ ĠassertThat ( symbol 2 . symbol . name . entry ). isEqualTo (" baz ") ĊĠĠĠ ĠassertThat ( symbol 2 . value ). isEqualTo ( 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Flag Attr () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< attr Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< flag Ġname =" bar " Ġvalue =" 0 "/> ĊĠĠĠĠĠĠĠ Ġ< flag Ġname =" bat " Ġvalue =" 1 "/> ĊĠĠĠĠĠĠĠ Ġ< flag Ġname =" baz " Ġvalue =" 2 "/> ĊĠĠĠĠĠ Ġ</ attr > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ Ġattr !! ĊĠĠĠ ĠassertThat ( attr . type Mask ). isEqualTo ( Resources . Attribute . Format Flags . FLAGS _ VALUE ) ĊĠĠĠ ĠassertThat ( attr . symbols ). has Size ( 3 ) ĊĊĠĠĠ Ġval Ġsymbol 0 Ġ= Ġattr . symbols [ 0 ] ĊĠĠĠ ĠassertThat ( symbol 0 . symbol . name . entry ). isEqualTo (" bar ") ĊĠĠĠ ĠassertThat ( symbol 0 . value ). isEqualTo ( 0 ) ĊĊĠĠĠ Ġval Ġsymbol 1 Ġ= Ġattr . symbols [ 1 ] ĊĠĠĠ ĠassertThat ( symbol 1 . symbol . name . entry ). isEqualTo (" bat ") ĊĠĠĠ ĠassertThat ( symbol 1 . value ). isEqualTo ( 1 ) ĊĊĠĠĠ Ġval Ġsymbol 2 Ġ= Ġattr . symbols [ 2 ] ĊĠĠĠ ĠassertThat ( symbol 2 . symbol . name . entry ). isEqualTo (" baz ") ĊĠĠĠ ĠassertThat ( symbol 2 . value ). isEqualTo ( 2 ) ĊĊĠĠĠ Ġval Ġflag Value Ġ= Ġtry Parse Flag Symbol ( attr , Ġ" baz Ġ| Ġbat ") ĊĠĠĠ ĠassertThat ( flag Value ). isNotNull () ĊĠĠĠ Ġflag Value !! ĊĠĠĠ ĠassertThat ( flag Value . res Value . data ). isEqualTo ( 1 Ġor Ġ 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġfail Parse Enum Non Unique Keys () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< attr Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bar " Ġvalue =" 0 "/> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bat " Ġvalue =" 1 "/> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" bat " Ġvalue =" 2 "/> ĊĠĠĠĠĠ Ġ</ attr > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< style Ġname =" foo " Ġparent ="@ style / fu "> ĊĠĠĠĠĠĠĠ Ġ< item Ġname =" bar "># ffffffff </ item > ĊĠĠĠĠĠĠĠ Ġ< item Ġname =" bat ">@ string / hey </ item > ĊĠĠĠĠĠĠĠ Ġ< item Ġname =" baz ">< b > hey </ b ></ item > ĊĠĠĠĠĠ Ġ</ style > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNotNull () ĊĠĠĠ ĠassertThat ( style . parent !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" style / fu ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( style . entries ). has Size ( 3 ) ĊĊĠĠĠ ĠassertThat ( style . entries [ 0 ]. key . name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / bar ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( style . entries [ 1 ]. key . name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / bat ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( style . entries [ 2 ]. key . name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / baz ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With Sh orthand Parent () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < style Ġname =" foo " Ġparent =" com . app : Theme "/> "" ")). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNotNull () ĊĠĠĠ ĠassertThat ( style . parent !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" com . app : style / Theme ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With Package Ali ased Parent () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< style Ġxmlns : app =" http :// schemas . android . com / apk / res / android " ĊĠĠĠĠĠĠĠĠĠ Ġname =" foo " Ġparent =" app : Theme "/> ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNotNull () ĊĠĠĠ ĠassertThat ( style . parent !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" android : style / Theme ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With Package Ali ased Items () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< style Ġxmlns : app =" http :// schemas . android . com / apk / res / android " Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< item Ġname =" app : bar "> 0 </ item > ĊĠĠĠĠĠ Ġ</ style > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . entries ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( style . entries [ 0 ]. key . name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" android : attr / bar ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With In ferred Parent () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < style Ġname =" foo . bar "/> "" ")). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo . bar ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNotNull () ĊĠĠĠ ĠassertThat ( style . parent In ferred ). isTrue () ĊĠĠĠ ĠassertThat ( style . parent !!. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" style / foo ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With Over written In ferred Parent () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < style Ġname =" foo . bar " Ġparent =""/> "" ")). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo . bar ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNull () ĊĠĠĠ ĠassertThat ( style . parent In ferred ). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Style With Private Parent () Ġ{ ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < style Ġname =" foo " Ġparent =" * android : style / bar " Ġ/> "" ")). isTrue () ĊĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / foo ") Ġas ? ĠStyle ĊĠĠĠ ĠassertThat ( style ). isNotNull () ĊĠĠĠ Ġstyle !! ĊĠĠĠ ĠassertThat ( style . parent ). isNotNull () ĊĠĠĠ ĠassertThat ( style . parent !!. is Private ). isTrue () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Auto Generated Id () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < string Ġname =" foo ">@ + id / bar </ string > "" ")). isTrue () ĊĠĠĠ ĠassertThat ( getValue (" id / bar ")). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Attributes In Declare Style able () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" bar " Ġ/> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" bat " Ġformat =" string | reference "/> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" baz "> ĊĠĠĠĠĠĠĠĠĠ Ġ< enum Ġname =" foo " Ġvalue =" 1 "/> ĊĠĠĠĠĠĠĠ Ġ</ attr > ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġtable Result Ġ= Ġtable . find Resource ( parse ResourceName (" style able / foo ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( table Result ). isNotNull () ĊĠĠĠ ĠassertThat ( table Result !!. entry . visibility . level ). isEqualTo ( Resource Visibility . PUBLIC ) ĊĊĠĠĠ Ġval Ġattr 1 Ġ= ĠgetValue (" attr / bar ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr 1 ). isNotNull () ĊĠĠĠ ĠassertThat ( attr 1 !!. weak ). isTrue () ĊĊĠĠĠ Ġval Ġattr 2 Ġ= ĠgetValue (" attr / bat ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr 2 ). isNotNull () ĊĠĠĠ ĠassertThat ( attr 2 !!. weak ). isTrue () ĊĊĠĠĠ Ġval Ġattr 3 Ġ= ĠgetValue (" attr / baz ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr 3 ). isNotNull () ĊĠĠĠ ĠassertThat ( attr 3 !!. weak ). isTrue () ĊĠĠĠ ĠassertThat ( attr 3 . symbols ). has Size ( 1 ) ĊĊĠĠĠ ĠassertThat ( getValue (" id / foo ")). isNotNull () ĊĊĠĠĠ Ġval Ġstyle able Ġ= ĠgetValue (" style able / foo ") Ġas ? ĠStyle able ĊĠĠĠ ĠassertThat ( style able ). isNotNull () ĊĠĠĠ Ġstyle able !! ĊĠĠĠ ĠassertThat ( style able . entries ). has Size ( 3 ) ĊĊĠĠĠ ĠassertThat ( style able . entries [ 0 ]. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / bar ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( style able . entries [ 1 ]. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / bat ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( style able . entries [ 2 ]. name ) ĊĠĠĠĠĠ Ġ. isEqualTo ( parse ResourceName (" attr / baz ") !!. resourceName ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Private Attributes Declare Style able () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< declare - style able Ġxmlns : priv Android =" http :// schemas . android . com / apk / prv / res / android " ĊĠĠĠĠĠĠĠĠĠ Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" * android : bar " Ġ/> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" priv Android : bat " Ġ/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstyle able Ġ= ĠgetValue (" style able / foo ") Ġas ? ĠStyle able ĊĠĠĠ ĠassertThat ( style able ). isNotNull () ĊĠĠĠ Ġstyle able !! ĊĠĠĠ ĠassertThat ( style able . entries ). has Size ( 2 ) ĊĊĠĠĠ Ġval Ġattr 0 Ġ= Ġstyle able . entries [ 0 ] ĊĠĠĠ ĠassertThat ( attr 0 . is Private ). isTrue () ĊĠĠĠ ĠassertThat ( attr 0 . name . p ck ). isEqualTo (" android ") ĊĊĠĠĠ Ġval Ġattr 1 Ġ= Ġstyle able . entries [ 1 ] ĊĠĠĠ ĠassertThat ( attr 1 . is Private ). isTrue () ĊĠĠĠ ĠassertThat ( attr 1 . name . p ck ). isEqualTo (" android ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Array () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< array Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< item >@ string / ref </ item > ĊĠĠĠĠĠĠĠ Ġ< item > hey </ item > ĊĠĠĠĠĠĠĠ Ġ< item > 2 3 </ item > ĊĠĠĠĠĠ Ġ</ array > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġarray Ġ= ĠgetValue (" array / foo ") Ġas ? ĠArray Resource ĊĠĠĠ ĠassertThat ( array ). isNotNull () ĊĠĠĠ Ġarray !! ĊĠĠĠ ĠassertThat ( array . elements ). has Size ( 3 ) ĊĊĠĠĠ Ġval Ġitem 0 Ġ= Ġarray . elements [ 0 ] Ġas ? ĠReference ĊĠĠĠ ĠassertThat ( item 0 ). isNotNull () ĊĠĠĠ Ġval Ġitem 1 Ġ= Ġarray . elements [ 1 ] Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( item 1 ). isNotNull () ĊĠĠĠ Ġval Ġitem 2 Ġ= Ġarray . elements [ 2 ] Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( item 2 ). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse String Array () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string - array Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< item >" W erk "</ item >" ĊĠĠĠĠĠ Ġ</ string - array > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġarray Ġ= ĠgetValue (" array / foo ") Ġas ? ĠArray Resource ĊĠĠĠ ĠassertThat ( array ). isNotNull () ĊĠĠĠ ĠassertThat ( array !!. elements ). has Size ( 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Array With Format () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< array Ġname =" foo " Ġformat =" string "> ĊĠĠĠĠĠĠĠ Ġ< item > 1 0 0 </ item > ĊĠĠĠĠĠ Ġ</ array > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġarray Ġ= ĠgetValue (" array / foo ") Ġas ? ĠArray Resource ĊĠĠĠ ĠassertThat ( array ). isNotNull () ĊĠĠĠ Ġarray !! ĊĠĠĠ ĠassertThat ( array . elements ). has Size ( 1 ) ĊĊĠĠĠ Ġval Ġstr Ġ= Ġarray . elements [ 0 ] Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( str ). isNotNull () ĊĠĠĠ ĠassertThat ( str !!. toString ()). isEqualTo (" 1 0 0 ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Array With Bad Format () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< array Ġname =" foo " Ġformat =" integer "> ĊĠĠĠĠĠĠĠ Ġ< item > Hi </ item > ĊĠĠĠĠĠ Ġ</ array > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Pl ural () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< plurals Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ< item Ġquantity =" other "> app les </ item > ĊĠĠĠĠĠĠĠ Ġ< item Ġquantity =" one "> apple </ item > ĊĠĠĠĠĠ Ġ</ plurals > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġplural Ġ= ĠgetValue (" plurals / foo ") Ġas ? ĠPl ural ĊĠĠĠ ĠassertThat ( plural ). isNotNull () ĊĠĠĠ Ġplural !! ĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . ZERO . ordinal ]). isNull () ĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . TWO . ordinal ]). isNull () ĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . FE W . ordinal ]). isNull () ĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . MAN Y . ordinal ]). isNull () ĊĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . ONE . ordinal ]). isNotNull () ĊĠĠĠ ĠassertThat ( plural . values [ Pl ural . Type . OTHER . ordinal ]). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Comments With Resource () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ<!-- This Ġis Ġa Ġcomment --> ĊĠĠĠĠĠ Ġ< string Ġname =" foo "> Hi </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġvalue Ġ= ĠgetValue (" string / foo ") Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( value ). isNotNull () ĊĠĠĠ ĠassertThat ( value !!. comment ). isEqualTo (" This Ġis Ġa Ġcomment ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest DoNot Combine Multiple Comments () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ<!-- One --> ĊĠĠĠĠĠ Ġ<!-- Two --> ĊĠĠĠĠĠ Ġ< string Ġname =" foo "> Hi </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġvalue Ġ= ĠgetValue (" string / foo ") Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( value ). isNotNull () ĊĠĠĠ ĠassertThat ( value !!. comment ). isEqualTo (" Two ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Ignore Comment Before End Tag () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ<!-- One --> ĊĠĠĠĠĠ Ġ< string Ġname =" foo "> ĊĠĠĠĠĠĠĠ ĠHi ĊĠĠĠĠĠ Ġ<!-- Two --> ĊĠĠĠĠĠ Ġ</ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġvalue Ġ= ĠgetValue (" string / foo ") Ġas ? ĠBasic String ĊĠĠĠ ĠassertThat ( value ). isNotNull () ĊĠĠĠ ĠassertThat ( value !!. comment ). isEqualTo (" One ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Nested Comments () Ġ{ ĊĠĠĠ Ġ// ĠWe Ġonly Ġcare Ġabout Ġdeclare - style able Ġand Ġenum / flag Ġattributes Ġbecause Ġcomments Ġfrom Ġthose Ġend ĊĠĠĠ Ġ// Ġup Ġin ĠR . java ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< declare - style able Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ<!-- ĠThe Ġname Ġof Ġthe Ġbar Ġ--> ĊĠĠĠĠĠĠĠ Ġ< attr Ġname =" bar Name " Ġformat =" string | reference " Ġ/> ĊĠĠĠĠĠ Ġ</ declare - style able > ĊĊĠĠĠĠĠ Ġ< attr Ġname =" foo "> ĊĠĠĠĠĠĠĠ Ġ<!-- ĠThe Ġvery Ġfirst Ġ--> ĊĠĠĠĠĠĠĠ Ġ< enum Ġname =" one " Ġvalue =" 1 " Ġ/> ĊĠĠĠĠĠ Ġ</ attr > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġstyle able Ġ= ĠgetValue (" style able / foo ") Ġas ? ĠStyle able ĊĠĠĠ ĠassertThat ( style able ). isNotNull () ĊĠĠĠ ĠassertThat ( style able !!. entries ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( style able . entries [ 0 ]. comment ). isEqualTo (" The Ġname Ġof Ġthe Ġbar ") ĊĊĠĠĠ Ġval Ġattr Ġ= ĠgetValue (" attr / foo ") Ġas ? ĠAttribute Resource ĊĠĠĠ ĠassertThat ( attr ). isNotNull () ĊĠĠĠ ĠassertThat ( attr !!. symbols ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( attr . symbols [ 0 ]. symbol . comment ). isEqualTo (" The Ġvery Ġfirst ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Public Id As Definition () Ġ{ ĊĠĠĠ Ġ// ĠDecl aring Ġan Ġid Ġas Ġpublic Ġshould Ġnot Ġrequire Ġa Ġseparate Ġdefinition Ġ( as Ġan Ġid Ġhas Ġno Ġvalue ) ĊĠĠĠ ĠassertThat ( test Parse (""" < public Ġtype =" id " Ġname =" foo "/> "" ")). isTrue () ĊĠĠĠ ĠassertThat ( getValue (" id / foo ") Ġas ? ĠId ). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Keep All Products () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġproduct =" phone "> hi </ string > ĊĠĠĠĠĠ Ġ< string Ġname =" foo " Ġproduct =" no - sd card "> ho </ string > ĊĠĠĠĠĠ Ġ< string Ġname =" bar " Ġproduct =""> w ee </ string > ĊĠĠĠĠĠ Ġ< string Ġname =" baz "> woo </ string > ĊĠĠĠĠĠ Ġ< string Ġname =" bit " Ġproduct =" ph able t "> h oot </ string > ĊĠĠĠĠĠ Ġ< string Ġname =" bot " Ġproduct =" default "> yes </ string > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ ĠassertThat ( getValue (" string / foo ", Ġproduct Name Ġ= Ġ" phone ") Ġas ? ĠBasic String ) ĊĠĠĠĠĠ Ġ. isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" string / foo ", Ġproduct Name Ġ= Ġ" no - sd card ") Ġas ? ĠBasic String ) ĊĠĠĠĠĠ Ġ. isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" string / bar ") Ġas ? ĠBasic String ). isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" string / baz ") Ġas ? ĠBasic String ). isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" string / bit ", Ġproduct Name Ġ= Ġ" ph able t ") Ġas ? ĠBasic String ) ĊĠĠĠĠĠ Ġ. isNotNull () ĊĠĠĠ ĠassertThat ( getValue (" string / bot ", Ġproduct Name Ġ= Ġ" default ") Ġas ? ĠBasic String ) ĊĠĠĠĠĠ Ġ. isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Auto Increment Ids In Public Group () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ< public - group Ġtype =" attr " Ġfirst - id =" 0 x 0 1 0 1 0 0 4 0 "> ĊĠĠĠĠĠĠĠ Ġ< public Ġname =" foo " Ġ/> ĊĠĠĠĠĠĠĠ Ġ< public Ġname =" bar " Ġ/> ĊĠĠĠĠĠ Ġ</ public - group > ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġtable Result 0 Ġ= Ġtable . find Resource ( parse ResourceName (" attr / foo ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( table Result 0 ). isNotNull () ĊĠĠĠ Ġtable Result 0 !! ĊĠĠĠ ĠassertThat ( table Result 0 . table Package . id ). isNotNull () ĊĠĠĠ ĠassertThat ( table Result 0 . group . id ). isNotNull () ĊĠĠĠ ĠassertThat ( table Result 0 . entry . id ). isNotNull () ĊĠĠĠ Ġval Ġactual Id 0 Ġ= Ġresource Id From Parts ( ĊĠĠĠĠĠ Ġtable Result 0 . table Package . id !! , ĊĠĠĠĠĠ Ġtable Result 0 . group . id !! , ĊĠĠĠĠĠ Ġtable Result 0 . entry . id !! ) ĊĠĠĠ ĠassertThat ( actual Id 0 ). isEqualTo ( 0 x 0 1 0 1 0 0 4 0 ) ĊĊĠĠĠ Ġval Ġtable Result 1 Ġ= Ġtable . find Resource ( parse ResourceName (" attr / bar ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( table Result 1 ). isNotNull () ĊĠĠĠ Ġtable Result 1 !! ĊĠĠĠ ĠassertThat ( table Result 1 . table Package . id ). isNotNull () ĊĠĠĠ ĠassertThat ( table Result 1 . group . id ). isNotNull () ĊĠĠĠ ĠassertThat ( table Result 1 . entry . id ). isNotNull () ĊĠĠĠ Ġval Ġactual Id 1 Ġ= Ġresource Id From Parts ( ĊĠĠĠĠĠ Ġtable Result 1 . table Package . id !! , ĊĠĠĠĠĠ Ġtable Result 1 . group . id !! , ĊĠĠĠĠĠ Ġtable Result 1 . entry . id !! ) ĊĠĠĠ ĠassertThat ( actual Id 1 ). isEqualTo ( 0 x 0 1 0 1 0 0 4 1 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Str on gest Symbol Visibility W ins () Ġ{ ĊĠĠĠ Ġval Ġinput Ġ= Ġ""" ĊĠĠĠĠĠ Ġ<!-- Ġprivate Ġ--> ĊĠĠĠĠĠ Ġ< java - symbol Ġtype =" string " Ġname =" foo " Ġ/> ĊĠĠĠĠĠ Ġ<!-- Ġpublic Ġ--> ĊĠĠĠĠĠ Ġ< public Ġtype =" string " Ġname =" foo " Ġid =" 0 x 0 1 0 2 0 0 0 0 " Ġ/> ĊĠĠĠĠĠ Ġ<!-- Ġprivate 2 Ġ--> ĊĠĠĠĠĠ Ġ< java - symbol Ġtype =" string " Ġname =" foo " Ġ/> ĊĠĠĠ Ġ""" . trim Indent () ĊĠĠĠ ĠassertThat ( test Parse ( input )). isTrue () ĊĊĠĠĠ Ġval Ġtable Result Ġ= Ġtable . find Resource ( parse ResourceName (" string / foo ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( table Result ). isNotNull () ĊĊĠĠĠ Ġval Ġentry Ġ= Ġtable Result !!. entry ĊĠĠĠ ĠassertThat ( entry . visibility . level ). isEqualTo ( Resource Visibility . PUBLIC ) ĊĠĠĠ ĠassertThat ( entry . visibility . comment ). isEqualTo (" public ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest External Types ShouldBe References () Ġ{ ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < item Ġtype =" layout " Ġname =" foo ">@ layout / bar </ item > "" ")). isTrue () ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < item Ġtype =" layout " Ġname =" bar ">" this Ġis Ġa Ġstring "</ item > "" ")). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Add Resources Element Should Add Entry With Undefined Symbol () Ġ{ ĊĠĠĠ ĠassertThat ( test Parse (""" < add - resource Ġname =" bar " Ġtype =" string " Ġ/> "" ")). isTrue () ĊĊĠĠĠ Ġval Ġtable Result Ġ= Ġtable . find Resource ( parse ResourceName (" string / bar ") !!. resourceName ) ĊĠĠĠ ĠassertThat ( table Result ). isNotNull () ĊĠĠĠ Ġval Ġentry Ġ= Ġtable Result !!. entry ĊĠĠĠ ĠassertThat ( entry . visibility . level ). isEqualTo ( Resource Visibility . UNDEFINED ) ĊĠĠĠ ĠassertThat ( entry . allow New ). isNotNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Item Element With Format () Ġ{ ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < item Ġname =" foo " Ġtype =" integer " Ġformat =" float "> 0 . 3 </ item > "" ")). isTrue () ĊĊĠĠĠ Ġval Ġprimitive Ġ= ĠgetValue (" integer / foo ") Ġas ? ĠBinary Primitive ĊĠĠĠ ĠassertThat ( primitive ). isNotNull () ĊĠĠĠ ĠassertThat ( primitive !!. res Value . dataType ). isEqualTo ( Res Value . DataType . FLOAT ) ĊĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġtest Parse (""" < item Ġname =" bar " Ġtype =" integer " Ġformat =" fraction "> 1 0 0 </ item > "" ")). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Item Element Value On NewLine With Quot ations () Ġ{ ĊĠĠĠ Ġval Ġsample Ġ= ĊĠĠĠĠĠĠĠ Ġ""" < style Ġname =" Widget . Image Button . Custom " Ġparent =" android : style / Widget . Image Button "> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ< item Ġname =" custom Attr "> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" some Ġvalue " ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ</ item > ĊĠĠĠĠĠĠĠĠĠĠ Ġ</ style > """ ĊĠĠĠ ĠassertThat ( test Parse ( sample )). isTrue () ĊĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / Widget . Image Button . Custom ") Ġas ĠStyle ĊĠĠĠ Ġval Ġitem Ġ= Ġstyle . entries [ 0 ]. value Ġas ĠRaw String ĊĠĠĠ ĠassertThat ( item . value . value ()). isEqualTo (" some Ġvalue ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Item Element WithValue On NewLine With No Quot ations () Ġ{ ĊĠĠĠĠĠ Ġval Ġsample Ġ= ĊĠĠĠĠĠĠĠĠ Ġ""" < style Ġname =" Widget . Image Button . Custom " Ġparent =" android : style / Widget . Image Button "> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ< item Ġname =" custom Attr "> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsome Ġvalue ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ</ item > ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ</ style > """ ĊĠĠĠĠĠ ĠassertThat ( test Parse ( sample )). isTrue () ĊĠĠĠĠĠ Ġval Ġstyle Ġ= ĠgetValue (" style / Widget . Image Button . Custom ") Ġas ĠStyle ĊĠĠĠĠĠ Ġval Ġitem Ġ= Ġstyle . entries [ 0 ]. value Ġas ĠRaw String ĊĠĠĠĠĠ ĠassertThat ( item . value . value ()). isEqualTo (" some Ġvalue ") ĊĠ Ġ} Ċ } Ċ