generated from Yandex-Practicum/go-sprint-four
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftracker_test.go
173 lines (161 loc) · 3.47 KB
/
ftracker_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package ftracker
import (
"testing"
)
func Test_distance(t *testing.T) {
type args struct {
action int
}
tests := []struct {
name string
args args
want float64
}{
// TODO: Add test cases.
{
name: "Success test",
args: args{
action: 2000,
},
want: 1.3,
},
{
name: "Null action",
args: args{
action: 0,
},
want: 0.0,
},
{
name: "One action",
args: args{
action: 1,
},
want: 0.00065,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := distance(tt.args.action); got != tt.want {
t.Errorf("distance() = %v, want %v", got, tt.want)
}
})
}
}
func Test_meanSpeed(t *testing.T) {
type args struct {
action int
duration float64
}
tests := []struct {
name string
args args
want float64
}{
// TODO: Add test cases.
{
name: "Successful test",
args: args{
action: 2000,
duration: 2.0,
},
want: 0.65,
},
{
name: "Null duration",
args: args{
action: 2000,
duration: 0,
},
want: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := meanSpeed(tt.args.action, tt.args.duration); got != tt.want {
t.Errorf("meanSpeed() = %v, want %v", got, tt.want)
}
})
}
}
func TestShowTrainingInfo(t *testing.T) {
type args struct {
action int
trainingType string
duration float64
weight float64
height float64
lengthPool int
countPool int
}
runTest := "Тип тренировки: Бег\nДлительность: 0.15 ч.\nДистанция: 2.60 км.\nСкорость: 17.33 км/ч\nСожгли калорий: 427.24\n"
walkingTest := "Тип тренировки: Ходьба\nДлительность: 1.00 ч.\nДистанция: 2.60 км.\nСкорость: 2.60 км/ч\nСожгли калорий: 220.27\n"
swimmingTest := "Тип тренировки: Плавание\nДлительность: 0.25 ч.\nДистанция: 0.65 км.\nСкорость: 1.60 км/ч\nСожгли калорий: 114.75\n"
unknownTest := "неизвестный тип тренировки"
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
{
name: "run test",
args: args{
action: 4000,
trainingType: "Бег",
duration: 0.15,
weight: 85,
height: 185,
lengthPool: 50,
countPool: 2,
},
want: runTest,
},
{
name: "walking test",
args: args{
action: 4000,
trainingType: "Ходьба",
duration: 1,
weight: 85,
height: 185,
lengthPool: 50,
countPool: 2,
},
want: walkingTest,
},
{
name: "swimming test",
args: args{
action: 1000,
trainingType: "Плавание",
duration: 0.25,
weight: 85,
height: 185,
lengthPool: 100,
countPool: 4,
},
want: swimmingTest,
},
{
name: "unknown test",
args: args{
action: 1000,
trainingType: "Керлинг",
duration: 5,
weight: 85,
height: 185,
lengthPool: 50,
countPool: 2,
},
want: unknownTest,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ShowTrainingInfo(tt.args.action, tt.args.trainingType, tt.args.duration, tt.args.weight, tt.args.height, tt.args.lengthPool, tt.args.countPool); got != tt.want {
t.Errorf("ShowTrainingInfo() = %v, want %v", got, tt.want)
}
})
}
}