本文整理汇总了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)
}
}
示例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, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2d, 0x5b, 0xc0, 0xd7, 0x36, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0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3a, 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")
}
}
}