MCPcopy Create free account
hub / github.com/buger/jsonparser / parseIntOverflows

Function parseIntOverflows

bytes_test.go:153–177  ·  view source on GitHub ↗

Test helper for SYS-REQ-015.

(bytes []byte)

Source from the content-addressed store, hash-verified

151
152// Test helper for SYS-REQ-015.
153func parseIntOverflows(bytes []byte) (v int64, ok bool) {
154 if len(bytes) == 0 {
155 return 0, false
156 }
157
158 var neg bool = false
159 if bytes[0] == '-' {
160 neg = true
161 bytes = bytes[1:]
162 }
163
164 for _, c := range bytes {
165 if c >= '0' && c <= '9' {
166 v = (10 * v) + int64(c-'0')
167 } else {
168 return 0, false
169 }
170 }
171
172 if neg {
173 return -v, true
174 } else {
175 return v, true
176 }
177}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected