Skip to content

Commit

Permalink
Rename ContainsString to containString
Browse files Browse the repository at this point in the history
  • Loading branch information
mingrammer committed Dec 3, 2018
1 parent 4591419 commit 88e6f3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions array.go
@@ -1,9 +1,8 @@
package main

// ContainsString checks if a string array contains a given string
func ContainsString(arr []string, str string) bool {
func containString(arr []string, str string) bool {
for _, s := range arr {
if str == s {
if s == str {
return true
}
}
Expand Down
8 changes: 4 additions & 4 deletions array_test.go
Expand Up @@ -6,11 +6,11 @@ import (
"github.com/stretchr/testify/assert"
)

func TestContainsString(t *testing.T) {
func TestContainString(t *testing.T) {
a := assert.New(t)

arr := []string{"a", "b", "c", "d", "e"}
a.Equal(true, ContainsString(arr, "a"), "a is in arr")
a.Equal(true, ContainsString(arr, "e"), "e is in arr")
a.Equal(false, ContainsString(arr, "f"), "f is not in arr")
a.Equal(true, containString(arr, "a"), "a is in arr")
a.Equal(true, containString(arr, "e"), "e is in arr")
a.Equal(false, containString(arr, "f"), "f is not in arr")
}
4 changes: 2 additions & 2 deletions option.go
Expand Up @@ -79,15 +79,15 @@ func defaultOptions() *Option {

// ParseFormat validates the given format
func ParseFormat(format string) (string, error) {
if !ContainsString(validFormats, format) {
if !containString(validFormats, format) {
return "", fmt.Errorf("%s is not a valid format", format)
}
return format, nil
}

// ParseType validates the given type
func ParseType(logType string) (string, error) {
if !ContainsString(validTypes, logType) {
if !containString(validTypes, logType) {
return "", fmt.Errorf("%s is not a valid log type", logType)
}
return logType, nil
Expand Down

0 comments on commit 88e6f3b

Please sign in to comment.