Skip to content

Commit

Permalink
add json.Number test cases for int*
Browse files Browse the repository at this point in the history
  • Loading branch information
shockerli committed Oct 6, 2021
1 parent f23aeb8 commit 263dfc1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions int_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cvt_test

import (
"encoding/json"
"fmt"
"math"
"testing"
Expand Down Expand Up @@ -1455,6 +1456,7 @@ func TestInt64E(t *testing.T) {
{&aliasTypeBool_true, 1, false},
{aliasTypeBool_false, 0, false},
{&aliasTypeBool_false, 0, false},
{json.Number("1"), 1, false},

// errors
{"10a", 0, true},
Expand All @@ -1473,6 +1475,7 @@ func TestInt64E(t *testing.T) {
{[]string{}, 0, true},
{[...]string{}, 0, true},
{map[int]string{}, 0, true},
{json.Number("hello"), 0, true},
}

for i, tt := range tests {
Expand Down Expand Up @@ -1570,6 +1573,7 @@ func TestInt32E(t *testing.T) {
{&aliasTypeBool_true, 1, false},
{aliasTypeBool_false, 0, false},
{&aliasTypeBool_false, 0, false},
{json.Number("1"), 1, false},

// errors
{"10a", 0, true},
Expand All @@ -1589,6 +1593,7 @@ func TestInt32E(t *testing.T) {
{[]string{}, 0, true},
{[...]string{}, 0, true},
{map[int]string{}, 0, true},
{json.Number("hello"), 0, true},
}

for i, tt := range tests {
Expand Down Expand Up @@ -1686,6 +1691,7 @@ func TestInt16E(t *testing.T) {
{&aliasTypeBool_true, 1, false},
{aliasTypeBool_false, 0, false},
{&aliasTypeBool_false, 0, false},
{json.Number("1"), 1, false},

// errors
{"10a", 0, true},
Expand All @@ -1707,6 +1713,7 @@ func TestInt16E(t *testing.T) {
{[]string{}, 0, true},
{[...]string{}, 0, true},
{map[int]string{}, 0, true},
{json.Number("hello"), 0, true},
}

for i, tt := range tests {
Expand Down Expand Up @@ -1804,6 +1811,7 @@ func TestInt8E(t *testing.T) {
{&aliasTypeBool_true, 1, false},
{aliasTypeBool_false, 0, false},
{&aliasTypeBool_false, 0, false},
{json.Number("1"), 1, false},

// errors
{"10a", 0, true},
Expand All @@ -1820,6 +1828,7 @@ func TestInt8E(t *testing.T) {
{uint8(math.MaxUint8), 0, true},
{"hello", 0, true},
{[]byte("hello"), 0, true},
{json.Number("hello"), 0, true},
{testing.T{}, 0, true},
{&testing.T{}, 0, true},
{[]int{}, 0, true},
Expand Down Expand Up @@ -1923,6 +1932,7 @@ func TestIntE(t *testing.T) {
{&aliasTypeBool_true, 1, false},
{aliasTypeBool_false, 0, false},
{&aliasTypeBool_false, 0, false},
{json.Number("1"), 1, false},

// errors
{"10a", 0, true},
Expand All @@ -1934,6 +1944,7 @@ func TestIntE(t *testing.T) {
{uint64(math.MaxUint64), 0, true},
{"hello", 0, true},
{[]byte("hello"), 0, true},
{json.Number("hello"), 0, true},
{testing.T{}, 0, true},
{&testing.T{}, 0, true},
{[]int{}, 0, true},
Expand Down

0 comments on commit 263dfc1

Please sign in to comment.