-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from syumai/d1-treat-integral-float64-as-int64
treat D1 driver row's integral float64 value as int64
- Loading branch information
Showing
3 changed files
with
67 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package d1 | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
) | ||
|
||
func Test_isIntegralNumber(t *testing.T) { | ||
tests := map[string]struct { | ||
f float64 | ||
want bool | ||
}{ | ||
"valid integral value": { | ||
f: 1, | ||
want: true, | ||
}, | ||
"invalid float value": { | ||
f: 1.1, | ||
want: false, | ||
}, | ||
"invalid NaN": { | ||
f: math.NaN(), | ||
want: false, | ||
}, | ||
"invalid +Inf": { | ||
f: math.Inf(+1), | ||
want: false, | ||
}, | ||
"invalid -Inf": { | ||
f: math.Inf(-1), | ||
want: false, | ||
}, | ||
} | ||
for name, tc := range tests { | ||
name := name | ||
tc := tc | ||
t.Run(name, func(t *testing.T) { | ||
t.Parallel() | ||
if got := isIntegralNumber(tc.f); got != tc.want { | ||
t.Errorf("isIntegralNumber() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters