示例#1
0
        public void InOrderNull()
        {
            ///Testing In order on empty tree
            BT testTree = new BT();

            Assert.Null(BT.IOrder(testTree.Root));
        }
示例#2
0
        public void InOrderEvenBT()
        {
            /// Testing In order traversal on even amoutn of branches
            BT testTree = new BT();

            testTree.Root = new Nodeb(100);
            Nodeb leftChild = new Nodeb(5);

            testTree.Root.Left = leftChild;

            Nodeb rightChild = new Nodeb(10);

            testTree.Root.Right = rightChild;
            List <int> expected = new List <int> {
                5, 100, 10
            };

            Assert.Equal(expected, BT.IOrder(testTree.Root));
        }
示例#3
0
        public void InOrderOddBT()
        {
            /// Testing in order traversal on odd number of branches
            BT testTree = new BT();

            testTree.Root = new Nodeb(100);
            Nodeb leftChild = new Nodeb(5);

            testTree.Root.Left = leftChild;

            Nodeb rightChild = new Nodeb(10);

            testTree.Root.Right = rightChild;

            Nodeb leftRightLeaf = new Nodeb(20);

            testTree.Root.Left.Right = leftRightLeaf;
            List <int> expected = new List <int> {
                5, 20, 100, 10
            };

            Assert.Equal(expected, BT.IOrder(testTree.Root));
        }