Skip to content

Commit 6a38036

Browse files
authored
Fix integer overflows in test when run on 32bit systems (#1479)
## Fixes Or Enhances While 32bit systems are becoming rarer, Debian still fully supports `armhf`. On such systems, `TestLuhnChecksumValidation` fails because some of the integer values overflow without an explicit cast to `int64`. ``` # github.com/go-playground/validator/v10 [github.com/go-playground/validator/v10.test] ./validator_test.go:13914:4: cannot use 586824160825533338 (untyped int constant) as int value in struct literal (overflows) ./validator_test.go:13917:4: cannot use 586824160825533328 (untyped int constant) as int value in struct literal (overflows) ./validator_test.go:13919:4: cannot use 10000000116 (untyped int constant) as int value in struct literal (overflows) ./validator_test.go:13921:4: cannot use 10000000117 (untyped int constant) as int value in struct literal (overflows) ``` **Make sure that you've checked the boxes below before you submit PR:** - [x] Tests exist or have been written that cover this particular change. @go-playground/validator-maintainers Signed-off-by: Mathias Gibbens <[email protected]>
1 parent 2d3af3d commit 6a38036

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

validator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13911,14 +13911,14 @@ func TestLuhnChecksumValidation(t *testing.T) {
1391113911
expected bool
1391213912
}{
1391313913
{uint64(586824160825533338), "luhn_checksum", true}, // credit card numbers are just special cases of numbers with luhn checksum
13914-
{586824160825533338, "luhn_checksum", true},
13914+
{int64(586824160825533338), "luhn_checksum", true},
1391513915
{"586824160825533338", "luhn_checksum", true},
1391613916
{uint64(586824160825533328), "luhn_checksum", false},
13917-
{586824160825533328, "luhn_checksum", false},
13917+
{int64(586824160825533328), "luhn_checksum", false},
1391813918
{"586824160825533328", "luhn_checksum", false},
13919-
{10000000116, "luhn_checksum", true}, // but there may be shorter numbers (11 digits)
13919+
{int64(10000000116), "luhn_checksum", true}, // but there may be shorter numbers (11 digits)
1392013920
{"10000000116", "luhn_checksum", true},
13921-
{10000000117, "luhn_checksum", false},
13921+
{int64(10000000117), "luhn_checksum", false},
1392213922
{"10000000117", "luhn_checksum", false},
1392313923
{uint64(12345678123456789011), "luhn_checksum", true}, // or longer numbers (19 digits)
1392413924
{"12345678123456789011", "luhn_checksum", true},

0 commit comments

Comments
 (0)