-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoption_test.go
52 lines (45 loc) · 1.98 KB
/
option_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
// Copyright (c) 2011, SoundCloud Ltd., Daniel Bornkessel
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Source code and contact info at http://github.com/kesselborn/go-getopt
package getopt
import (
"testing"
)
func TestOptionMethods(t *testing.T) {
var option Option
option = Option{"method|m|MON_METHOD", "method: one of either 'heartbeat' or 'nagios'", Required, ""}
if option.LongOpt() != "method" {
t.Errorf("'method|m|MON_METHOD': longopt parsing failed (expected 'method', got '" + option.LongOpt() + "')")
}
if option.ShortOpt() != "m" {
t.Errorf("'method|m|MON_METHOD': shortopt parsing failed (expected 'm', got '" + option.ShortOpt() + "')")
}
if option.EnvVar() != "MON_METHOD" {
t.Errorf("'method|m|MON_METHOD': env var parsing failed")
}
option = Option{"method|m|MON_METHOD", "method: one of either 'heartbeat' or 'nagios'", NoLongOpt, ""}
if option.LongOpt() != "" {
t.Errorf("'method|m|MON_METHOD' with option NoLongOpt: longopt parsing failed (expected '', got '" + option.LongOpt() + "')")
}
option = Option{"method||MON_METHOD", "method: one of either 'heartbeat' or 'nagios'", Required, ""}
if option.LongOpt() != "method" {
t.Errorf("'method||MON_METHOD': longopt parsing failed (expected 'method', got '" + option.LongOpt() + "')")
}
if option.ShortOpt() != "" {
t.Errorf("'method||MON_METHOD': shortopt parsing failed (expected '', got '" + option.ShortOpt() + "')")
}
if option.EnvVar() != "MON_METHOD" {
t.Errorf("'method||MON_METHOD': env var parsing failed")
}
option = Option{"method", "method: one of either 'heartbeat' or 'nagios'", Required, ""}
if option.LongOpt() != "method" {
t.Errorf("'method': longopt parsing failed (expected 'method', got '" + option.LongOpt() + "')")
}
if option.ShortOpt() != "" {
t.Errorf("'method': shortopt parsing failed (expected '', got '" + option.ShortOpt() + "')")
}
if option.EnvVar() != "" {
t.Errorf("'method': env var parsing failed")
}
}