MCPcopy Index your code
hub / github.com/go-git/go-git / TestReadVariableWidthIntBoundary

Method TestReadVariableWidthIntBoundary

utils/binary/read_test.go:79–93  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

77}
78
79func (s *BinarySuite) TestReadVariableWidthIntBoundary(c *C) {
80 // Crafted input that drives the running accumulator to exactly
81 // (math.MaxInt64-127)>>7 — the largest pre-increment value for
82 // which the next iteration would still fit in int64. Seven 0xFE
83 // bytes followed by 0xFF land v at exactly the bound; an eighth
84 // continuation byte forces the next iteration. With a strict
85 // "greater than" check the bound was off by one and the
86 // subsequent v++ <<7 wrapped through MinInt64.
87 buf := bytes.NewBuffer([]byte{
88 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0x00,
89 })
90
91 _, err := ReadVariableWidthInt(buf)
92 c.Assert(err, Equals, ErrIntegerOverflow)
93}
94
95func (s *BinarySuite) TestReadUint32(c *C) {
96 buf := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 1

ReadVariableWidthIntFunction · 0.85

Tested by

no test coverage detected