From 712e6e24753f2352fd93d997e54e3ae439cd0d0b Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 23 Jun 2024 19:16:47 -0400 Subject: [PATCH] fix(test): Fix strings.Repeat test that failed in the wrong way on 32bit Signed-off-by: Dave Henderson --- internal/tests/integration/strings_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/tests/integration/strings_test.go b/internal/tests/integration/strings_test.go index 27ffafe8e..82a39d14f 100644 --- a/internal/tests/integration/strings_test.go +++ b/internal/tests/integration/strings_test.go @@ -1,6 +1,8 @@ package integration import ( + "fmt" + "math" "strings" "testing" @@ -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()