i am so pleased
This commit is contained in:
@@ -105,3 +105,33 @@ func TestGetMonthlyContributionRate(t *testing.T) {
|
||||
t.Error(got["y"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewContributionPredictor(t *testing.T) {
|
||||
name := "x"
|
||||
currency := ledger.USD
|
||||
predictor := newContributionPredictor(map[string]ledger.Balance{
|
||||
name: {currency: 10},
|
||||
"y": {"XYZ": 3},
|
||||
})
|
||||
month := time.Hour * 24 * 365 / 12
|
||||
|
||||
if got := predictor(ledger.Balances{}, 2*month); got[name][currency] != 20 {
|
||||
t.Error(got[name])
|
||||
} else if got["y"]["XYZ"] != 6 {
|
||||
t.Error(got["y"])
|
||||
}
|
||||
|
||||
if got := predictor(ledger.Balances{name: {currency: 30}}, 2*month); got[name][currency] != 30+20 {
|
||||
t.Error(got)
|
||||
} else if got["y"]["XYZ"] != 6 {
|
||||
t.Error(got["y"])
|
||||
}
|
||||
|
||||
if got := predictor(ledger.Balances{"z": {"ABC": 100}}, 2*month); got[name][currency] != 20 {
|
||||
t.Error(got)
|
||||
} else if got["y"]["XYZ"] != 6 {
|
||||
t.Error(got["y"])
|
||||
} else if got["z"]["ABC"] != 100 {
|
||||
t.Error(got["z"])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user