Пример #1
0
        protected internal override DiffAlgorithm Algorithm()
        {
            HistogramDiff hd = new HistogramDiff();

            hd.SetFallbackAlgorithm(null);
            return(hd);
        }
Пример #2
0
 internal State(HistogramDiff _enclosing, EditList edits, HashedSequenceComparator
                <S> cmp, HashedSequence <S> a, HashedSequence <S> b)
 {
     this._enclosing = _enclosing;
     this.cmp        = cmp;
     this.a          = a;
     this.b          = b;
     this.edits      = edits;
 }
Пример #3
0
        public virtual void TestExceedsChainLength_DuringScanOfB()
        {
            HistogramDiff hd = new HistogramDiff();

            hd.SetFallbackAlgorithm(null);
            hd.SetMaxChainLength(1);
            EditList r = hd.Diff(RawTextComparator.DEFAULT, T("RaaS"), T("QaaT"));

            NUnit.Framework.Assert.AreEqual(1, r.Count);
            NUnit.Framework.Assert.AreEqual(new Edit(0, 4, 0, 4), r[0]);
        }
Пример #4
0
        public virtual void TestExceedsChainLength_DuringScanOfA()
        {
            HistogramDiff hd = new HistogramDiff();

            hd.SetFallbackAlgorithm(null);
            hd.SetMaxChainLength(3);
            SequenceComparator <RawText> cmp = new _SequenceComparator_97();
            EditList r = hd.Diff(cmp, T("RabS"), T("QabT"));

            NUnit.Framework.Assert.AreEqual(1, r.Count);
            NUnit.Framework.Assert.AreEqual(new Edit(0, 4, 0, 4), r[0]);
        }
Пример #5
0
        public virtual void TestFallbackToMyersDiff()
        {
            HistogramDiff hd = new HistogramDiff();

            hd.SetMaxChainLength(4);
            RawTextComparator cmp = RawTextComparator.DEFAULT;
            RawText           ac  = T("bbbbb");
            RawText           bc  = T("AbCbDbEFbZ");
            EditList          r;

            // Without fallback our results are limited due to collisions.
            hd.SetFallbackAlgorithm(null);
            r = hd.Diff(cmp, ac, bc);
            NUnit.Framework.Assert.AreEqual(1, r.Count);
            // Results go up when we add a fallback for the high collision regions.
            hd.SetFallbackAlgorithm(MyersDiff <Sequence> .INSTANCE);
            r = hd.Diff(cmp, ac, bc);
            NUnit.Framework.Assert.AreEqual(5, r.Count);
        }