-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
38 lines (32 loc) · 922 Bytes
/
main_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
package main
import "testing"
func TestNewKSCEmployee(t *testing.T) {
expLastName := "Kerman"
var Jobs = [...]string{
"Pilot",
"Scientist",
"Engineer",
}
expMinAge := 22
expMaxAge := 39
/* Get a random employee */
employee := newKSCEmployee()
/* Test if the has the best last name on Kerbin */
if employee.LastName != expLastName {
t.Errorf("LastName of Kerbal (%s) was not %s", employee.LastName, expLastName)
}
/* Test if the employee has a valid job that is available at KSC */
validJob := false
for _, job := range Jobs {
if job == employee.Position {
validJob = true
}
}
if validJob != true {
t.Errorf("Position of Kerbal (%s) is not a valid job at KSC", employee.Position)
}
/* Test if the employee has a valid age */
if employee.Age < expMinAge || employee.Age > expMaxAge {
t.Errorf("Age of Kerbal (%d) is not between %d and %d", employee.Age, expMinAge, expMaxAge)
}
}