-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_test.go
More file actions
68 lines (63 loc) · 1.59 KB
/
util_test.go
File metadata and controls
68 lines (63 loc) · 1.59 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package csfloat_test
import (
"testing"
csfloat "github.com/Bios-Marcel/csfloat_go"
)
func Test_ApplyFee(t *testing.T) {
type testCase struct {
value int
fee float64
expectedValueWithoutFee int
expectedAppliedFee int
}
testCases := []testCase{
{
value: 0,
fee: 0.02,
expectedValueWithoutFee: 0,
expectedAppliedFee: 0,
},
{
value: 0,
fee: 0,
expectedValueWithoutFee: 0,
expectedAppliedFee: 0,
},
{
value: 3,
fee: 0.02,
expectedValueWithoutFee: 2,
expectedAppliedFee: 1,
},
{
value: 100,
fee: 0.02,
expectedValueWithoutFee: 98,
expectedAppliedFee: 2,
},
{
value: 101,
fee: 0.02,
expectedValueWithoutFee: 98,
expectedAppliedFee: 3,
},
{
value: 200,
fee: 0.02,
expectedValueWithoutFee: 196,
expectedAppliedFee: 4,
},
{
value: 201,
fee: 0.02,
expectedValueWithoutFee: 196,
expectedAppliedFee: 5,
},
}
for _, tc := range testCases {
valueWithoutFee, appliedFee := csfloat.ApplyFee(tc.value, tc.fee)
if valueWithoutFee != tc.expectedValueWithoutFee || appliedFee != tc.expectedAppliedFee {
t.Errorf("ApplyFee(%d, %f) = (%d, %d), want (%d, %d)", tc.value, tc.fee, valueWithoutFee, appliedFee, tc.expectedValueWithoutFee, tc.expectedAppliedFee)
}
}
}