当前位置: 首页>>代码示例>>Golang>>正文


Golang wipro.Reader类代码示例

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


在下文中一共展示了Reader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Unmarshal

func (t *ErrorInTopic) Unmarshal(r *wipro.Reader) {
	t.TopicName = r.ReadString()
	t.ErrorInPartitions = make([]ErrorInPartition, int(r.ReadInt32()))
	for i := range t.ErrorInPartitions {
		t.ErrorInPartitions[i].Unmarshal(r)
	}
}
开发者ID:AnotherGoogleFans,项目名称:kafka,代码行数:7,代码来源:marshal_auto.go

示例2: TestUnmarshal

func TestUnmarshal(t *testing.T) {
	t.Parallel()
	r := wipro.Reader{
		B: []byte{0x0, 0x0, 0x1, 0x7a, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x74, 0x65, 0x73, 0x74, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x1, 0x56, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2d, 0x9, 0xf8, 0xf8, 0x91, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x32, 0x30, 0x31, 0x35, 0x2d, 0x30, 0x39, 0x2d, 0x31, 0x35, 0x54, 0x32, 0x32, 0x3a, 0x31, 0x38, 0x3a, 0x30, 0x31, 0x2b, 0x30, 0x38, 0x3a, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0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6f, 0x20, 0x32, 0x30, 0x31, 0x35, 0x2d, 0x30, 0x39, 0x2d, 0x31, 0x35, 0x54, 0x32, 0x32, 0x3a, 0x31, 0x38, 0x3a, 0x35, 0x31, 0x2b, 0x30, 0x38, 0x3a, 0x30, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x2d, 0x13, 0x20, 0xd9, 0x52, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x32, 0x30, 0x31, 0x35, 0x2d, 0x30, 0x39, 0x2d, 0x31, 0x35, 0x54, 0x32, 0x32, 0x3a, 0x31, 0x38, 0x3a, 0x35, 0x34, 0x2b, 0x30, 0x38, 0x3a, 0x30, 0x30},
	}
	messageCount := 6
	{
		resp := FetchResponse{}
		(&RequestOrResponse{M: &Response{ResponseMessage: &resp}}).Unmarshal(&r)
		if r.Err != nil {
			t.Fatal(r.Err)
		}
		if len(resp) != 1 ||
			len(resp[0].FetchMessageSetInPartitions) != 1 ||
			len(resp[0].FetchMessageSetInPartitions[0].MessageSet) != messageCount {
			t.Fatal("fail to parse truncated message set")
		}
	}
	{
		r.Reset()
		size := r.ReadInt32()
		size -= 2
		r.B = r.B[:size+4]
		(&wipro.Writer{B: r.B}).SetInt32(0, size)
		r.Reset()
		messageCount--

		resp := FetchResponse{}
		(&RequestOrResponse{M: &Response{ResponseMessage: &resp}}).Unmarshal(&r)
		if r.Err != nil {
			t.Fatal(r.Err)
		}
		if len(resp) != 1 ||
			len(resp[0].FetchMessageSetInPartitions) != 1 ||
			len(resp[0].FetchMessageSetInPartitions[0].MessageSet) != 5 {
			t.Fatal("fail to parse truncated message set")
		}
	}
}
开发者ID:AnotherGoogleFans,项目名称:kafka,代码行数:39,代码来源:marshal_test.go


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