diff options
author | Duncan Overbruck <github@duncano.de> | 2023-08-24 20:39:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-24 20:39:33 +0200 |
commit | 6aea1e0d440708a970c8294978b57ee27097bfc5 (patch) | |
tree | 56c42e7c231a28d3c46253d240fa9b8b8c1e07c8 /round2_64_test.go | |
parent | Update ErrNoMultipartForm (diff) | |
download | fasthttp-6aea1e0d440708a970c8294978b57ee27097bfc5.tar.gz fasthttp-6aea1e0d440708a970c8294978b57ee27097bfc5.tar.bz2 fasthttp-6aea1e0d440708a970c8294978b57ee27097bfc5.zip |
fix round2_32, split round2 tests because they depend on sizeof int at compile time (#1607)
Diffstat (limited to 'round2_64_test.go')
-rw-r--r-- | round2_64_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/round2_64_test.go b/round2_64_test.go new file mode 100644 index 0000000..d805802 --- /dev/null +++ b/round2_64_test.go @@ -0,0 +1,33 @@ +//go:build amd64 || arm64 || ppc64 || ppc64le || s390x +// +build amd64 arm64 ppc64 ppc64le s390x + +package fasthttp + +import ( + "math" + "testing" +) + +func TestRound2ForSliceCap(t *testing.T) { + t.Parallel() + + testRound2ForSliceCap(t, 0, 0) + testRound2ForSliceCap(t, 1, 1) + testRound2ForSliceCap(t, 2, 2) + testRound2ForSliceCap(t, 3, 4) + testRound2ForSliceCap(t, 4, 4) + testRound2ForSliceCap(t, 5, 8) + testRound2ForSliceCap(t, 7, 8) + testRound2ForSliceCap(t, 8, 8) + testRound2ForSliceCap(t, 9, 16) + testRound2ForSliceCap(t, 0x10001, 0x20000) + + testRound2ForSliceCap(t, math.MaxInt32, math.MaxInt32) + testRound2ForSliceCap(t, math.MaxInt64-1, math.MaxInt64-1) +} + +func testRound2ForSliceCap(t *testing.T, n, expectedRound2 int) { + if roundUpForSliceCap(n) != expectedRound2 { + t.Fatalf("Unexpected round2(%d)=%d. Expected %d", n, roundUpForSliceCap(n), expectedRound2) + } +} |