generated from VLADIMIR/template
add places operations
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
package formatter
|
||||
|
||||
type IFormatter interface {
|
||||
FormatText(text string) string
|
||||
FormatString(text string) string
|
||||
}
|
||||
@@ -1,17 +1,11 @@
|
||||
package formatter
|
||||
package formatter_utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type service struct{}
|
||||
|
||||
func NewFormatter() IFormatter {
|
||||
return &service{}
|
||||
}
|
||||
|
||||
func (s *service) FormatText(text string) string {
|
||||
func FormatText(text string) string {
|
||||
scanner := bufio.NewScanner(strings.NewReader(text))
|
||||
|
||||
scanner.Split(bufio.ScanLines)
|
||||
@@ -41,7 +35,7 @@ func (s *service) FormatText(text string) string {
|
||||
return res.String()
|
||||
}
|
||||
|
||||
func (s *service) FormatString(text string) string {
|
||||
func FormatString(text string) string {
|
||||
l := strings.TrimSpace(text)
|
||||
if strings.HasPrefix(l, "--") {
|
||||
l = strings.Replace(l, "--", "—", 1)
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
package formatter
|
||||
package formatter_utils
|
||||
|
||||
import "testing"
|
||||
|
||||
@@ -31,8 +31,7 @@ func Test_service_FormatText(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var s service
|
||||
got := s.FormatText(tt.text)
|
||||
got := FormatText(tt.text)
|
||||
if got != tt.want {
|
||||
t.Errorf("FormatText() = %v, want %v", got, tt.want)
|
||||
}
|
||||
Reference in New Issue
Block a user