ana-ledger/ledger/delta_test.go

42 lines
709 B
Go

package ledger
import (
"testing"
)
func TestDelta(t *testing.T) {
d := "2099-08-07"
delta := newDelta(d, "", "name", 34.56, "$")
if delta.Date != d {
t.Error(delta.Date)
}
if delta.Account != "name" {
t.Error(delta.Account)
}
if delta.Value != 34.56 {
t.Error(delta.Value)
}
if delta.Currency != USD {
t.Error(delta.Currency)
}
t.Log(delta)
d2 := "2099-09-08"
delta2 := newDelta(d2, "", "name", 11.11, "$")
combined := delta.Plus(delta2)
if combined.Date != d2 {
t.Error(combined.Date)
}
if combined.Account != "name" {
t.Error(combined.Account)
}
if combined.Value != 45.67 {
t.Error(combined.Value)
}
if combined.Currency != USD {
t.Error(combined.Currency)
}
}