Debian Codegraph @

flag_test.go

raw symbols SCIP
1 package getoptscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/
2
3 import (
4 "testingscip-go gomod github.com/golang/go/src go1.16 testing/"
5 "timescip-go gomod github.com/golang/go/src go1.16 time/"
6
7 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/"
8 )
9
10 func TestIntscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestInt().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
11 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)
12
13 p := NewFlagSetscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/NewFlagSet().("", 0)
14 var k int
15 p.IntVarscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#IntVar().(&k, "k", 16, "set k")
16 i := p.Int64scip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#Int64().("i", -1, "set i")
17 j := p.Uintscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#Uint().("j", 64, "set j")
18
19 err := p.parsescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#parse().([]string{"bin", "-i", "32", "normal arg"})
20 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
21 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(3, p.optindexscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#optindex., "Expected to only parse two arguments")
22 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(int64(32), *i, "Expected -i argument to equal 32")
23 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(uint(64), *j, "Expected -j argument to equal 64, since unset")
24 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(16, k, "Expected -k argument to equal 16, since unset")
25 }
26
27 func TestBoolscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestBool().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
28 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)
29
30 p := NewFlagSetscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/NewFlagSet().("", 0)
31 var a bool
32 p.BoolVarscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#BoolVar().(&a, "a", false, "set a")
33 b := p.Boolscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#Bool().("b", false, "set b")
34
35 err := p.parsescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#parse().([]string{"bin", "-a", "normal arg"})
36 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
37 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(2, p.optindexscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#optindex., "Expected to only parse two arguments")
38 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(true, a, "Expected -a argument to be set")
39 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(false, *b, "Expected -b argument to not be set")
40 }
41
42 func TestStringscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestString().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
43 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)
44
45 p := NewFlagSetscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/NewFlagSet().("", 0)
46 get := p.Stringscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#String().("c", "default", "get -c")
47
48 opt := "some options"
49 err := p.parsescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#parse().([]string{"bin", "-c", opt, "normal arg"})
50 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
51 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(opt, *get, "Expected argument to be parsed")
52 }
53
54 func TestFloat64scip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestFloat64().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
55 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)
56
57 p := NewFlagSetscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/NewFlagSet().("", 0)
58 f := p.Float64scip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#Float64().("f", -3.14, "get -f")
59
60 err := p.parsescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#parse().([]string{"bin", "-f", "3.14", "normal arg"})
61 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
62 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(3.14, *f, "Expected -f to equal 3.14")
63 }
64
65 func TestDurationscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/TestDuration().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) {
66 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)
67
68 p := NewFlagSetscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/NewFlagSet().("", 0)
69 d := p.Durationscip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#Duration().("d", 0, "get -d")
70
71 err := p.parsescip-go gomod git.sr.ht/~sircmpwn/getopt . `git.sr.ht/~sircmpwn/getopt`/FlagSet#parse().([]string{"bin", "-d", "1h3m", "normal arg"})
72 assert.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Nil().(err, "Expected err to be nil")
73 assert.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Assertions#Equal().(timescip-go gomod github.com/golang/go/src go1.16 time/.Hourscip-go gomod github.com/golang/go/src go1.16 time/Hour.+3*timescip-go gomod github.com/golang/go/src go1.16 time/.Minutescip-go gomod github.com/golang/go/src go1.16 time/Minute., *d, "Expected -d to equal 1 hour and 3 minutes")
74 }