diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-04-02 20:43:58 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-04-02 21:00:42 +0200 |
commit | 4494a01b794ab785c64c8e93c61ccbfa845bc478 (patch) | |
tree | b7401804a188d8b5d5c627b1268c1869f902eb43 /metrics/metrics_test.go | |
parent | e91e222cd21213961d1e6206e1523bee2c21fa0c (diff) | |
download | hugo-4494a01b794ab785c64c8e93c61ccbfa845bc478.tar.gz hugo-4494a01b794ab785c64c8e93c61ccbfa845bc478.zip |
metrics: Adjust the howSimilar logic vs strings
Also add a test.
Diffstat (limited to 'metrics/metrics_test.go')
-rw-r--r-- | metrics/metrics_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index 70baa0a61..d22a51733 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -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) + "!" |