import test from 'ava' ; import { Amount } from '../..' ; test ( 'toString' , ( c ) => { const t = ( expected , n , fixed ) => { c . is ( new Amount ( n , 100 ) . toString ( 100 , { fixed } ) , expected ) ; } ; t ( '100.0' , 99.9512986 , 1 ) ; t ( '10.0' , 9.95036 , 1 ) ; t ( '1.0' , 0.99 , 1 ) ; t ( '0.10' , 0.09906 , 2 ) ; t ( '0.010' , 0.0098034 , 3 ) ; t ( '0.1' , 0.1 , 1 ) ; t ( '0.10' , 0.1 , 2 ) ; t ( '0.100' , 0.1 , 3 ) ; t ( '0.01' , 0.01 , 2 ) ; t ( '0.010' , 0.01 , 3 ) ; t ( '0.0100' , 0.01 , 4 ) ; t ( '0.00' , 0.001 , 2 ) ; t ( '0.001' , 0.001 , 3 ) ; t ( '0.0010' , 0.001 , 4 ) ; t ( '1.0000' , 1 , 4 ) ; t ( '1.0' , 1 , 1 ) ; t ( '0.0000006' , 0.0000006 , 7 ) ; t ( '0.00000006' , 0.00000006 , 8 ) ; t ( '0.000000060' , 0.00000006 , 9 ) ; t ( '0.0000000600' , 0.00000006 , 10 ) ; t ( '0.0' , 0 , 1 ) ; t ( '0.00' , 0 , 2 ) ; t ( '-1111111111111111111111.00000000' , '-1111111111111111111111' , 8 ) ; t ( '-0.1' , - 0.1 , 1 ) ; t ( '-0.10' , - 0.1 , 2 ) ; t ( '-0.100' , - 0.1 , 3 ) ; t ( '-0.01' , - 0.01 , 2 ) ; t ( '-0.010' , - 0.01 , 3 ) ; t ( '-0.0100' , - 0.01 , 4 ) ; t ( '-0.00' , - 0.001 , 2 ) ; t ( '-0.001' , - 0.001 , 3 ) ; t ( '-0.0010' , - 0.001 , 4 ) ; t ( '-1.0000' , - 1 , 4 ) ; t ( '-1.0' , - 1 , 1 ) ; t ( '-0.00000' , - 0.0000006 , 5 ) ; t ( '-0.0000006' , - 0.0000006 , 7 ) ; t ( '-0.00000006' , - 0.00000006 , 8 ) ; t ( '-0.000000060' , - 0.00000006 , 9 ) ; t ( '-0.0000000600' , - 0.00000006 , 10 ) ; t ( '0.0' , - 0 , 1 ) ; t ( '0.00' , - 0 , 2 ) ; t ( '0.00' , '-0.0' , 2 ) ; t ( '0.00' , '-0.0000' , 2 ) ; t ( '0.0000' , - 0 , 4 ) ; t ( '0.00001' , 0.00001 , 5 ) ; t ( '0.00000000000000000010' , '0.0000000000000000001' , 20 ) ; t ( '0.00001000000000000' , 0.00001 , 17 ) ; t ( '1.00000000000000000' , 1 , 17 ) ; t ( '100000000000000128.0' , '100000000000000128' , 1 ) ; t ( '10000000000000128.00' , '10000000000000128' , 2 ) ; t ( '10000000000000128.00000000000000000000' , '10000000000000128' , 20 ) ; t ( '-42.000' , - 42 , 3 ) ; t ( '-0.00000000000000000010' , '-0.0000000000000000001' , 20 ) ; t ( '0.12312312312312300000' , '0.123123123123123' , 20 ) ; t ( '1.3' , 1.25 , 1 ) ; t ( '234.2041' , 234.20405 , 4 ) ; t ( '234.2041' , '234.204050000000000000000000000000006' , 4 ) ; t ( '733744593401073823825766410831877679446.0000000000000000000' , '733744593401073823825766410831877679446' , 19 ) ; t ( '-64.6849459' , '-64.6849458687691227978' , 7 ) ; t ( '-0.000000' , '-0.00000000009' , 6 ) ; t ( '-62537287527837589298857228059657673223234916.95923265430000000' , '-62537287527837589298857228059657673223234916.9592326543' , 17 ) ; t ( '3393668096256773847245721315080265089731.000000' , '3393668096256773847245721315080265089731' , 6 ) ; t ( '0.0' , '0.0000000000000056674956638008432348702401392' , 1 ) ; t ( '72516372734.6' , '72516372734.6447' , 1 ) ; t ( '-418.28' , '-418.2800731793741351' , 2 ) ; t ( '0.00' , '0.001' , 2 ) ; t ( '8366217346845756726.00000000' , '8366217346845756726' , 8 ) ; t ( '-0.000000' , '-0.0000000000000092034548636370987112234384736726' , 6 ) ; t ( '0.35' , '0.35474830751442135112334772517193392' , 2 ) ; t ( '64703289793894.5830' , '64703289793894.58296866' , 4 ) ; t ( '-0.000000000000000036' , '-0.000000000000000036461242408590182363418943891' , 18 ) ; t ( '5494508405056449117588.631948' , '5494508405056449117588.631948458033233759999' , 6 ) ; t ( '-0.0' , '-0.00393971618499838726739122333520030506235698' , 1 ) ; t ( '375581290738585826632.00000000' , '375581290738585826632' , 8 ) ; t ( '254.96635275802300887' , '254.96635275802300886544776010389418575738792480979736' , 17 ) ; t ( '21492347.69467571391498624445' , '21492347.6946757139149862444482880595559468' , 20 ) ; t ( '313576441324233.0000000' , '313576441324233' , 7 ) ; t ( '-534460490015293367127173277346694900936058.0000' , '-534460490015293367127173277346694900936058' , 4 ) ; t ( '182707431911537249021116759327712693311898345504618668.43327000000000000000000' , '182707431911537249021116759327712693311898345504618668.43327' , 23 ) ; t ( '210005324615278.4586839690045963321032' , '210005324615278.458683969004596332103244549279' , 22 ) ; t ( '779837001772884165637922377221951347134695.644834' , '779837001772884165637922377221951347134695.6448338' , 6 ) ; t ( '-0.000001' , '-0.00000064188301390033596845335767993853284632527964514979079' , 6 ) ; t ( '13.0' , '13' , 1 ) ; t ( '0.0000001269' , '0.0000001269060795648365813491128357427111184222' , 10 ) ; t ( '18446632248354.00' , '18446632248354' , 2 ) ; t ( '-1229249.79' , '-1229249.7897249259' , 2 ) ; t ( '49082.0' , '49082' , 1 ) ; t ( '-61.0' , '-61' , 1 ) ; t ( '-893.0' , '-893' , 1 ) ; t ( '5002282278.56974877690066484' , '5002282278.569748776900664839184116538222902' , 17 ) ; t ( '41372.00' , '41372' , 2 ) ; t ( '-4732022445962399687294885123498809.7625585825095' , '-4732022445962399687294885123498809.7625585825095' , 13 ) ; t ( '-55484242.036895641' , '-55484242.036895641' , 9 ) ; t ( '-41427133134.52583323427907663268339' , '-41427133134.525833234279076632683393992706825' , 23 ) ; t ( '0.0' , '0.00004300614085218825243480119971669264977421' , 1 ) ; t ( '-472025754597316278339412186866.7010659789' , '-472025754597316278339412186866.701065978877597089729906019843' , 10 ) ; } ) ;