Exemplo n.º 1
0
        public void GetMin_CorrectReturn()
        {
            var tree = new AvlTree <int>();

            tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            tree.GetMin().Should().Be(1);
        }
Exemplo n.º 2
0
        public void Constructor_UseCustomComparer_FormsCorrectTree()
        {
            var tree = new AvlTree <int>(Comparer <int> .Create((x, y) => y.CompareTo(x)));

            tree.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            tree.GetMin().Should().Be(10);
            tree.GetMax().Should().Be(1);
            tree.GetKeysInOrder().SequenceEqual(new[] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }).Should().BeTrue();
        }
Exemplo n.º 3
0
        public void GetMin_EmptyTree_ThrowsException()
        {
            var tree = new AvlTree <int>();

            Assert.Throws <InvalidOperationException>(() => tree.GetMin());
        }