Use _ to avoid reserved words in func args

- Fix 
This commit is contained in:
Aaron L 2017-02-24 22:27:05 -08:00
parent 3747754236
commit 8aa4e2148c
5 changed files with 61 additions and 3 deletions

View file

@ -580,3 +580,23 @@ func TestShouldTitleCaseEnum(t *testing.T) {
}
}
}
func TestReplaceReservedWords(t *testing.T) {
tests := []struct {
Word string
Replace bool
}{
{"break", true},
{"id", false},
{"type", true},
}
for i, test := range tests {
got := ReplaceReservedWords(test.Word)
if test.Replace && !strings.HasSuffix(got, "_") {
t.Errorf("%i) want suffixed (%s), got: %s", i, test.Word, got)
} else if !test.Replace && strings.HasSuffix(got, "_") {
t.Errorf("%i) want normal (%s), got: %s", i, test.Word, got)
}
}
}