mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-18 07:12:43 +00:00
helpers: Remove unusded WordCount
This commit is contained in:
parent
e856f24129
commit
001dd01ee2
2 changed files with 0 additions and 21 deletions
|
@ -421,16 +421,6 @@ func totalWordsOld(s string) int {
|
||||||
return len(strings.Fields(s))
|
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.
|
// TruncateWordsByRune truncates words by runes.
|
||||||
func TruncateWordsByRune(words []string, max int) (string, bool) {
|
func TruncateWordsByRune(words []string, max int) (string, bool) {
|
||||||
count := 0
|
count := 0
|
||||||
|
|
|
@ -16,7 +16,6 @@ package helpers
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
"html/template"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue