Exemplo n.º 1
0
        public void RemoveSequentialData_InReversedOrder_Test()
        {
            const int count   = 100;
            var       items   = Enumerable.Range(0, count).ToArray();
            var       itemSet = new SortedSet <int>(items);

            var node = CreateTree(items);

            foreach (var i in items.Reverse())
            {
                node = TwoThreeHelper.Remove(node, i);
                itemSet.Remove(i);

                AssertValid(node);
                CollectionAssert.AreEqual(itemSet, node.GetValues());
            }
        }
Exemplo n.º 2
0
        public void RemoveRandomData_Test()
        {
            const int count   = 100;
            var       items   = RandomHelper.UniqueSequence(_random, count);
            var       itemSet = new SortedSet <int>(items);

            var node = CreateTree(items);

            var shuffled = RandomHelper.Shuffle(_random, items);

            foreach (var i in shuffled)
            {
                node = TwoThreeHelper.Remove(node, i);
                itemSet.Remove(i);

                AssertValid(node);
                CollectionAssert.AreEqual(itemSet, node.GetValues());
            }

            Assert.IsInstanceOf <EmptyTwoThree <int> >(node);
        }