Skip to content

Commit

Permalink
add test for multiple repeating groups in a message
Browse files Browse the repository at this point in the history
partly revert change in quickfixgo#368 due to breaking the unit test added in this PR
  • Loading branch information
albert committed Apr 10, 2024
1 parent 3bf2b87 commit 1b77d53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func validateWalk(transportDD *datadictionary.DataDictionary, appDD *datadiction
for len(remainingFields) > 0 {
field := remainingFields[0]
tag := field.tag

switch {
case tag.IsHeader():
messageDef = transportDD.Header
Expand Down Expand Up @@ -246,12 +246,11 @@ func validateVisitGroupField(fieldDef *datadictionary.FieldDef, fieldStack []Tag
if childDefs[0].Required() {
return fieldStack, RequiredTagMissing(Tag(childDefs[0].Tag()))
}
fieldStack = fieldStack[1:]
}

childDefs = childDefs[1:]
}

if groupCount != int(numInGroup) {
return fieldStack, incorrectNumInGroupCountForRepeatingGroup(numInGroupTag)
}
Expand Down
12 changes: 12 additions & 0 deletions validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestValidate(t *testing.T) {
tcInvalidTagCheckDisabledFixT(),
tcInvalidTagCheckEnabled(),
tcInvalidTagCheckEnabledFixT(),
tcMultipleRepeatingGroupFields(),
}

msg := NewMessage()
Expand Down Expand Up @@ -923,6 +924,17 @@ func tcFloatValidationFixT() validateTest {
}
}

func tcMultipleRepeatingGroupFields() validateTest {
dict, _ := datadictionary.Parse("spec/FIX43.xml")
validator := NewValidator(defaultValidatorSettings, dict, nil)
return validateTest{
TestName: "Multiple repeating group fields in a message",
Validator: validator,
MessageBytes: []byte("8=FIX.4.39=17635=D34=249=TW52=20140329-22:38:4556=ISLD11=ID453=2448=PARTYID452=3523=SUBID448=PARTYID2452=378=179=ACCOUNT80=121=140=154=138=20055=INTC60=20140329-22:38:4510=178"),
DoNotExpectReject: true,
}
}

func TestValidateVisitField(t *testing.T) {
fieldType0 := datadictionary.NewFieldType("myfield", 11, "STRING")
fieldDef0 := &datadictionary.FieldDef{FieldType: fieldType0}
Expand Down

0 comments on commit 1b77d53

Please sign in to comment.