-
Notifications
You must be signed in to change notification settings - Fork 0
/
round_test.go
47 lines (37 loc) · 950 Bytes
/
round_test.go
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
package round
import (
"testing"
)
func TestRound(t *testing.T) {
r := genRandomFloat(1, 9)
t.Logf("Generate random float64 number(1-9): %f\n", r)
t.Logf("after round: %.3f", Ceil(r))
t.Logf("rand: %.3f", r)
if Round(r) == r {
t.Errorf("Test Round Failed: %f is equal %f", r, Round(r))
} else {
t.Log("Test Round Passed!!!")
}
}
func TestCeil(t *testing.T) {
r := genRandomFloat(1, 9)
t.Logf("Generate random float64 number(1-9): %f\n", r)
t.Logf("after ceil: %f", Ceil(r))
t.Logf("rand: %f", r)
if Ceil(r) == r {
t.Errorf("Test Ceil Failed: %f is equal %f", r, Ceil(r))
} else {
t.Log("Test Ceil Passed!!!")
}
}
func TestFloor(t *testing.T) {
r := genRandomFloat(1, 9)
t.Logf("Generate random float64 number(1-9): %f\n", r)
t.Logf("after floor: %f", Ceil(r))
t.Logf("rand: %f", r)
if Floor(r) == r {
t.Errorf("Test Floor Failed: %f is equal %f", r, Floor(r))
} else {
t.Log("Test Floor Passed!!!")
}
}