From e3c4afc0a3dd078004837439a5dd314ac684042a Mon Sep 17 00:00:00 2001 From: David Bartley Date: Tue, 14 Mar 2023 18:00:56 -0700 Subject: [PATCH] Add `SecurityInfo()` and `InvPosition()` tests. --- invstmt_test.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/invstmt_test.go b/invstmt_test.go index b943ed7..a4f1027 100644 --- a/invstmt_test.go +++ b/invstmt_test.go @@ -1866,3 +1866,47 @@ func TestUnmarshalOOList(t *testing.T) { } checkEqual(t, "OOList", reflect.ValueOf(&expected), reflect.ValueOf(&actual)) } + +func TestSecurityInfo(t *testing.T) { + secInfo := SecInfo{ + Ticker: "ABC", + } + tests := []Security{ + DebtInfo{SecInfo: secInfo}, + MFInfo{SecInfo: secInfo}, + OptInfo{SecInfo: secInfo}, + OtherInfo{SecInfo: secInfo}, + StockInfo{SecInfo: secInfo}, + } + + for _, tc := range tests { + t.Run(tc.SecurityType(), func(t *testing.T) { + info := tc.SecurityInfo() + if info.Ticker != secInfo.Ticker { + t.Errorf("got %v, want %v", info, secInfo) + } + }) + } +} + +func TestInvPosition(t *testing.T) { + invPos := InvPosition{ + Memo: "stuff", + } + tests := []Position{ + DebtPosition{InvPos: invPos}, + MFPosition{InvPos: invPos}, + OptPosition{InvPos: invPos}, + OtherPosition{InvPos: invPos}, + StockPosition{InvPos: invPos}, + } + + for _, tc := range tests { + t.Run(tc.PositionType(), func(t *testing.T) { + pos := tc.InvPosition() + if pos.Memo != invPos.Memo { + t.Errorf("got %v, want %v", pos, invPos) + } + }) + } +}