Debian Codegraph @

duration_test.go

raw symbols SCIP
1 // Copyright 2013 Google Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package getoptscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/
6
7 import (
8 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
9 "stringsscip-go gomod github.com/golang/go/src go1.13 strings/"
10 "testingscip-go gomod github.com/golang/go/src go1.13 testing/"
11 "timescip-go gomod github.com/golang/go/src go1.13 time/"
12 )
13
14 var durationTestsscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests. = []struct {
15 wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where. string
16 inscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:in. []string
17 dscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:d. timescip-go gomod github.com/golang/go/src go1.13 time/.Durationscip-go gomod github.com/golang/go/src go1.13 time/Duration#
18 durscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:dur. timescip-go gomod github.com/golang/go/src go1.13 time/.Durationscip-go gomod github.com/golang/go/src go1.13 time/Duration#
19 errscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:err. string
20 }{
21 {
22 locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(),
23 []string{},
24 17, 42,
25 "",
26 },
27 {
28 locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(),
29 []string{"test", "-d", "1s", "--duration", "2s"},
30 timescip-go gomod github.com/golang/go/src go1.13 time/.Secondscip-go gomod github.com/golang/go/src go1.13 time/Second., 2 * timescip-go gomod github.com/golang/go/src go1.13 time/.Secondscip-go gomod github.com/golang/go/src go1.13 time/Second.,
31 "",
32 },
33 {
34 locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(),
35 []string{"test", "-d1s", "-d2s"},
36 2 * timescip-go gomod github.com/golang/go/src go1.13 time/.Secondscip-go gomod github.com/golang/go/src go1.13 time/Second., 42,
37 "",
38 },
39 {
40 locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(),
41 []string{"test", "-d1"},
42 17, 42,
43 "test: time: missing unit in duration",
44 },
45 {
46 locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(),
47 []string{"test", "--duration", "foo"},
48 17, 42,
49 "test: time: invalid duration",
50 },
51 }
52
53 func TestDurationscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/TestDuration().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) {
54 for x, tt := range durationTestsscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests. {
55 resetscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/reset().()
56 d := Durationscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Duration().('d', 17)
57 opt := DurationLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/DurationLong().("duration", 0, 42)
58 if stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Indexscip-go gomod github.com/golang/go/src go1.13 strings/Index().(tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where., ":-") > 0 {
59 tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where. = fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.13 fmt/Sprintf().("#%d", x)
60 }
61
62 parsescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/parse().(tt.inscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:in.)
63 if s := checkErrorscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/checkError().(tt.errscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:err.); s != "" {
64 t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s: %s", tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where., s)
65 }
66 if got, want := *d, tt.dscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:d.; got != want {
67 t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s: got %v, want %v", tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where., got, want)
68 }
69 if got, want := *opt, tt.durscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:dur.; got != want {
70 t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%s: got %v, want %v", tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/durationTests:where., got, want)
71 }
72 }
73 }