mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-07 08:50:23 +08:00
20 lines
325 B
Go
20 lines
325 B
Go
package utils
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
)
|
|
|
|
func TestSimilarity(t *testing.T) {
|
|
r := Similarity([]uint8{1, 2, 3}, []uint8{1, 3, 4})
|
|
t.Log(r)
|
|
if math.Abs(r-0.9958705948858224) > 1e-6 {
|
|
t.Fail()
|
|
}
|
|
r = Similarity([]uint8{3, 2, 1}, []uint8{1, 3, 4})
|
|
t.Log(r)
|
|
if math.Abs(r-0.6813851438692469) > 1e-6 {
|
|
t.Fail()
|
|
}
|
|
}
|