From fe4a138ac8c39cb00bbee7279a0957897ab88fae Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Mon, 19 Apr 2021 21:03:43 -0700 Subject: test coverage 100% !! --- example_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'example_test.go') diff --git a/example_test.go b/example_test.go index 5645156..26f24e7 100644 --- a/example_test.go +++ b/example_test.go @@ -95,6 +95,19 @@ func Example_mappings() { // output: map[john:123 mary:456] } +// This example demonstrates arguments with keys and values separated by commas +func Example_mappingsWithCommas() { + // The args you would pass in on the command line + os.Args = split("./example --userids john=123 mary=456") + + var args struct { + UserIDs map[string]int + } + MustParse(&args) + fmt.Println(args.UserIDs) + // output: map[john:123 mary:456] +} + // This eample demonstrates multiple value arguments that can be mixed with // other arguments. func Example_multipleMixed() { @@ -130,6 +143,7 @@ func Example_helpText() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -162,6 +176,7 @@ func Example_helpPlaceholder() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -202,6 +217,7 @@ func Example_helpTextWithSubcommand() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) @@ -239,6 +255,7 @@ func Example_helpTextForSubcommand() { // This is only necessary when running inside golang's runnable example harness osExit = func(int) {} + stdout = os.Stdout MustParse(&args) -- cgit v1.2.3