Skip to content

Commit

Permalink
Add test with real IPO data
Browse files Browse the repository at this point in the history
  • Loading branch information
markwinter committed Dec 21, 2024
1 parent 8d6b08c commit 060e0f1
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions itch/5.0/ipo_quotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,47 @@ func TestMakeAndParseIpoQuotation(t *testing.T) {
t.Errorf("parsed event and original event are not equal:\n%v", cmp.Diff(m, parsedEvent))
}
}

func TestParseIpoQuotation(t *testing.T) {
bdtxTimestamp, _ := time.ParseDuration("8h25m39.142161035s")

type args struct {
data []byte
}
tests := []struct {
name string
args args
want IpoQuotation
wantErr bool
}{
{
name: "BDTX IPO",
args: args{
// Real data taken from an ITCH file
data: []byte{75, 0, 0, 0, 0, 27, 151, 225, 202, 146, 139, 66, 68, 84, 88, 32, 32, 32, 32, 0, 0, 142, 248, 65, 0, 2, 230, 48},
},
want: IpoQuotation{
StockLocate: 0,
TrackingNumber: 0,
Stock: "BDTX",
Timestamp: bdtxTimestamp,
ReleaseTime: 36600 * time.Second,
Qualifier: QUALIFIER_ANTICIPATED,
Price: udecimal.MustParse("19.0000"),
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ParseIpoQuotation(tt.args.data)
if (err != nil) != tt.wantErr {
t.Errorf("ParseIpoQuotation() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !cmp.Equal(got, tt.want) {
t.Errorf("%v", cmp.Diff(tt.want, got))
}
})
}
}

0 comments on commit 060e0f1

Please sign in to comment.