Skip to content

Commit d591447

Browse files
committed
Failing unit test for message with repeating group
1 parent b9e203b commit d591447

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

message_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,29 @@ func (s *MessageSuite) TestReBuild() {
146146
s.True(bytes.Equal(s.msg.bodyBytes, expectedBodyBytes), "Incorrect body bytes, got %s", string(s.msg.bodyBytes))
147147
}
148148

149+
func (s *MessageSuite) TestRebuildWithRepeatingGroup() {
150+
151+
dict, dictErr := datadictionary.Parse("spec/FIX44.xml")
152+
s.Nil(dictErr)
153+
154+
// Given message bytes from a valid string
155+
rawMsg := bytes.NewBufferString("8=FIX.4.49=21035=D34=2347=UTF-852=20231231-20:19:4149=0100150=01001a56=TEST44=1211=139761=1010040021=1386=1336=NOPL55=SYMABC54=160=20231231-20:19:4138=140=259=0453=1448=4501447=D452=28354=6355=Public10=104")
156+
157+
// When we parse it into a message
158+
s.Nil(ParseMessageWithDataDictionary(s.msg, rawMsg, dict, dict))
159+
160+
// And then rebuild the message bytes
161+
rebuildBytes := s.msg.build()
162+
163+
// this method does result in test passing.
164+
//s.msg.buildWithBodyBytes(s.msg.bodyBytes)
165+
166+
expectedBytes := []byte("8=FIX.4.49=21035=D34=249=0100150=01001a52=20231231-20:19:4156=TEST347=UTF-844=1211=139761=1010040021=1386=1336=NOPL55=SYMABC54=160=20231231-20:19:4138=140=259=0453=1448=4501447=D452=28354=6355=Public10=104")
167+
168+
// Then the bytes should be the same with repeating group properly ordered
169+
s.True(bytes.Equal(expectedBytes, rebuildBytes), "Unexpected bytes,\n +%s\n -%s", rebuildBytes, expectedBytes)
170+
}
171+
149172
func (s *MessageSuite) TestReBuildWithRepeatingGroupForResend() {
150173
// Given the following message with a repeating group
151174
origHeader := "8=FIXT.1.19=16135=834=349=ISLD52=20240415-03:43:17.92356=TW"

0 commit comments

Comments
 (0)