@@ -29,4 +29,41 @@ void main() {
2929 expect (formatWithSuffix (999999 + 1 ), '1.0m' );
3030 expect (formatWithSuffix (1234000 ), '1.2m' );
3131 });
32+
33+ test ('Significant digit 0-999' , () {
34+ expect (computeWith3SignificantDigits (0 ), (value: '0' , suffix: '' ));
35+ expect (computeWith3SignificantDigits (1 ), (value: '1' , suffix: '' ));
36+ expect (computeWith3SignificantDigits (23 ), (value: '23' , suffix: '' ));
37+ expect (computeWith3SignificantDigits (999 ), (value: '999' , suffix: '' ));
38+ });
39+
40+ test ('Significant digit 1000-999499' , () {
41+ expect (computeWith3SignificantDigits (1000 ), (value: '1.00' , suffix: 'k' ));
42+ expect (computeWith3SignificantDigits (1049 ), (value: '1.05' , suffix: 'k' ));
43+ expect (computeWith3SignificantDigits (1051 ), (value: '1.05' , suffix: 'k' ));
44+ expect (computeWith3SignificantDigits (1100 ), (value: '1.10' , suffix: 'k' ));
45+ expect (computeWith3SignificantDigits (9500 ), (value: '9.50' , suffix: 'k' ));
46+ expect (computeWith3SignificantDigits (99500 ), (value: '99.5' , suffix: 'k' ));
47+ expect (computeWith3SignificantDigits (100490 ), (value: '100' , suffix: 'k' ));
48+ expect (computeWith3SignificantDigits (100500 ), (value: '101' , suffix: 'k' ));
49+ expect (computeWith3SignificantDigits (199500 ), (value: '200' , suffix: 'k' ));
50+ expect (computeWith3SignificantDigits (999499 ), (value: '999' , suffix: 'k' ));
51+ });
52+
53+ test ('Significant digit 999500-100000000' , () {
54+ expect (computeWith3SignificantDigits (999500 ), (value: '1.00' , suffix: 'M' ));
55+ expect (computeWith3SignificantDigits (999999 ), (value: '1.00' , suffix: 'M' ));
56+ expect (
57+ computeWith3SignificantDigits (900000000 ), (value: '900' , suffix: 'M' ));
58+ expect (
59+ computeWith3SignificantDigits (999500000 ), (value: '1.00' , suffix: 'B' ));
60+ expect (computeWith3SignificantDigits (1009450000 ),
61+ (value: '1.01' , suffix: 'B' ));
62+ expect (computeWith3SignificantDigits (1094599999 ),
63+ (value: '1.09' , suffix: 'B' ));
64+ expect (computeWith3SignificantDigits (1095000001 ),
65+ (value: '1.10' , suffix: 'B' ));
66+ expect (computeWith3SignificantDigits (19000000000 ),
67+ (value: '19.0' , suffix: 'B' ));
68+ });
3269}
0 commit comments