Debian Codegraph @

getopt_test.go

raw symbols SCIP
1 package getoptscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.16 fmt/"
5 "osscip-go gomod github.com/golang/go/src go1.16 os/"
6 "testingscip-go gomod github.com/golang/go/src go1.16 testing/"
7
8 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/"
9 )
10
11 func TestSimpleCasescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestSimpleCase().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
12 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
13 opts, i, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{
14 "test_bin", "-afo", "output-file", "normal arg"}, "afo:")
15 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
16 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(len(opts), 3, "Expected 3 options to be parsed")
17 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(i, 3, "Expected non-option args to start at index 2")
18 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[0], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'a', ""})
19 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[1], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'f', ""})
20 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[2], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'o', "output-file"})
21 }
22
23 func TestShortFormArgumentscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestShortFormArgument().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
24 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
25 opts, i, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{
26 "test_bin", "-afooutput-file", "normal arg"}, "afo:")
27 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
28 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(len(opts), 3, "Expected 3 options to be parsed")
29 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(i, 2, "Expected non-option args to start at index 2")
30 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[0], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'a', ""})
31 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[1], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'f', ""})
32 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[2], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'o', "output-file"})
33 }
34
35 func TestSeparateArgsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestSeparateArgs().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
36 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
37 opts, i, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{
38 "test_bin", "-a", "-f", "-o", "output-file", "normal arg"}, "afo:")
39 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
40 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(len(opts), 3, "Expected 3 options to be parsed")
41 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(i, 5, "Expected non-option args to start at index 5")
42 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[0], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'a', ""})
43 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[1], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'f', ""})
44 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[2], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'o', "output-file"})
45 }
46
47 func TestTwoDashesscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestTwoDashes().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
48 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
49 opts, i, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{
50 "test_bin", "-afo", "output-file", "--", "-f", "normal arg"}, "afo:")
51 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
52 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(len(opts), 3, "Expected 3 options to be parsed")
53 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(i, 4, "Expected non-option args to start at index 4")
54 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[0], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'a', ""})
55 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[1], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'f', ""})
56 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[2], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{'o', "output-file"})
57 }
58
59 func TestUnknownOptionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestUnknownOption().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
60 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
61 _, _, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{"test_bin", "-x"}, "y")
62 var errt UnknownOptionErrorscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/UnknownOptionError#
63 assert.IsTypescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#IsType().(err, errt, "Expected unknown option error")
64 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(err.Error(), fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.16 fmt/Sprintf().("%s: unknown option -x", osscip-go gomod github.com/golang/go/src go1.16 os/.Argsscip-go gomod github.com/golang/go/src go1.16 os/Args.[0]),
65 "Expected POSIX-compatible error message")
66 }
67
68 func TestMissingOptionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestMissingOption().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
69 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
70 _, _, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{"test_bin", "-x"}, "x:")
71 var errt MissingOptionErrorscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/MissingOptionError#
72 assert.IsTypescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#IsType().(err, errt, "Expected missing option error")
73 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(err.Error(), fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.16 fmt/Sprintf().("%s: expected argument for -x",
74 osscip-go gomod github.com/golang/go/src go1.16 os/.Argsscip-go gomod github.com/golang/go/src go1.16 os/Args.[0]), "Expected POSIX-compatible error message")
75 }
76
77 func TestExpectedMissingOptionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestExpectedMissingOption().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
78 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
79 opts, _, err := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{"test_bin", "-x"}, ":x:")
80 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
81 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(len(opts), 1, "Expected 1 option to be parsed")
82 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opts[0], Optionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Option#{':', "x"})
83 }
84
85 func TestNoOptionscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestNoOption().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
86 assert := assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/New().(t)
87 _, i, _ := Getoptsscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/Getopts().([]string{"test_bin"}, "")
88 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(i, 1, "Expected non-option args to start at index 1")
89 }