58 lines
2.6 KiB
Go
58 lines
2.6 KiB
Go
|
package levenshtein
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGetBestFittingChoice(t *testing.T) {
|
||
|
choices := map[string]string{
|
||
|
"ninja.scroll.1993": "tt0107692",
|
||
|
"wargames.kriegsspiele.1983": "tt0086567",
|
||
|
"x-men.2000": "tt0120903",
|
||
|
"asterix.der.gallier.1967": "tt0061369",
|
||
|
"das.schweigen.der.laemmer.1991": "tt0102926",
|
||
|
"fast.furious.7.2015": "tt2820852",
|
||
|
"inglourious.basterds.2009": "tt0361748",
|
||
|
"menace.ii.society.1993": "tt0107554",
|
||
|
"28.days.later.2002": "tt0289043",
|
||
|
"zombieland.2009": "tt1156398",
|
||
|
"vivarium.2019": "tt8368406",
|
||
|
"fast.furious.five.2011": "tt1596343",
|
||
|
"knives.out.mord.ist.familiensache.2019": "tt8946378",
|
||
|
"passengers.2016": "tt1355644",
|
||
|
"quatermain.auf.der.suche.nach.dem.schatz.der.koenige.1985": "tt0089421",
|
||
|
"your.name.2016": "tt5311514",
|
||
|
"bang.boom.bang.ein.todsicheres.ding.1999": "tt0135790",
|
||
|
"cube.1997": "tt0123755",
|
||
|
"easy.rider.1969": "tt0064276",
|
||
|
"joker.2019": "tt7286456",
|
||
|
"hellraiser.das.tor.zur.hoelle.1987": "tt0093177",
|
||
|
"terminator.1984": "tt0088247",
|
||
|
"upgrade.2018": "tt6499752",
|
||
|
"der.mann.mit.der.todeskralle.1973": "tt0070034",
|
||
|
"fast.furious.6.2013": "tt1905041",
|
||
|
"last.night.in.soho.2021": "tt9639470",
|
||
|
"oldboy.2003": "tt0364569",
|
||
|
"roter.drache.2002": "tt0289765",
|
||
|
"gladiator.2000": "tt0172495",
|
||
|
"snowden.2016": "tt3774114",
|
||
|
}
|
||
|
|
||
|
data := map[string]BestFittingChoice{
|
||
|
"cube.1997": {Ratio: 1.0, Key: "cube.1997", Value: "tt0123755"},
|
||
|
"joker.2019": {Ratio: 1.0, Key: "joker.2019", Value: "tt7286456"},
|
||
|
"der.mann.mit.der.todeskralle.1973": {Ratio: 1.0, Key: "der.mann.mit.der.todeskralle.1973", Value: "tt0070034"},
|
||
|
"fast.furious.vi.2013": {Ratio: 0.9230769230769231, Key: "fast.furious.6.2013", Value: "tt1905041"},
|
||
|
"wargames.1983": {Ratio: 0.6666666666666666, Key: "wargames.kriegsspiele.1983", Value: "tt0086567"},
|
||
|
"vivarium": {Ratio: 0.7619047619047619, Key: "vivarium.2019", Value: "tt8368406"},
|
||
|
}
|
||
|
|
||
|
for d, expectedResult := range data {
|
||
|
result := GetBestFittingChoice(d, choices)
|
||
|
if result != expectedResult {
|
||
|
t.Errorf("\ngot: %+v\nwanted: %+v\nfor: %q", result, expectedResult, d)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|