/// <exception cref="NGit.Diff.SimilarityIndex.TableFullException"></exception> private static int KeyFor(string line) { SimilarityIndex si = Hash(line); NUnit.Framework.Assert.AreEqual(1, si.Size(), "single line scored"); return(si.Key(0)); }
public virtual void TestIndexingLargeObject() { byte[] @in = Sharpen.Runtime.GetBytesForString((string.Empty + "A\n" + "B\n" + "B\n" + "B\n"), "UTF-8"); // // // // SimilarityIndex si = new SimilarityIndex(); si.Hash(new ByteArrayInputStream(@in), @in.Length); NUnit.Framework.Assert.AreEqual(2, si.Size()); }
public virtual void TestIndexingSmallObject() { SimilarityIndex si = Hash(string.Empty + "A\n" + "B\n" + "D\n" + "B\n"); // // // // // int key_A = KeyFor("A\n"); int key_B = KeyFor("B\n"); int key_D = KeyFor("D\n"); NUnit.Framework.Assert.IsTrue(key_A != key_B && key_A != key_D && key_B != key_D); NUnit.Framework.Assert.AreEqual(3, si.Size()); NUnit.Framework.Assert.AreEqual(2, si.Count(si.FindIndex(key_A))); NUnit.Framework.Assert.AreEqual(4, si.Count(si.FindIndex(key_B))); NUnit.Framework.Assert.AreEqual(2, si.Count(si.FindIndex(key_D))); }