diff options
| author | Eric Paris <[email protected]> | 2015-08-15 16:05:51 -0400 |
|---|---|---|
| committer | Eric Paris <[email protected]> | 2015-08-15 16:12:29 -0400 |
| commit | e0e7ef766bf91748c5c55258e3773edaea7ed5f4 (patch) | |
| tree | 6b7b45fb16d399e64949d036e5bfdc6be79586f6 /flag_test.go | |
| parent | 4b69d21313e8b16259f8fdac37156283b254c84b (diff) | |
New AddFlagSet function on FlagSet
This function allows one to create a different FlagSets and then easily
merge them together.
Diffstat (limited to 'flag_test.go')
| -rw-r--r-- | flag_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/flag_test.go b/flag_test.go index 9ff1934..5114f28 100644 --- a/flag_test.go +++ b/flag_test.go @@ -110,6 +110,23 @@ func TestUsage(t *testing.T) { } } +func TestAddFlagSet(t *testing.T) { + oldSet := NewFlagSet("old", ContinueOnError) + newSet := NewFlagSet("new", ContinueOnError) + + oldSet.String("flag1", "flag1", "flag1") + oldSet.String("flag2", "flag2", "flag2") + + newSet.String("flag2", "flag2", "flag2") + newSet.String("flag3", "flag3", "flag3") + + oldSet.AddFlagSet(newSet) + + if len(oldSet.formal) != 3 { + t.Errorf("Unexpected result adding a FlagSet to a FlagSet %v", oldSet) + } +} + func TestAnnotation(t *testing.T) { f := NewFlagSet("shorthand", ContinueOnError) |
