package ledger import ( "testing" "time" ) func TestDelta(t *testing.T) { d, err := time.Parse("2006-01-02", "2099-08-07") if err != nil { t.Fatal(err) } 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, _ := time.Parse("2006-01-02", "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) } }