Skip to content

Commit

Permalink
Test empty string for Uint64 and Int64
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 20, 2023
1 parent 56a5bd6 commit 4cd270e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func TestUint64JSON(t *testing.T) {
// test unquoted unmarshal
err = json.Unmarshal([]byte(`123`), &u)
require.EqualError(t, err, "cannot unmarshal 123 into Uint64, expected string-encoded integer")

// test empty string
err = json.Unmarshal([]byte(`""`), &u)
require.EqualError(t, err, "cannot unmarshal \"\" into Uint64, failed to parse integer")
}

func TestInt64JSON(t *testing.T) {
Expand Down Expand Up @@ -75,4 +79,8 @@ func TestInt64JSON(t *testing.T) {
// test unquoted unmarshal
err = json.Unmarshal([]byte(`-123`), &i)
require.EqualError(t, err, "cannot unmarshal -123 into Int64, expected string-encoded integer")

// test empty string
err = json.Unmarshal([]byte(`""`), &i)
require.EqualError(t, err, "cannot unmarshal \"\" into Int64, failed to parse integer")
}

0 comments on commit 4cd270e

Please sign in to comment.