Exemple #1
0
        public void Remove_MultipleKeys_TreeStillValid()
        {
            var tree = new AATree <int>();

            tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            Remove(4).Should().NotThrow();
            tree.Contains(4).Should().BeFalse();
            tree.Count.Should().Be(9);

            Remove(8).Should().NotThrow();
            tree.Contains(8).Should().BeFalse();
            tree.Count.Should().Be(8);

            Remove(1).Should().NotThrow();
            tree.Contains(1).Should().BeFalse();
            tree.Count.Should().Be(7);

            Validate(tree.Root);

            Action Remove(int x) => () => tree.Remove(x);
        }
        public void Remove_MultipleKeys_TreeStillValid()
        {
            var tree = new AATree <int>();

            tree.AddRange(new [] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            Remove(4).Should().NotThrow();
            Assert.IsFalse(tree.Contains(4));
            Assert.AreEqual(9, tree.Count);

            Remove(8).Should().NotThrow();
            Assert.IsFalse(tree.Contains(8));
            Assert.AreEqual(8, tree.Count);

            Remove(1).Should().NotThrow();
            Assert.IsFalse(tree.Contains(1));
            Assert.AreEqual(7, tree.Count);

            Validate(tree.Root);

            Action Remove(int x) => () => tree.Remove(x);
        }