2016-12-11 14:33:05 +01:00
|
|
|
package count
|
|
|
|
|
2016-12-11 14:50:01 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
2016-12-11 14:33:05 +01:00
|
|
|
|
2018-04-27 17:28:03 +02:00
|
|
|
"github.com/usefathom/fathom/pkg/models"
|
|
|
|
)
|
2016-12-26 11:43:50 +02:00
|
|
|
|
|
|
|
func TestCalculatePointPercentages(t *testing.T) {
|
2018-05-02 14:52:52 +02:00
|
|
|
totals := []*models.Total{
|
|
|
|
&models.Total{
|
|
|
|
Value: "Foo",
|
|
|
|
Count: 5,
|
2016-12-26 11:43:50 +02:00
|
|
|
},
|
|
|
|
}
|
2016-12-11 14:33:05 +01:00
|
|
|
|
2018-05-02 14:52:52 +02:00
|
|
|
totals = calculatePercentagesOfTotal(totals, 100)
|
2016-12-26 11:43:50 +02:00
|
|
|
|
2018-05-02 14:52:52 +02:00
|
|
|
if totals[0].PercentageOfTotal != 5.00 {
|
|
|
|
t.Errorf("Percentage value should be 5.00, is %.2f", totals[0].PercentageOfTotal)
|
2016-12-26 11:43:50 +02:00
|
|
|
}
|
2016-12-11 14:33:05 +01:00
|
|
|
}
|