@@ -36,9 +36,12 @@ void main() {
3636 test ('calculates positive relative growth rate for positive trend' , () {
3737 // Input list (newest first): [1645, 1635, ..., 1355] (30 values)
3838 // Average = 1500 for the first 30 values. Slope: 10.
39- final downloads =
40- List <int >.generate (analysisWindowDays * 2 , (i) => 1645 - (i * 10 ));
41- final expectedRate = 10.0 / 1500.0 ;
39+ final downloads = < int > [
40+ ...List <int >.generate (analysisWindowDays * 2 , (i) => 1645 - (i * 10 )),
41+ ...List .filled (300 , 0 )
42+ ];
43+ final avg = downloads.reduce ((prev, element) => prev + element) / 330 ;
44+ final expectedRate = 10.0 / avg;
4245 expect (computeRelativeGrowthRate (downloads), expectedRate);
4346 });
4447
@@ -107,10 +110,10 @@ void main() {
107110 final downloads = [100 , 50 ];
108111 // For relativeGrowth:
109112 // Padded data: [100, 50, 0...0] (28 zeros)
110- // avg = 150/30 = 5
113+ // avg = (100 + 50) / 2 = 75.
111114 // growthRate = 63750 / 67425
112115 final expectedDampening = min (1.0 , 150 / 30000 );
113- final expectedRelativeGrowth = 63750 / 67425 / 5 ;
116+ final expectedRelativeGrowth = ( 63750 / 67425 ) / 75 ;
114117 final expectedScore =
115118 expectedRelativeGrowth * expectedDampening * expectedDampening;
116119 expect (computeTrendScore (downloads), expectedScore);
@@ -178,7 +181,7 @@ void main() {
178181 test ('Short history, high sum meets threshold -> no dampening' , () {
179182 final downloads = List <int >.filled (15 , 2000 );
180183 final expectedDampening = min (1.0 , 30000 / 30000 );
181- final expectedRelativeGrowth = 6750000 / 67425 / 1000 ;
184+ final expectedRelativeGrowth = ( 6750000 / 67425 ) / 2000 ;
182185 final expectedScore =
183186 expectedRelativeGrowth * expectedDampening * expectedDampening;
184187
0 commit comments