Skip to content

Commit

Permalink
style: Rename regexp matcher struct
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyno-zeta committed Sep 6, 2020
1 parent ef98919 commit fb02a7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions string-regexp-matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/golang/mock/gomock"
)

type stringRegexp struct {
type stringRegexpMatcher struct {
reg *regexp.Regexp
}

func (s *stringRegexp) String() string {
func (s *stringRegexpMatcher) String() string {
return fmt.Sprintf("input matching regexp %s", s.reg.String())
}

func (s *stringRegexp) Matches(x interface{}) bool {
func (s *stringRegexpMatcher) Matches(x interface{}) bool {
// Try to cast input as string
st, ok := x.(string)
// Check if it is a string
Expand All @@ -28,7 +28,7 @@ func (s *stringRegexp) Matches(x interface{}) bool {

// Will return a new string regexp matcher
func StringRegexpMatcher(regexSt string) gomock.Matcher {
return &stringRegexp{
return &stringRegexpMatcher{
reg: regexp.MustCompile(regexSt),
}
}
8 changes: 4 additions & 4 deletions string-regexp-matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Test_stringRegexp_String(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &stringRegexp{
s := &stringRegexpMatcher{
reg: tt.fields.reg,
}
if got := s.String(); got != tt.want {
Expand Down Expand Up @@ -85,7 +85,7 @@ func Test_stringRegexp_Matches(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &stringRegexp{
s := &stringRegexpMatcher{
reg: tt.fields.reg,
}
if got := s.Matches(tt.args.x); got != tt.want {
Expand All @@ -102,14 +102,14 @@ func TestStringRegexpMatcher(t *testing.T) {
tests := []struct {
name string
args args
want *stringRegexp
want *stringRegexpMatcher
}{
{
name: "constructor",
args: args{
regexSt: "^a$",
},
want: &stringRegexp{
want: &stringRegexpMatcher{
reg: regexp.MustCompile("^a$"),
},
},
Expand Down

0 comments on commit fb02a7e

Please sign in to comment.