package ledger

import (
	"testing"
	"time"
)

func TestRegisterBetween(t *testing.T) {
	reg := make(Register)
	reg["2001-01"] = make(Balances)
	reg["2002-01"] = make(Balances)
	reg["2003-01"] = make(Balances)
	reg["2004-01"] = make(Balances)
	reg["2005-01"] = make(Balances)

	start, _ := time.ParseInLocation("2006-01", "2002-01", time.Local)
	end, _ := time.ParseInLocation("2006-01", "2004-01", time.Local)
	got := reg.Between(start, end)
	if len(got) != 3 {
		t.Error(len(got))
	}
	if _, ok := got["2002-01"]; !ok {
		t.Error("2002-01")
	}
	if _, ok := got["2003-01"]; !ok {
		t.Error("2003-01")
	}
	if _, ok := got["2004-01"]; !ok {
		t.Error("2004-01")
	}
}
