This repository has been archived by the owner on Sep 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs_test.go
122 lines (96 loc) · 1.7 KB
/
args_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
package main
import (
"testing"
)
func TestParseArguments(t *testing.T) {
args := []string{
"-c", "5",
"-d", "30",
"-v",
"-p", "a:1",
"-p", "b:2",
"--client-stats",
"--version",
}
opts, err := parseArgs(args)
if err != nil {
t.Error(err)
return
}
if !expectInt(t, 5, opts.Clients) {
return
}
if !expectInt(t, 30, opts.Duration) {
return
}
if !expectBool(t, true, opts.Verbose) {
return
}
if !expectBool(t, true, opts.PerClientStats) {
return
}
if !expectBool(t, true, opts.Version) {
return
}
if opts.Properties == nil {
t.Error("property map not initialized")
return
}
if !expectInt(t, 2, len(opts.Properties)) {
return
}
if !expectKeyValue(t, opts.Properties, "a", "1") {
return
}
if !expectKeyValue(t, opts.Properties, "b", "2") {
return
}
}
func TestEmptyArguments(t *testing.T) {
args := []string{}
_, err := parseArgs(args)
if err != nil {
t.Error(err)
return
}
}
func TestDefaultValuesOfArguments(t *testing.T) {
args := []string{}
opts, err := parseArgs(args)
if err != nil {
t.Error(err)
return
}
if !expectInt(t, MIN_LOAD, opts.Clients) {
return
}
if !expectInt(t, MIN_RUN_TIME, opts.Duration) {
return
}
if !expectBool(t, false, opts.Verbose) {
return
}
if !expectBool(t, false, opts.PerClientStats) {
return
}
if !expectBool(t, false, opts.Version) {
return
}
if !expectInt(t, 0, len(opts.Properties)) {
return
}
}
func TestLowerBoundsOfArguments(t *testing.T) {
args := []string{"-d", "0", "-c", "0"}
opts, err := parseArgs(args)
if err != nil {
t.Error(err)
return
}
if !expectInt(t, MIN_LOAD, opts.Clients) {
return
}
if !expectInt(t, MIN_RUN_TIME, opts.Duration) {
return
}
}