• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang datadictionary.Parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/quickfixgo/quickfix/datadictionary.Parse函数的典型用法代码示例。如果您正苦于以下问题:Golang Parse函数的具体用法?Golang Parse怎么用?Golang Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,
	}
}
开发者ID:quickfixgo,项目名称:quickfix,代码行数:33,代码来源:validation_test.go


示例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,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:32,代码来源:validation_test.go


示例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))
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:32,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:9,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:10,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:54,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:11,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:12,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:12,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:12,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:12,代码来源:validation_test.go


示例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,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:12,代码来源:validation_test.go


示例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))
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:13,代码来源:validation_test.go


示例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,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:13,代码来源:validation_test.go


示例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)
}
开发者ID:jarlwolfganger,项目名称:quickfix,代码行数:13,代码来源:validation_test.go


示例16: tcInvalidMsgType

func tcInvalidMsgType() validateTest {
	dict, _ := datadictionary.Parse("spec/FIX40.xml")
	validator := &fixValidator{dict, defaultValidatorSettings}
	builder := createFIX40NewOrderSingle()
	builder.Header.SetField(tagMsgType, FIXString("z"))
	msgBytes, _ := builder.Build()

	return validateTest{
		TestName:             "Invalid MsgType",
		Validator:            validator,
		MessageBytes:         msgBytes,
		ExpectedRejectReason: rejectReasonInvalidMsgType,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:14,代码来源:validation_test.go


示例17: tcTagIsDefinedForMessage

func tcTagIsDefinedForMessage() validateTest {
	//compare to tcTagIsNotDefinedForMessage
	dict, _ := datadictionary.Parse("spec/FIX43.xml")
	validator := &fixValidator{dict, defaultValidatorSettings}
	validMsg := createFIX43NewOrderSingle()
	msgBytes, _ := validMsg.Build()

	return validateTest{
		TestName:          "TagIsDefinedForMessage",
		Validator:         validator,
		MessageBytes:      msgBytes,
		DoNotExpectReject: true,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:14,代码来源:validation_test.go


示例18: tcIncorrectDataFormatForValue

func tcIncorrectDataFormatForValue() validateTest {
	dict, _ := datadictionary.Parse("spec/FIX40.xml")
	validator := &fixValidator{dict, defaultValidatorSettings}
	builder := createFIX40NewOrderSingle()
	tag := Tag(38)
	builder.Body.SetField(tag, FIXString("+200.00"))
	msgBytes, _ := builder.Build()

	return validateTest{
		TestName:             "IncorrectDataFormatForValue",
		Validator:            validator,
		MessageBytes:         msgBytes,
		ExpectedRejectReason: rejectReasonIncorrectDataFormatForValue,
		ExpectedRefTagID:     &tag,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:16,代码来源:validation_test.go


示例19: tcTagNotDefinedForMessage

func tcTagNotDefinedForMessage() validateTest {
	dict, _ := datadictionary.Parse("spec/FIX40.xml")
	validator := &fixValidator{dict, defaultValidatorSettings}
	invalidMsg := createFIX40NewOrderSingle()
	tag := Tag(41)
	invalidMsg.Body.SetField(tag, FIXString("hello"))
	msgBytes, _ := invalidMsg.Build()

	return validateTest{
		TestName:             "Tag Not Defined For Message",
		Validator:            validator,
		MessageBytes:         msgBytes,
		ExpectedRejectReason: rejectReasonTagNotDefinedForThisMessageType,
		ExpectedRefTagID:     &tag,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:16,代码来源:validation_test.go


示例20: tcInvalidTagNumberTrailer

func tcInvalidTagNumberTrailer() validateTest {
	dict, _ := datadictionary.Parse("spec/FIX40.xml")
	validator := &fixValidator{dict, defaultValidatorSettings}
	invalidTrailerFieldMessage := createFIX40NewOrderSingle()
	tag := Tag(9999)
	invalidTrailerFieldMessage.Trailer.SetField(tag, FIXString("hello"))
	msgBytes, _ := invalidTrailerFieldMessage.Build()

	return validateTest{
		TestName:             "Invalid Tag Number Trailer",
		Validator:            validator,
		MessageBytes:         msgBytes,
		ExpectedRejectReason: rejectReasonInvalidTagNumber,
		ExpectedRefTagID:     &tag,
	}
}
开发者ID:cbusbey,项目名称:quickfix,代码行数:16,代码来源:validation_test.go



注:本文中的github.com/quickfixgo/quickfix/datadictionary.Parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang field.NewAccount函数代码示例发布时间:2022-05-28
下一篇:
Golang quickfix.SessionID类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap