Skip to content

Commit

Permalink
pkg/metricutil: address commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Feb 23, 2017
1 parent ef745db commit e387790
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/metricutil/metricutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func convertCmdLabels() map[string]string {
}

func runesHasLowerNeighborAt(runes []rune, idx int) bool {
if idx > 1 && unicode.IsLower(runes[idx-1]) {
if idx > 0 && unicode.IsLower(runes[idx-1]) {
return true
}
if idx+1 < len(runes) && unicode.IsLower(runes[idx+1]) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/metricutil/metricutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ func (s *testMetricsSuite) TestCamelCaseToSnakeCase(c *C) {
{"omg_wtf_bbq", "omg_wtf_bbq"},
{"Abc", "abc"},
{"aAbc", "a_abc"},
{"aBCd", "a_b_cd"},
{"ABc", "a_bc"},
{"AbcDef", "abc_def"},
{"AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz",
"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz"},
}

for _, input := range inputs {
c.Assert(input.newName, Equals, camelCaseToSnakeCase(input.name))
c.Assert(camelCaseToSnakeCase(input.name), Equals, input.newName)
}
}

Expand Down

0 comments on commit e387790

Please sign in to comment.