test balances zeroing and unzeroing

This commit is contained in:
Bel LaPointe
2023-10-25 08:06:41 -06:00
parent fb2ed278c2
commit 0b945df7e8
2 changed files with 20 additions and 0 deletions

View File

@@ -3,6 +3,23 @@ package ledger
import "testing"
func TestDeltas(t *testing.T) {
t.Run("balances", func(t *testing.T) {
deltas := Deltas{
{Name: "a", Value: 0},
{Name: "b", Value: 1},
{Name: "b", Value: -.999999999999999999999999},
{Name: "b", Value: 1.3},
}
balances := deltas.Balances()
if len(balances) != 1 {
t.Error(len(balances), balances)
}
if balances["b"][""] != 1.3 {
t.Error(balances["b"])
}
})
t.Run("register", func(t *testing.T) {
deltas := Deltas{
{Date: "a", Value: 0.1},