Skip to content

Commit

Permalink
fix(test): Fix strings.Repeat test that failed in the wrong way on 32bit
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson committed Jun 23, 2024
1 parent 5104b19 commit 712e6e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/tests/integration/strings_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"fmt"
"math"
"strings"
"testing"

Expand All @@ -26,7 +28,10 @@ func TestStrings_Indent(t *testing.T) {
func TestStrings_Repeat(t *testing.T) {
inOutTest(t, `ba{{ strings.Repeat 2 "na" }}`, `banana`)

_, _, err := cmd(t, "-i", `ba{{ strings.Repeat 9223372036854775807 "na" }}`).run()
// use MaxInt so we avoid a negative count on 32-bit systems
input := fmt.Sprintf(`ba{{ strings.Repeat %d "na" }}`, math.MaxInt)

_, _, err := cmd(t, "-i", input).run()
assert.ErrorContains(t, err, `too long: causes overflow`)

_, _, err = cmd(t, "-i", `ba{{ strings.Repeat -1 "na" }}`).run()
Expand Down

0 comments on commit 712e6e2

Please sign in to comment.