Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bint.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
return false, bint{}, 0, errInvalidFormat(s)
}

// prevent "-.123" or "+.123"
if s[pos] == '.' {
// prevent "-.123" or "+.123", and a second sign as in "-+123" that big.Int would read as a sign again
if s[pos] < '0' || s[pos] > '9' {
return false, bint{}, 0, errInvalidFormat(s)
}

Expand Down Expand Up @@ -201,7 +201,7 @@
return false, bint{}, 0, errInvalidFormat(s)
}

//nolint:gosec // prec <= maxPrec (19) and can be safely converted to uint8

Check failure on line 204 in bint.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:gosec // prec <= maxPrec (19) and can be safely converted to uint8` is unused for linter "gosec" (nolintlint)
return neg, bintFromBigInt(dValue), uint8(prec), nil
}

Expand Down
6 changes: 6 additions & 0 deletions decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ func TestParse(t *testing.T) {
{"+340282366920938463463374607431768211459", "340282366920938463463374607431768211459", nil},
{"340282366920938463463374607431768211459.", "", fmt.Errorf("%w: can't parse '340282366920938463463374607431768211459.'", ErrInvalidFormat)},
{"--340282366920938463463374607431768211459", "", fmt.Errorf("%w: can't parse '--340282366920938463463374607431768211459'", ErrInvalidFormat)},
{"-+1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '-+1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"-+340282366920938463463374607431768211459.123", "", fmt.Errorf("%w: can't parse '-+340282366920938463463374607431768211459.123'", ErrInvalidFormat)},
{"+-1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '+-1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"++1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '++1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"--1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '--1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"-+123", "", fmt.Errorf("%w: can't parse '-+123'", ErrInvalidFormat)},
{".1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '.1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"+.1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '+.1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
{"-.1234567890123456789012345678901234567890123456", "", fmt.Errorf("%w: can't parse '-.1234567890123456789012345678901234567890123456'", ErrInvalidFormat)},
Expand Down
Loading