コード例 #1
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
        private void TestTree(
            string label,
            IRangeList tree,
            IEnumerable <Op> sequence,
            VoidAction action)
        {
            try
            {
                BuildTree(tree, sequence);
            }
            catch (Exception exception)
            {
                Console.WriteLine("{0} [setup]: Unexpected exception occurred: {1}", label, exception);
                throw new UnitTestFailureException(label, exception);
            }

            try
            {
                action();
            }
            catch (Exception exception)
            {
                Console.WriteLine("{0} [action]: Unexpected exception occurred: {1}", label, exception);
                throw new UnitTestFailureException(label, exception);
            }

            ValidateRanges(((INonInvasiveRange2MapInspection)tree).GetRanges());
        }
コード例 #2
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 protected void ValidateRangesEqual(IRangeList tree1, IRangeList tree2)
 {
     IncrementIteration();
     Range2MapEntry[] ranges1 = ((INonInvasiveRange2MapInspection)tree1).GetRanges();
     ValidateRanges(ranges1);
     Range2MapEntry[] ranges2 = ((INonInvasiveRange2MapInspection)tree2).GetRanges();
     ValidateRanges(ranges2);
     ValidateRangesEqual(ranges1, ranges2);
     TestTrue("GetExtent", delegate() { return(tree1.GetExtent() == tree2.GetExtent()); });
 }
コード例 #3
0
        public override bool Do(int seed, StochasticControls control)
        {
            IRangeList[] collections = new IRangeList[]
            {
                new ReferenceRangeList(), // must be first

                new SplayTreeRangeList(),
                new SplayTreeArrayRangeList(),
                new AdaptRangeListToRangeListLong(new SplayTreeRangeListLong()),

                new RedBlackTreeRangeList(),
                new RedBlackTreeArrayRangeList(),
                new AdaptRangeListToRangeListLong(new RedBlackTreeRangeListLong()),

                new AVLTreeRangeList(),
                new AVLTreeArrayRangeList(),
                new AdaptRangeListToRangeListLong(new AVLTreeRangeListLong()),
            };

            Tuple <Tuple <int, int>, InvokeAction <IRangeList> >[] actions = new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >[]
            {
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), ContainsAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(300 - 90, 300 + 100), TryInsertAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(300, 300), TryDeleteAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), TryGetLengthAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), TrySetLengthAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(300 - 90, 300 + 100), InsertAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(300, 300), DeleteAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), GetLengthAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), SetLengthAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(150, 150), AdjustLengthAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(100, 100), GetExtentAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(150, 150), NearestLessOrEqualAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(150, 150), NearestLessAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(150, 150), NearestGreaterOrEqualAction),
                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(150, 150), NearestGreaterAction),

                new Tuple <Tuple <int, int>, InvokeAction <IRangeList> >(new Tuple <int, int>(75, 75), EnumerateAction),
            };

            return(StochasticDriver(
                       "Range Map Stochastic Test",
                       seed,
                       control,
                       collections,
                       actions,
                       delegate(IRangeList _collection) { return _collection.Count; },
                       delegate(IRangeList[] _collections) { Validate(_collections); }));
        }
コード例 #4
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 private void BuildTree(
     IRangeList tree,
     IEnumerable <Op> sequence)
 {
     ValidateTree(tree);
     foreach (Op op in sequence)
     {
         IncrementIteration();
         op.Do(tree);
         ValidateTree(tree);
         ValidateRanges(((INonInvasiveRange2MapInspection)tree).GetRanges());
     }
 }
コード例 #5
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 private void BuildTree(
     IRangeList tree,
     IRangeList treeAnalog,
     IEnumerable <Op> sequence)
 {
     ValidateTree(tree);
     foreach (Op op in sequence)
     {
         IncrementIteration();
         op.Do(tree, treeAnalog);
         ValidateTree(tree);
     }
     ValidateRangesEqual(tree, treeAnalog);
 }
コード例 #6
0
ファイル: UnitTestAllocation.cs プロジェクト: fsgeek/TreeLib
 public AllocTestRangeList(IRangeList actual)
 {
     this.actual = actual;
 }
コード例 #7
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public override void Do(IRangeList tree, IRangeList treeAnalog)
 {
     tree.Delete(start);
     treeAnalog.Delete(start);
 }
コード例 #8
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public override void Do(IRangeList tree)
 {
     tree.Delete(start);
 }
コード例 #9
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public override void Do(IRangeList tree, IRangeList treeAnalog)
 {
     tree.Insert(start, length);
     treeAnalog.Insert(start, length);
 }
コード例 #10
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public override void Do(IRangeList tree)
 {
     tree.Insert(start, length);
 }
コード例 #11
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public abstract void Do(IRangeList tree, IRangeList treeAnalog);
コード例 #12
0
ファイル: UnitTestRangeList.cs プロジェクト: fsgeek/TreeLib
 public abstract void Do(IRangeList tree);