package Ġcom . con cord ium . wallet . data . util Ċ Ċ import Ġorg . junit . Test Ċ Ċ import Ġorg . junit . Assert .* Ċ import Ġjava . text . Decimal Format Symbols Ċ Ċ class ĠCurrency Util UnitTest Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġdecimal Separator Ġ= ĠDecimal Format Symbols . getInstance (). decimal Separator ĊĊĠĠĠ Ġprivate Ġfun Ġreplace Decimal Sep ( str : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( decimal Separator Ġ!= Ġ'.') Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġstr . replace ('.', Ġdecimal Separator ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġstr ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġformat GT U () Ġ{ ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 0 0 "), ĠCurrency Util . format GT U ( 0 )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 . 0 0 "), ĠCurrency Util . format GT U ( 1 0 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 0 0 . 0 0 "), ĠCurrency Util . format GT U ( 1 0 0 0 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 . 2 0 "), ĠCurrency Util . format GT U ( 1 2 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 . 2 3 "), ĠCurrency Util . format GT U ( 1 2 3 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 . 2 3 4 "), ĠCurrency Util . format GT U ( 1 2 3 4 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 . 2 3 4 5 "), ĠCurrency Util . format GT U ( 1 2 3 4 5 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 1 2 3 . 4 5 6 7 "), ĠCurrency Util . format GT U ( 1 2 3 4 5 6 7 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 0 0 0 1 "), ĠCurrency Util . format GT U ( 1 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 0 0 1 2 "), ĠCurrency Util . format GT U ( 1 2 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 0 1 "), ĠCurrency Util . format GT U ( 1 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 0 1 2 3 "), ĠCurrency Util . format GT U ( 1 2 3 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 2 0 "), ĠCurrency Util . format GT U ( 2 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 2 3 "), ĠCurrency Util . format GT U ( 2 3 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 2 3 4 "), ĠCurrency Util . format GT U ( 2 3 4 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep (" 0 . 2 3 4 5 "), ĠCurrency Util . format GT U ( 2 3 4 5 0 0 )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 . 0 0 "), ĠCurrency Util . format GT U (- 1 0 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 0 0 "), ĠCurrency Util . format GT U (- 1 0 0 0 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 . 2 0 "), ĠCurrency Util . format GT U (- 1 2 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 . 2 3 "), ĠCurrency Util . format GT U (- 1 2 3 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 . 2 3 4 "), ĠCurrency Util . format GT U (- 1 2 3 4 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 . 2 3 4 5 "), ĠCurrency Util . format GT U (- 1 2 3 4 5 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 2 3 . 4 5 6 7 "), ĠCurrency Util . format GT U (- 1 2 3 4 5 6 7 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 0 0 0 1 "), ĠCurrency Util . format GT U (- 1 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 0 0 1 2 "), ĠCurrency Util . format GT U (- 1 2 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 0 1 "), ĠCurrency Util . format GT U (- 1 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 0 1 2 3 "), ĠCurrency Util . format GT U (- 1 2 3 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 2 0 "), ĠCurrency Util . format GT U (- 2 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 2 3 "), ĠCurrency Util . format GT U (- 2 3 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 2 3 4 "), ĠCurrency Util . format GT U (- 2 3 4 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 0 . 2 3 4 5 "), ĠCurrency Util . format GT U (- 2 3 4 5 0 0 )) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 3 4 5 4 7 "), ĠCurrency Util . format GT U (- 1 0 0 2 3 4 5 4 7 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 3 4 5 4 "), ĠCurrency Util . format GT U (- 1 0 0 2 3 4 5 4 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 3 4 5 "), ĠCurrency Util . format GT U (- 1 0 0 2 3 4 5 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 3 4 "), ĠCurrency Util . format GT U (- 1 0 0 2 3 4 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 3 "), ĠCurrency Util . format GT U (- 1 0 0 2 3 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 2 0 "), ĠCurrency Util . format GT U (- 1 0 0 2 0 0 0 0 0 )) ĊĠĠĠĠĠĠĠ ĠassertEquals ( replace Decimal Sep ("- 1 0 0 . 0 0 "), ĠCurrency Util . format GT U (- 1 0 0 0 0 0 0 0 0 )) ĊĊĊĠĠĠĠĠĠĠ Ġ// For Ġthe Ġfollowing Ġto Ġbe Ġtested Ġit Ġneeds Ġto Ġbe Ġin Ġan Ġinst ument ed Ġtest , Ġor Ġan ĊĠĠĠĠĠĠĠ Ġ// Ġalternative Ġsolution Ġfor Ġthe Ġresource Ġstring Ġis Ġneeded : Ġlet Ġthe ĠCurrency Util Ġuse Ġa ĊĠĠĠĠĠĠĠ Ġ// ĠResource c Provider . getString Ġ( that Ġis Ġset Ġon Ġthe ĠApp Core ) Ġinstead Ġof Ġhaving Ġreference Ġto Ġcontext ĊĠĠĠĠĠĠĠ Ġ// assertEquals ( replace Decimal Sep (" 0 . 0 0 "), ĠCurrency Util . format GT U ( 0 , Ġwith G Stroke Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġ// assertEquals ( replace Decimal Sep (" 1 . 0 0 "), ĠCurrency Util . format GT U ( 1 0 0 0 0 , Ġwith G Stroke Ġ= Ġtrue )) ĊĠĠĠĠĠĠĠ Ġ// assertEquals ( replace Decimal Sep ("- 1 . 0 0 "), ĠCurrency Util . format GT U (- 1 0 0 0 0 , Ġwith G Stroke Ġ= Ġtrue )) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġto GT U Value () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 2 3 4 5 6 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 2 3 4 5 6 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 0 0 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" 1 . 0 0 . 0 0 . 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , ĠCurrency Util . to GT U Value ( replace Decimal Sep (" abc "))) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 2 3 4 5 6 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 2 3 4 5 6 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals (- 1 0 0 0 0 0 0 L , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 0 0 0 0 0 "))) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , ĠCurrency Util . to GT U Value ( replace Decimal Sep ("- 1 . 0 0 . 0 0 . 0 0 "))) ĊĊĠĠĠ Ġ} Ċ } Ċ