17 lines
496 B
Go
17 lines
496 B
Go
package repository
|
|
|
|
import "testing"
|
|
|
|
func TestAbsoluteSharesToPercentagesMatchesLaravel(t *testing.T) {
|
|
result := absoluteSharesToPercentages([4]float64{50000, 30000, 10000, 10000}, 100000)
|
|
expected := [4]float64{50, 30, 10, 10}
|
|
if result != expected {
|
|
t.Fatalf("shares = %v, want %v", result, expected)
|
|
}
|
|
|
|
withRounding := absoluteSharesToPercentages([4]float64{1, 1, 1, 0}, 3)
|
|
if withRounding != [4]float64{33.34, 33.33, 33.33, 0} {
|
|
t.Fatalf("rounded shares = %v", withRounding)
|
|
}
|
|
}
|