aboutsummaryrefslogtreecommitdiff
path: root/bytesconv_32_test.go
diff options
context:
space:
mode:
authorGravatar Ivan Mironov <mironov.ivan@gmail.com> 2020-04-23 18:08:07 +0500
committerGravatar GitHub <noreply@github.com> 2020-04-23 15:08:07 +0200
commit3e27d8ebad7a69e49e447c7d0511dda63a9fbabb (patch)
tree505579f8a264a70147f0d9e27b16f480f7787590 /bytesconv_32_test.go
parentOnly base64 the proxy auth once (diff)
downloadfasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.tar.gz
fasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.tar.bz2
fasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.zip
Fix integer overflow handling in parseUintBuf() (#789)
* Add more tests for parseUintBuf() * Fix integer overflow handling in parseUintBuf()
Diffstat (limited to 'bytesconv_32_test.go')
-rw-r--r--bytesconv_32_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/bytesconv_32_test.go b/bytesconv_32_test.go
index 405230b..f0647bd 100644
--- a/bytesconv_32_test.go
+++ b/bytesconv_32_test.go
@@ -38,10 +38,22 @@ func TestReadHexIntSuccess(t *testing.T) {
testReadHexIntSuccess(t, "1234ZZZ", 0x1234)
}
+func TestParseUintError32(t *testing.T) {
+ t.Parallel()
+
+ // Overflow by last digit: 2 ** 32 / 2 * 10 ** n
+ testParseUintError(t, "2147483648")
+ testParseUintError(t, "21474836480")
+ testParseUintError(t, "214748364800")
+}
+
func TestParseUintSuccess(t *testing.T) {
t.Parallel()
testParseUintSuccess(t, "0", 0)
testParseUintSuccess(t, "123", 123)
testParseUintSuccess(t, "123456789", 123456789)
+
+ // Max supported value: 2 ** 32 / 2 - 1
+ testParseUintSuccess(t, "2147483647", 2147483647)
}