(t *testing.T)
| 897 | } |
| 898 | |
| 899 | func TestNormalizationSetFlags(t *testing.T) { |
| 900 | f := NewFlagSet("normalized", ContinueOnError) |
| 901 | nfunc := wordSepNormalizeFunc |
| 902 | testName := "valid_flag" |
| 903 | normName := nfunc(nil, testName) |
| 904 | if testName == string(normName) { |
| 905 | t.Error("TestNormalizationSetFlags meaningless: the original and normalized flag names are identical:", testName) |
| 906 | } |
| 907 | |
| 908 | f.Bool(testName, false, "bool value") |
| 909 | f.Set(testName, "true") |
| 910 | f.SetNormalizeFunc(nfunc) |
| 911 | |
| 912 | if len(f.formal) != 1 { |
| 913 | t.Error("Normalizing flags should not result in duplications in the flag set:", f.formal) |
| 914 | } |
| 915 | if f.orderedFormal[0].Name != string(normName) { |
| 916 | t.Error("Flag name not normalized") |
| 917 | } |
| 918 | for k := range f.formal { |
| 919 | if k != "valid.flag" { |
| 920 | t.Errorf("The key in the flag map should have been normalized: wanted \"%s\", got \"%s\" instead", normName, k) |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | if !reflect.DeepEqual(f.formal, f.actual) { |
| 925 | t.Error("The map of set flags should get normalized. Formal:", f.formal, "Actual:", f.actual) |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | // Declare a user-defined flag type. |
| 930 | type flagVar []string |
nothing calls this directly
no test coverage detected