-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat_test.go
More file actions
51 lines (42 loc) · 809 Bytes
/
float_test.go
File metadata and controls
51 lines (42 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package isodd
import (
"testing"
)
func TestFloat32(t *testing.T) {
type testcase struct {
num float32
isOdd bool
}
testCases := []testcase{
{1.232458, true},
{0.324, false},
{2.94038598, false},
{-200000.94038598, false},
{-999999.232458, true},
}
for _, test := range testCases {
isOdd := Float32(test.num)
if isOdd != test.isOdd {
t.Fatalf("[TestFloat32] %f failed", test.num)
}
}
}
func TestFloat64(t *testing.T) {
type testcase struct {
num float64
isOdd bool
}
testCases := []testcase{
{1.232458, true},
{0.324, false},
{2.94038598, false},
{-200000.94038598, false},
{-999999.232458, true},
}
for _, test := range testCases {
isOdd := Float64(test.num)
if isOdd != test.isOdd {
t.Fatalf("[TestFloat64] %f failed", test.num)
}
}
}