Skip to content

Commit

Permalink
helpers: Remove unusded WordCount
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 4, 2017
1 parent e856f24 commit 001dd01
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
10 changes: 0 additions & 10 deletions helpers/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,16 +421,6 @@ func totalWordsOld(s string) int {
return len(strings.Fields(s))
}

// WordCount takes content and returns a map of words and count of each word.
func WordCount(s string) map[string]int {
m := make(map[string]int)
for _, f := range strings.Fields(s) {
m[f]++
}

return m
}

// TruncateWordsByRune truncates words by runes.
func TruncateWordsByRune(words []string, max int) (string, bool) {
count := 0
Expand Down
11 changes: 0 additions & 11 deletions helpers/content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package helpers
import (
"bytes"
"html/template"
"reflect"
"strings"
"testing"

Expand Down Expand Up @@ -460,13 +459,3 @@ func BenchmarkTotalWordsOld(b *testing.B) {
}
}
}

func TestWordCount(t *testing.T) {
testString := "Two, Words!"
expectedMap := map[string]int{"Two,": 1, "Words!": 1}
actualMap := WordCount(testString)

if !reflect.DeepEqual(expectedMap, actualMap) {
t.Errorf("Actual Map (%v) does not equal expected (%v)", actualMap, expectedMap)
}
}

0 comments on commit 001dd01

Please sign in to comment.