From be263b349d54318de512b25ba2488044c867df0d Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 6 Jul 2019 18:47:57 +0200 Subject: rename --- internal/flood/flood.go | 19 ++++--------------- internal/flood/flood_test.go | 23 ----------------------- 2 files changed, 4 insertions(+), 38 deletions(-) (limited to 'internal/flood') diff --git a/internal/flood/flood.go b/internal/flood/flood.go index b16b948..fce81ae 100644 --- a/internal/flood/flood.go +++ b/internal/flood/flood.go @@ -4,7 +4,6 @@ import ( "math" "sort" "strings" - "unicode" "unicode/utf8" ) @@ -18,15 +17,15 @@ type Kicker interface { Kick(nick string, message ...string) } -type Checker struct { +type Check struct { k Kicker } -func New(k Kicker) *Checker { - return &Checker{k: k} +func New(k Kicker) *Check { + return &Check{k: k} } -func (c Checker) Check(text, nick string) { +func (c Check) Check(text, nick string) { if isFlood(text) { c.k.Kick(nick) } @@ -68,13 +67,3 @@ func commonWord(v []string) int { sort.Sort(sort.Reverse(sort.IntSlice(l))) return l[0] } - -func noSpaceCompare(a, b string) bool { - dropSpaces := func(r rune) rune { - if unicode.IsSpace(r) { - return -1 - } - return r - } - return strings.Map(dropSpaces, a) == strings.Map(dropSpaces, b) -} diff --git a/internal/flood/flood_test.go b/internal/flood/flood_test.go index a09a3c4..1874254 100644 --- a/internal/flood/flood_test.go +++ b/internal/flood/flood_test.go @@ -26,26 +26,3 @@ func TestFlood(t *testing.T) { }) } } - -func TestNoSpaceCompare(t *testing.T) { - testCases := []struct { - a, b string - ok bool - }{ - {"", "", true}, - {"x", "", false}, - {"", "x", false}, - {"x ", "x", true}, - {" x", "x", true}, - {"x x", "xx", true}, - {"x x x", "x", false}, - } - for _, tc := range testCases { - t.Run(tc.a+"?"+tc.b, func(t *testing.T) { - ok := noSpaceCompare(tc.a, tc.b) - if ok != tc.ok { - t.Errorf("got %v; want %v", ok, tc.ok) - } - }) - } -} -- cgit v1.2.3