Exemplo n.º 1
0
        public virtual void TestBeforeAfterCuts()
        {
            Edit whole = new Edit(1, 8, 2, 9);
            Edit mid   = new Edit(4, 5, 3, 6);

            NUnit.Framework.Assert.AreEqual(new Edit(1, 4, 2, 3), whole.Before(mid));
            NUnit.Framework.Assert.AreEqual(new Edit(5, 8, 6, 9), whole.After(mid));
        }
Exemplo n.º 2
0
            internal virtual void DiffReplace(Edit r)
            {
                Edit lcs = new HistogramDiffIndex <S>(this._enclosing.maxChainLength, this.cmp, this
                                                      .a, this.b, r).FindLongestCommonSequence();

                if (lcs != null)
                {
                    // If we were given an edit, we can prove a result here.
                    //
                    if (lcs.IsEmpty())
                    {
                        // An empty edit indicates there is nothing in common.
                        // Replace the entire region.
                        //
                        this.edits.AddItem(r);
                    }
                    else
                    {
                        this.Diff(r.Before(lcs));
                        this.Diff(r.After(lcs));
                    }
                }
                else
                {
                    if (this._enclosing.fallback is LowLevelDiffAlgorithm)
                    {
                        LowLevelDiffAlgorithm fb = (LowLevelDiffAlgorithm)this._enclosing.fallback;
                        fb.DiffNonCommon(this.edits, this.cmp, this.a, this.b, r);
                    }
                    else
                    {
                        if (this._enclosing.fallback != null)
                        {
                            SubsequenceComparator <HashedSequence <S> > cs  = this.Subcmp();
                            Subsequence <HashedSequence <S> >           @as = Subsequence <S> .A(this.a, r);

                            Subsequence <HashedSequence <S> > bs = Subsequence <S> .B(this.b, r);

                            EditList res = this._enclosing.fallback.DiffNonCommon(cs, @as, bs);
                            Sharpen.Collections.AddAll(this.edits, Subsequence <S> .ToBase(res, @as, bs));
                        }
                        else
                        {
                            this.edits.AddItem(r);
                        }
                    }
                }
            }
Exemplo n.º 3
0
		public virtual void TestBeforeAfterCuts()
		{
			Edit whole = new Edit(1, 8, 2, 9);
			Edit mid = new Edit(4, 5, 3, 6);
			NUnit.Framework.Assert.AreEqual(new Edit(1, 4, 2, 3), whole.Before(mid));
			NUnit.Framework.Assert.AreEqual(new Edit(5, 8, 6, 9), whole.After(mid));
		}