ana register to contributions

This commit is contained in:
bel
2023-10-26 20:07:23 -06:00
parent d93a3560da
commit 6c31005d24
2 changed files with 66 additions and 0 deletions

View File

@@ -41,3 +41,48 @@ func TestNewInterestPredictor(t *testing.T) {
})
}
}
func TestGetContributions(t *testing.T) {
input := ledger.Register{
"2001-01": ledger.Balances{
"a": ledger.Balance{"x": 1},
"b": ledger.Balance{"z": 1},
},
"2001-02": ledger.Balances{
"a": ledger.Balance{"y": 1},
},
"2001-03": ledger.Balances{
"b": ledger.Balance{"z": 2},
},
}
got := getContributions(input)
if len(got) != 2 {
t.Error(len(got))
}
if len(got["a"]) != 2 {
t.Error(len(got["a"]))
} else if len(got["a"][0]) != 1 {
t.Error(got["a"])
} else if got["a"][0]["x"] != 1 {
t.Error(got["a"][0])
} else if len(got["a"][1]) != 2 {
t.Error(got["a"][1])
} else if got["a"][1]["x"] != -1 {
t.Error(got["a"][1]["x"])
} else if got["a"][1]["y"] != 1 {
t.Error(got["a"][1]["y"])
}
if len(got["b"]) != 2 {
t.Error(len(got["b"]))
} else if len(got["b"][0]) != 1 {
t.Error(got["b"])
} else if got["b"][0]["z"] != 1 {
t.Error(got["b"][0])
} else if len(got["b"][1]) != 1 {
t.Error(got["b"][1])
} else if got["b"][1]["z"] != 1 {
t.Error(got["b"][1]["z"])
}
}