Beispiel #1
0
        public void BTNComparerReturnsTrueForBothNullBtn()
        {
            BTN btn       = null;
            BTN secondBtn = null;

            var results = BTNComparer.AreEqual(btn, secondBtn);

            Assert.IsTrue(results);
        }
Beispiel #2
0
        public static bool AreEqual(BTN btn, BTN secondBtn)
        {
            if (btn == null && secondBtn == null)
            {
                return(true);
            }

            if (btn != null && secondBtn != null)
            {
                return(btn.val == secondBtn.val && AreEqual(btn.right, secondBtn.right) && AreEqual(btn.left, secondBtn.left));
            }

            return(false);
        }
Beispiel #3
0
        public void BTNComparerReturnsFalseForDifferentBTN()
        {
            var btn = new BTN(1);

            btn.left        = new BTN(2);
            btn.right       = new BTN(3);
            btn.left.left   = new BTN(4);
            btn.left.right  = new BTN(5);
            btn.right.right = new BTN(6);
            btn.right.left  = new BTN(8);

            var secondBtn = new BTN(1);

            secondBtn.left        = new BTN(2);
            secondBtn.right       = new BTN(3);
            secondBtn.left.left   = new BTN(4);
            secondBtn.left.right  = new BTN(5);
            secondBtn.right.right = new BTN(6);
            secondBtn.right.left  = new BTN(7);

            var results = BTNComparer.AreEqual(btn, secondBtn);

            Assert.IsFalse(results);
        }
Beispiel #4
0
        public void BTNComparerReturnsTrueForTheSameBTN()
        {
            var btn = new BTN(1);

            btn.left        = new BTN(2);
            btn.right       = new BTN(3);
            btn.left.left   = new BTN(4);
            btn.left.right  = new BTN(5);
            btn.right.right = new BTN(6);
            btn.right.left  = new BTN(7);

            var secondBtn = new BTN(1);

            secondBtn.left        = new BTN(2);
            secondBtn.right       = new BTN(3);
            secondBtn.left.left   = new BTN(4);
            secondBtn.left.right  = new BTN(5);
            secondBtn.right.right = new BTN(6);
            secondBtn.right.left  = new BTN(7);

            var results = BTNComparer.AreEqual(btn, secondBtn);

            Assert.IsTrue(results);
        }
Beispiel #5
0
 public BTN(int val, BTN left, BTN right)
 {
     Val   = val;
     Left  = left;
     Right = right;
 }