42 lines
697 B
Go
42 lines
697 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.Name != "name" {
|
|
t.Error(delta.Name)
|
|
}
|
|
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.Name != "name" {
|
|
t.Error(combined.Name)
|
|
}
|
|
if combined.Value != 45.67 {
|
|
t.Error(combined.Value)
|
|
}
|
|
if combined.Currency != USD {
|
|
t.Error(combined.Currency)
|
|
}
|
|
}
|