-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_test.go
64 lines (55 loc) · 1.3 KB
/
functions_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
package go_tools
import (
mrand "math/rand"
"github.com/makhidkarun/go_tools"
"testing"
)
var rng = mrand.New(mrand.NewSource(99))
func TestOneD6(t *testing.T) {
roll := go_tools.OneD6()
if roll < 1 || roll > 6 {
t.Error(`OneD6 failed`)
}
}
func TestTwoD6(t *testing.T) {
roll := go_tools.TwoD6()
if roll < 2 || roll > 12 {
t.Error(`TwoD6 failed`)
}
}
func TestAge(t *testing.T) {
age := go_tools.Age(2)
if age < 26 || age > 29 {
t.Error(`Age failed`)
}
}
func TestFormatUPP(t *testing.T) {
upp := [6]int{7, 7, 15, 9, 12, 12}
newUPP := go_tools.FormatUPP(upp)
if newUPP != "77F9CC" {
t.Error(`FormatUPP failed.`)
}
}
func TestStringInArray(t *testing.T) {
var genders []string = []string{"F", "M"}
option1 := "F"
option2 := "R"
if !go_tools.StringInArray(option1, genders) {
t.Error(`Missing an F.`)
}
if go_tools.StringInArray(option2, genders) {
t.Error(`Never met R.`)
}
}
func TestRandomStringFromArray(t *testing.T) {
var genders []string = []string{"F", "M"}
gender := go_tools.RandomStringFromArray(genders)
if !go_tools.StringInArray(gender, genders) {
t.Error(`Bad gender output.`)
}
var ranks []string = []string{"PVT", "SGT", "LT", "CPT", "MAJ"}
rank := go_tools.RandomStringFromArray(ranks)
if !go_tools.StringInArray(rank, ranks) {
t.Error(`Bad rank output.`)
}
}