本文整理汇总了Golang中github.com/david415/HoneyBadger/types.Sequence.Add方法的典型用法代码示例。如果您正苦于以下问题:Golang Sequence.Add方法的具体用法?Golang Sequence.Add怎么用?Golang Sequence.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/david415/HoneyBadger/types.Sequence
的用法示例。
在下文中一共展示了Sequence.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestGetStartSequence
func TestGetStartSequence(t *testing.T) {
var start types.Sequence = 4
var head *types.Ring = types.NewRing(10)
head.Reassembly = &types.Reassembly{
Seq: 3,
Bytes: []byte{1, 2, 3, 4, 5, 6, 7},
}
startSeq := getStartSequence(head, start)
if startSeq.Difference(start) != 0 {
t.Errorf("startSeq %d != start %d\n", startSeq, start)
t.Fail()
}
start = 2
startSeq = getStartSequence(head, start)
if startSeq != start.Add(1) {
t.Errorf("startSeq %d != start %d\n", startSeq, start.Add(1))
t.Fail()
}
}
示例2: byteSpan
func byteSpan(expected, received types.Sequence, bytes []byte) (toSend []byte, next types.Sequence) {
if expected == types.InvalidSequence {
return bytes, received.Add(len(bytes))
}
span := int(received.Difference(expected))
if span <= 0 {
return bytes, received.Add(len(bytes))
} else if len(bytes) < span {
return nil, expected
}
return bytes[span:], expected.Add(len(bytes) - span)
}