public void StaticDamerauOSAShouldBeThreadsafe()
 {
     System.Threading.Tasks.Parallel.For(0, testStrings.Count, i => {
         foreach (var s2 in testStrings)
         {
             int d1 = Distance.DamerauOSA(testStrings[i], s2);
             int d2 = EditDistanceReference.RefDamerauOSA(testStrings[i], s2);
             Assert.AreEqual(d2, d1);
         }
     });
 }
 public void StaticDamerauOSAShouldMatchReferenceImplementationMax1()
 {
     foreach (var s1 in testStrings)
     {
         foreach (var s2 in testStrings)
         {
             int d1 = Distance.DamerauOSA(s1, s2, 1);
             int d2 = EditDistanceReference.RefDamerauOSA(s1, s2, 1);
             Assert.AreEqual(d2, d1);
         }
     }
 }
示例#3
0
 public void StaticLevDistanceShouldMatchReferenceImplementationMax1()
 {
     foreach (var s1 in testStrings)
     {
         foreach (var s2 in testStrings)
         {
             int d1 = Distance.Levenshtein(s1, s2, 1);
             int d2 = EditDistanceReference.RefLevenshtein(s1, s2, 1);
             Assert.AreEqual(d2, d1);
         }
     }
 }
        public void DamerauOSAShouldMatchReferenceImplementationMax0()
        {
            var ed = new DamerauOSA();

            foreach (var s1 in testStrings)
            {
                foreach (var s2 in testStrings)
                {
                    int d1 = (int)ed.Distance(s1, s2, 0);
                    int d2 = EditDistanceReference.RefDamerauOSA(s1, s2, 0);
                    Assert.AreEqual(d2, d1);
                }
            }
        }
示例#5
0
        public void LevDistanceShouldMatchReferenceImplementationMax0()
        {
            var ed = new Levenshtein();

            foreach (var s1 in testStrings)
            {
                foreach (var s2 in testStrings)
                {
                    int d1 = (int)ed.Distance(s1, s2, 0);
                    int d2 = EditDistanceReference.RefLevenshtein(s1, s2, 0);
                    Assert.AreEqual(d2, d1);
                }
            }
        }