mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
metrics: Adjust the howSimilar logic vs strings
Also add a test.
This commit is contained in:
@@ -17,6 +17,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/resources/page"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -40,6 +42,12 @@ func TestSimilarPercentage(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestSimilarPercentageNonString(t *testing.T) {
|
||||
assert := require.New(t)
|
||||
assert.Equal(100, howSimilar(page.NopPage, page.NopPage))
|
||||
assert.Equal(90, howSimilar(page.Pages{}, page.Pages{}))
|
||||
}
|
||||
|
||||
func BenchmarkHowSimilar(b *testing.B) {
|
||||
s1 := "Hugo is cool and " + strings.Repeat("fun ", 10) + "!"
|
||||
s2 := "Hugo is cool and " + strings.Repeat("cool ", 10) + "!"
|
||||
|
Reference in New Issue
Block a user