Skip to content

Commit

Permalink
Merge pull request #81 from tdakkota/fix/handle-cr-properly
Browse files Browse the repository at this point in the history
fix: properly handle CR character
  • Loading branch information
tdakkota authored Jul 20, 2023
2 parents 17ee314 + 86e96b5 commit d2a6a27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 4 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ linters:
disable-all: true
enable:
- deadcode
- depguard
- dogsled
- errcheck
- goconst
Expand Down Expand Up @@ -94,15 +93,14 @@ issues:

# Check that equal to self is true
- linters: [gocritic]
source: '(assert|require).+Equal'
text: 'dupArg'
source: "(assert|require).+Equal"
text: "dupArg"
path: _test\.go

# Ignore shadowing of err.
- linters: [ govet ]
- linters: [govet]
text: 'declaration of "(err|ctx|log|c)"'

# Ignore linters in main packages.
- path: main\.go
linters: [ goconst, funlen, gocognit, gocyclo ]

linters: [goconst, funlen, gocognit, gocyclo]
9 changes: 5 additions & 4 deletions dec_float.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ func init() {
floatDigits[','] = endOfNumber
floatDigits[']'] = endOfNumber
floatDigits['}'] = endOfNumber
floatDigits[' '] = endOfNumber
floatDigits['\t'] = endOfNumber
floatDigits['\n'] = endOfNumber

for ch, isSpace := range spaceSet {
if isSpace == 1 {
floatDigits[ch] = endOfNumber
}
}
for i := int8('0'); i <= int8('9'); i++ {
floatDigits[i] = i - int8('0')
}
Expand Down
5 changes: 3 additions & 2 deletions int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,13 @@ func TestReadInt64(t *testing.T) {
`12345678901`,
`9223372036854775807`,
`-9223372036854775808`,
"-9223372036854775808\r",
}
for i, input := range inputs {
input := input
t.Run(fmt.Sprintf("Test%d", i+1), createTestCase(input, func(t *testing.T, d *Decoder) error {
should := require.New(t)
expected, err := strconv.ParseInt(input, 10, 64)
expected, err := strconv.ParseInt(strings.Trim(input, "\r"), 10, 64)
should.NoError(err)
v, err := d.Int64()
should.NoError(err)
Expand All @@ -455,7 +456,7 @@ func TestReadInt64(t *testing.T) {
i := 0

return d.Arr(func(d *Decoder) error {
expected, err := strconv.ParseInt(inputs[i], 10, 64)
expected, err := strconv.ParseInt(strings.Trim(inputs[i], "\r"), 10, 64)
should.NoError(err)

v, err := d.Int64()
Expand Down

0 comments on commit d2a6a27

Please sign in to comment.