From e135a72bda6ffa828e5445a16c349dd7017db282 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 29 Apr 2017 15:11:17 +0200 Subject: main: "--" should also block "-o" parsing Includes test cases. --- cli_args_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cli_args_test.go') diff --git a/cli_args_test.go b/cli_args_test.go index 8846491..63a33ef 100644 --- a/cli_args_test.go +++ b/cli_args_test.go @@ -12,6 +12,7 @@ type testcase struct { o []string } +// TestPrefixOArgs checks that the "-o x,y,z" parsing works correctly. func TestPrefixOArgs(t *testing.T) { testcases := []testcase{ { @@ -51,6 +52,15 @@ func TestPrefixOArgs(t *testing.T) { i: []string{"gocryptfs", "-o", "rw", "--config", "fff", "ccc", "mmm"}, o: []string{"gocryptfs", "-rw", "--config", "fff", "ccc", "mmm"}, }, + // "--" should also block "-o" parsing. + { + i: []string{"gocryptfs", "foo", "bar", "--", "-o", "a"}, + o: []string{"gocryptfs", "foo", "bar", "--", "-o", "a"}, + }, + { + i: []string{"gocryptfs", "--", "-o", "a"}, + o: []string{"gocryptfs", "--", "-o", "a"}, + }, } for _, tc := range testcases { o := prefixOArgs(tc.i) -- cgit v1.2.3