mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
46 lines
803 B
Go
46 lines
803 B
Go
package flags
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestPassDoubleDash(t *testing.T) {
|
|
var opts = struct {
|
|
Value bool `short:"v"`
|
|
}{}
|
|
|
|
p := NewParser(&opts, PassDoubleDash)
|
|
ret, err := p.ParseArgs([]string{"-v", "--", "-v", "-g"})
|
|
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
return
|
|
}
|
|
|
|
if !opts.Value {
|
|
t.Errorf("Expected Value to be true")
|
|
}
|
|
|
|
assertStringArray(t, ret, []string{"-v", "-g"})
|
|
}
|
|
|
|
func TestPassAfterNonOption(t *testing.T) {
|
|
var opts = struct {
|
|
Value bool `short:"v"`
|
|
}{}
|
|
|
|
p := NewParser(&opts, PassAfterNonOption)
|
|
ret, err := p.ParseArgs([]string{"-v", "arg", "-v", "-g"})
|
|
|
|
if err != nil {
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
return
|
|
}
|
|
|
|
if !opts.Value {
|
|
t.Errorf("Expected Value to be true")
|
|
}
|
|
|
|
assertStringArray(t, ret, []string{"arg", "-v", "-g"})
|
|
}
|