(t *testing.T)
| 815 | } |
| 816 | |
| 817 | func TestCustomNormalizedNames(t *testing.T) { |
| 818 | f := NewFlagSet("normalized", ContinueOnError) |
| 819 | if f.Parsed() { |
| 820 | t.Error("f.Parse() = true before Parse") |
| 821 | } |
| 822 | |
| 823 | validFlag := f.Bool("valid-flag", false, "bool value") |
| 824 | f.SetNormalizeFunc(aliasAndWordSepFlagNames) |
| 825 | someOtherFlag := f.Bool("some-other-flag", false, "bool value") |
| 826 | |
| 827 | args := []string{"--old_valid_flag", "--some-other_flag"} |
| 828 | if err := f.Parse(args); err != nil { |
| 829 | t.Fatal(err) |
| 830 | } |
| 831 | |
| 832 | if *validFlag != true { |
| 833 | t.Errorf("validFlag is %v even though we set the alias --old_valid_falg", *validFlag) |
| 834 | } |
| 835 | if *someOtherFlag != true { |
| 836 | t.Error("someOtherFlag should be true, is ", *someOtherFlag) |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | // Every flag we add, the name (displayed also in usage) should normalized |
| 841 | func TestNormalizationFuncShouldChangeFlagName(t *testing.T) { |
nothing calls this directly
no test coverage detected