Skip to content

Commit

Permalink
rename value getter
Browse files Browse the repository at this point in the history
  • Loading branch information
RikaCelery committed Oct 13, 2024
1 parent 4524132 commit 09e5c79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,25 @@ type PatternParsed struct {
Msg *message.Segment
}

func (p PatternParsed) GetText() []string {
func (p PatternParsed) Text() []string {
if !p.Valid {
return nil
}
return p.Value.([]string)
}
func (p PatternParsed) GetAt() string {
func (p PatternParsed) At() string {
if !p.Valid {
return ""
}
return p.Value.(string)
}
func (p PatternParsed) GetImage() string {
func (p PatternParsed) Image() string {
if !p.Valid {
return ""
}
return p.Value.(string)
}
func (p PatternParsed) GetReply() string {
func (p PatternParsed) Reply() string {
if !p.Valid {
return ""
}
Expand Down
8 changes: 4 additions & 4 deletions pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ func TestPattern_Reply(t *testing.T) {
}
}
func TestPatternParsed_Gets(t *testing.T) {
assert.Equal(t, []string{"gaga"}, PatternParsed{Valid: true, Value: []string{"gaga"}}.GetText())
assert.Equal(t, "image", PatternParsed{Valid: true, Value: "image"}.GetImage())
assert.Equal(t, "reply", PatternParsed{Valid: true, Value: "reply"}.GetReply())
assert.Equal(t, "114514", PatternParsed{Valid: true, Value: "114514"}.GetAt())
assert.Equal(t, []string{"gaga"}, PatternParsed{Valid: true, Value: []string{"gaga"}}.Text())
assert.Equal(t, "image", PatternParsed{Valid: true, Value: "image"}.Image())
assert.Equal(t, "reply", PatternParsed{Valid: true, Value: "reply"}.Reply())
assert.Equal(t, "114514", PatternParsed{Valid: true, Value: "114514"}.At())
}
func TestPattern_SetOptional(t *testing.T) {
assert.Panics(t, func() {
Expand Down

0 comments on commit 09e5c79

Please sign in to comment.