Skip to content

Commit

Permalink
Add required tests for go/mysql/fastparse
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 committed Jan 19, 2024
1 parent 715da52 commit 97d2572
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions go/mysql/fastparse/fastparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,48 @@ func TestParseInt64(t *testing.T) {
expected: 42,
err: `unparsed tail left after parsing int64 from "\t 42 \n": "\n"`,
},
{
input: "",
base: 10,
expected: 0,
err: `cannot parse int64 from empty string`,
},
{
input: "256",
base: 1,
expected: 0,
err: `invalid base 1; must be in [2, 36]`,
},
{
input: "256",
base: 37,
expected: 0,
err: `invalid base 37; must be in [2, 36]`,
},
{
input: " -",
base: 10,
expected: 0,
err: `cannot parse int64 from " -"`,
},
{
input: "-18446744073709551615",
base: 10,
expected: -9223372036854775808,
err: `cannot parse int64 from "-18446744073709551615": overflow`,
},
{
input: " ",
base: 10,
expected: 0,
err: `cannot parse int64 from " "`,
},
{
input: " :",
base: 10,
expected: 0,
err: `cannot parse int64 from " :"`,
},
}
for _, tc := range testcases {
t.Run(tc.input, func(t *testing.T) {
Expand Down Expand Up @@ -326,6 +368,36 @@ func TestParseUint64(t *testing.T) {
expected: 42,
err: `unparsed tail left after parsing uint64 from "\t 42 \n": "\n"`,
},
{
input: "",
base: 10,
expected: 0,
err: `cannot parse uint64 from empty string`,
},
{
input: "256",
base: 1,
expected: 0,
err: `invalid base 1; must be in [2, 36]`,
},
{
input: "256",
base: 37,
expected: 0,
err: `invalid base 37; must be in [2, 36]`,
},
{
input: " ",
base: 10,
expected: 0,
err: `cannot parse uint64 from " "`,
},
{
input: " :",
base: 10,
expected: 0,
err: `cannot parse uint64 from " :"`,
},
}
for _, tc := range testcases {
t.Run(tc.input, func(t *testing.T) {
Expand Down

0 comments on commit 97d2572

Please sign in to comment.