-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisee_service_test.go
51 lines (46 loc) · 916 Bytes
/
isee_service_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
48
49
50
51
package main
import (
"fmt"
"reflect"
"testing"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func TestISEECalc(t *testing.T) {
tests := []struct {
Salary int
HasHouse bool
HouseArea int
FamilyMembers int
EuroPrice int
Expected int
}{
{
10000000,
false,
100,
4,
5000,
9756,
},
{
10000000,
true,
70,
4,
35000,
4239,
},
}
for i, test := range tests {
usr := &User{&primitive.NilObjectID, 1, &test.Salary, &test.HasHouse, &test.HouseArea, &test.FamilyMembers}
srv := ISEEService{usr}
Assert(t, test.Expected, srv.Calc(test.EuroPrice), "Test case %d is not successful\n", i)
}
}
func Assert(t *testing.T, exp interface{}, act interface{}, msg string, args ...interface{}) {
t.Helper()
if !reflect.DeepEqual(act, exp) {
msg = fmt.Sprintf(msg, args...)
t.Errorf("%s\nactual: %v\nexpected: %v", msg, act, exp)
}
}