public void TestLevenshteinSimilarityWithDifferentValues() { Assert.AreEqual((decimal)4 / 5, Similarity.CalculateLevenshteinSimilarity("test", "test2").Value); Assert.AreEqual((decimal)4 / 5, Similarity.CalculateLevenshteinSimilarity("test1", "test2").Value); Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("test", string.Empty).Value); Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity(string.Empty, "test").Value); Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("test", "a").Value); Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("a", "test").Value); Assert.AreEqual((decimal)1 / 4, Similarity.CalculateLevenshteinSimilarity("test", "aeaa").Value); Assert.AreEqual((decimal)1 / 4, Similarity.CalculateLevenshteinSimilarity("aeaa", "test").Value); Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("abcd", "efgh").Value); Assert.AreEqual((decimal)3 / 8, Similarity.CalculateLevenshteinSimilarity("xx345xxx", "yy345yyy").Value); Assert.AreEqual((decimal)5 / 8, Similarity.CalculateLevenshteinSimilarity("12xxx678", "12yyy678").Value); Assert.AreEqual((decimal)7 / 10, Similarity.CalculateLevenshteinSimilarity("12345678", "1x34567890").Value); }
public void TestLevenshteinSimilarityWithEqualStrings() { string testString = "test"; Assert.AreEqual(1, Similarity.CalculateLevenshteinSimilarity(testString, testString).Value); }
public void TestLevenshteinSimilarityWithCompletelyDifferentStrings() { Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("abcd", "efgh").Value); }