| 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 | ) |
| 12 | |
| 13 | var enumTestsscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests. = []struct { |
| 14 | wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:where. string |
| 15 | inscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:in. []string |
| 16 | valuesscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:values. []string |
| 17 | outscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:out. string |
| 18 | errscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:err. string |
| 19 | }{ |
| 20 | { |
| 21 | locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(), |
| 22 | nil, |
| 23 | []string{}, |
| 24 | "", |
| 25 | "", |
| 26 | }, |
| 27 | { |
| 28 | locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(), |
| 29 | []string{"test", "-e", "val1"}, |
| 30 | []string{"val1", "val2"}, |
| 31 | "val1", |
| 32 | "", |
| 33 | }, |
| 34 | { |
| 35 | locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(), |
| 36 | []string{"test", "-e", "val1", "-e", "val2"}, |
| 37 | []string{"val1", "val2"}, |
| 38 | "val2", |
| 39 | "", |
| 40 | }, |
| 41 | { |
| 42 | locscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/loc().(), |
| 43 | []string{"test", "-e", "val3"}, |
| 44 | []string{"val1", "val2"}, |
| 45 | "", |
| 46 | "test: invalid value: val3\n", |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | func TestEnumscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/TestEnum().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 51 | for x, tt := range enumTestsscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests. { |
| 52 | 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`/enumTests:where., ":-") > 0 { |
| 53 | tt.wherescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests: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) |
| 54 | } |
| 55 | |
| 56 | resetscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/reset().() |
| 57 | e := Enumscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Enum().('e', tt.valuesscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:values.) |
| 58 | parsescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/parse().(tt.inscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:in.) |
| 59 | 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`/enumTests:err.); s != "" { |
| 60 | 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`/enumTests:where., s) |
| 61 | } |
| 62 | if *e != tt.outscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:out. { |
| 63 | 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`/enumTests:where., *e, tt.outscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/enumTests:out.) |
| 64 | } |
| 65 | } |
| 66 | } |