本文整理汇总了Golang中github.com/quickfixgo/quickfix/datadictionary.Parse函数的典型用法代码示例。如果您正苦于以下问题:Golang Parse函数的具体用法?Golang Parse怎么用?Golang Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: tcFieldNotFoundBody
func tcFieldNotFoundBody() validateTest {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
validator := &fixValidator{dict, defaultValidatorSettings}
invalidMsg1 := NewMessage()
invalidMsg1.Header.SetField(tagMsgType, FIXString("D")).
SetField(tagBeginString, FIXString("FIX.4.0")).
SetField(tagBodyLength, FIXString("0")).
SetField(tagSenderCompID, FIXString("0")).
SetField(tagTargetCompID, FIXString("0")).
SetField(tagMsgSeqNum, FIXString("0")).
SetField(tagSendingTime, FIXUTCTimestamp{Time: time.Now()})
invalidMsg1.Trailer.SetField(tagCheckSum, FIXString("000"))
invalidMsg1.Body.SetField(Tag(11), FIXString("A")).
SetField(Tag(21), FIXString("A")).
SetField(Tag(55), FIXString("A")).
SetField(Tag(54), FIXString("A")).
SetField(Tag(38), FIXString("A"))
tag := Tag(40)
//ord type is required
//invalidMsg1.Body.SetField(Tag(40), "A"))
msgBytes := invalidMsg1.build()
return validateTest{
TestName: "FieldNotFoundBody",
Validator: validator,
MessageBytes: msgBytes,
ExpectedRejectReason: rejectReasonRequiredTagMissing,
ExpectedRefTagID: &tag,
}
}
示例2: tcFieldNotFoundHeader
func tcFieldNotFoundHeader() validateTest {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
validator := &fixValidator{dict, defaultValidatorSettings}
invalidMsg2 := NewMessage()
invalidMsg2.Trailer.SetField(tagCheckSum, FIXString("000"))
invalidMsg2.Body.SetField(Tag(11), FIXString("A")).
SetField(Tag(21), FIXString("A")).
SetField(Tag(55), FIXString("A")).
SetField(Tag(54), FIXString("A")).
SetField(Tag(38), FIXString("A"))
invalidMsg2.Header.SetField(tagMsgType, FIXString("D")).
SetField(tagBeginString, FIXString("FIX.4.0")).
SetField(tagBodyLength, FIXString("0")).
SetField(tagSenderCompID, FIXString("0")).
SetField(tagTargetCompID, FIXString("0")).
SetField(tagMsgSeqNum, FIXString("0"))
//sending time is required
//invalidMsg2.Header.FieldMap.SetField(tag.SendingTime, "0"))
tag := tagSendingTime
msgBytes, _ := invalidMsg2.Build()
return validateTest{
TestName: "FieldNotFoundHeader",
Validator: validator,
MessageBytes: msgBytes,
ExpectedRejectReason: rejectReasonRequiredTagMissing,
ExpectedRefTagID: &tag,
}
}
示例3: TestValidateInvalidTagNumber
func (s *ValidationTests) TestValidateInvalidTagNumber(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Header().Set(fix.NewStringField(9999, "hello"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonInvalidTagNumber)
c.Check(*reject.RefTagID(), Equals, fix.Tag(9999))
builder = s.createFIX40NewOrderSingle()
builder.Trailer().Set(fix.NewStringField(9999, "hello"))
msgBytes, _ = builder.Build()
msg, _ = parseMessage(msgBytes)
reject = validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonInvalidTagNumber)
c.Check(*reject.RefTagID(), Equals, fix.Tag(9999))
builder = s.createFIX40NewOrderSingle()
builder.Body().Set(fix.NewStringField(9999, "hello"))
msgBytes, _ = builder.Build()
msg, _ = parseMessage(msgBytes)
reject = validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonInvalidTagNumber)
c.Check(*reject.RefTagID(), Equals, fix.Tag(9999))
}
示例4: TestFloatValidation
func (s *ValidationTests) TestFloatValidation(c *C) {
msg, err := parseMessage([]byte("8=FIX.4.29=10635=D34=249=TW52=20140329-22:38:4556=ISLD11=ID21=140=154=138=+200.0055=INTC60=20140329-22:38:4510=178"))
c.Check(err, IsNil)
dict, _ := datadictionary.Parse("spec/FIX42.xml")
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonIncorrectDataFormatForValue)
}
示例5: TestValidateTagNotDefinedForMessageComponent
func (s *ValidationTests) TestValidateTagNotDefinedForMessageComponent(c *C) {
dict, err := datadictionary.Parse("spec/FIX43.xml")
c.Check(err, IsNil)
builder := s.createFIX43NewOrderSingle()
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, IsNil)
}
示例6: TestValidateFieldNotFound
func (s *ValidationTests) TestValidateFieldNotFound(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := NewMessageBuilder()
builder.Header().Set(fix.NewStringField(tag.MsgType, "D"))
builder.Header().Set(fix.NewStringField(tag.BeginString, "FIX.4.0"))
builder.Header().Set(fix.NewStringField(tag.BodyLength, "0"))
builder.Header().Set(fix.NewStringField(tag.SenderCompID, "0"))
builder.Header().Set(fix.NewStringField(tag.TargetCompID, "0"))
builder.Header().Set(fix.NewStringField(tag.MsgSeqNum, "0"))
builder.Header().Set(fix.NewUTCTimestampField(tag.SendingTime, time.Now()))
builder.Trailer().Set(fix.NewStringField(tag.CheckSum, "000"))
builder.Body().Set(fix.NewStringField(tag.ClOrdID, "A"))
builder.Body().Set(fix.NewStringField(tag.HandlInst, "A"))
builder.Body().Set(fix.NewStringField(tag.Symbol, "A"))
builder.Body().Set(fix.NewStringField(tag.Side, "A"))
builder.Body().Set(fix.NewStringField(tag.OrderQty, "A"))
//ord type is required
//builder.Body().Set(fix.NewStringField(tag.OrdType, "A"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonRequiredTagMissing)
c.Check(*reject.RefTagID(), Equals, tag.OrdType)
builder = NewMessageBuilder()
builder.Trailer().Set(fix.NewStringField(tag.CheckSum, "000"))
builder.Body().Set(fix.NewStringField(tag.ClOrdID, "A"))
builder.Body().Set(fix.NewStringField(tag.HandlInst, "A"))
builder.Body().Set(fix.NewStringField(tag.Symbol, "A"))
builder.Body().Set(fix.NewStringField(tag.Side, "A"))
builder.Body().Set(fix.NewStringField(tag.OrderQty, "A"))
builder.Header().Set(fix.NewStringField(tag.MsgType, "D"))
builder.Header().Set(fix.NewStringField(tag.BeginString, "FIX.4.0"))
builder.Header().Set(fix.NewStringField(tag.BodyLength, "0"))
builder.Header().Set(fix.NewStringField(tag.SenderCompID, "0"))
builder.Header().Set(fix.NewStringField(tag.TargetCompID, "0"))
builder.Header().Set(fix.NewStringField(tag.MsgSeqNum, "0"))
//sending time is required
//msg.Header.FieldMap.Set(fix.NewStringField(tag.SendingTime, "0"))
msgBytes, _ = builder.Build()
msg, _ = parseMessage(msgBytes)
reject = validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonRequiredTagMissing)
c.Check(*reject.RefTagID(), Equals, tag.SendingTime)
}
示例7: TestValidateTagAppearsMoreThanOnce
func (s *ValidationTests) TestValidateTagAppearsMoreThanOnce(c *C) {
msg, err := parseMessage([]byte("8=FIX.4.09=10735=D34=249=TW52=20060102-15:04:0556=ISLD11=ID21=140=140=254=138=20055=INTC60=20060102-15:04:0510=234"))
c.Check(err, IsNil)
dict, _ := datadictionary.Parse("spec/FIX40.xml")
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonTagAppearsMoreThanOnce)
c.Check(*reject.RefTagID(), Equals, tag.OrdType)
}
示例8: TestValidateValueIsIncorrect
func (s *ValidationTests) TestValidateValueIsIncorrect(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Body().Set(fix.NewStringField(tag.HandlInst, "4"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonValueIsIncorrect)
c.Check(*reject.RefTagID(), Equals, tag.HandlInst)
}
示例9: TestValidateInvalidMsgType
func (s *ValidationTests) TestValidateInvalidMsgType(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Header().Set(fix.NewStringField(tag.MsgType, "z"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonInvalidMsgType)
}
示例10: TestValidateTagSpecifiedWithoutAValue
func (s *ValidationTests) TestValidateTagSpecifiedWithoutAValue(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Body().Set(fix.NewStringField(tag.ClientID, ""))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonTagSpecifiedWithoutAValue)
c.Check(*reject.RefTagID(), Equals, tag.ClientID)
}
示例11: TestValidateIncorrectDataFormatForValue
func (s *ValidationTests) TestValidateIncorrectDataFormatForValue(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Body().Set(fix.NewStringField(tag.OrderQty, "+200.00"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonIncorrectDataFormatForValue)
c.Check(*reject.RefTagID(), Equals, tag.OrderQty)
}
示例12: tcFloatValidation
func tcFloatValidation() validateTest {
dict, _ := datadictionary.Parse("spec/FIX42.xml")
validator := &fixValidator{dict, defaultValidatorSettings}
tag := Tag(38)
return validateTest{
TestName: "FloatValidation",
Validator: validator,
MessageBytes: []byte("8=FIX.4.29=10635=D34=249=TW52=20140329-22:38:4556=ISLD11=ID21=140=154=138=+200.0055=INTC60=20140329-22:38:4510=178"),
ExpectedRejectReason: rejectReasonIncorrectDataFormatForValue,
ExpectedRefTagID: &tag,
}
}
示例13: TestValidateTagNotDefinedForMessage
func (s *ValidationTests) TestValidateTagNotDefinedForMessage(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
builder.Body().Set(fix.NewStringField(41, "hello"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonTagNotDefinedForThisMessageType)
c.Check(*reject.RefTagID(), Equals, fix.Tag(41))
}
示例14: tcTagAppearsMoreThanOnce
func tcTagAppearsMoreThanOnce() validateTest {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
validator := &fixValidator{dict, defaultValidatorSettings}
tag := Tag(40)
return validateTest{
TestName: "Tag appears more than once",
Validator: validator,
MessageBytes: []byte("8=FIX.4.09=10735=D34=249=TW52=20060102-15:04:0556=ISLD11=ID21=140=140=254=138=20055=INTC60=20060102-15:04:0510=234"),
ExpectedRejectReason: rejectReasonTagAppearsMoreThanOnce,
ExpectedRefTagID: &tag,
}
}
示例15: TestValidateTagSpecifiedOutOfRequiredOrder
func (s *ValidationTests) TestValidateTagSpecifiedOutOfRequiredOrder(c *C) {
dict, _ := datadictionary.Parse("spec/FIX40.xml")
builder := s.createFIX40NewOrderSingle()
//should be in header
builder.Body().Set(fix.NewStringField(tag.OnBehalfOfCompID, "CWB"))
msgBytes, _ := builder.Build()
msg, _ := parseMessage(msgBytes)
reject := validate(dict, *msg)
c.Check(reject, NotNil)
c.Check(reject.RejectReason(), Equals, rejectReasonTagSpecifiedOutOfRequiredOrder)
c.Check(*reject.RefTagID(), Equals, tag.OnBehalfOfCompID)
}