コード例 #1
0
        public void AddTwoNumber_SingleNode()
        {
            ListNode l1 = new ListNode(1);
            ListNode l2 = new ListNode(2);

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(3, result.val);
        }
コード例 #2
0
        public void AddTwoNumber_Bigger_Than_10()
        {
            ListNode l1 = new ListNode(5)
            {
            };

            ListNode l2 = new ListNode(5)
            {
            };

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(0, result.val);
            Assert.AreEqual(1, result.next.val);
        }
コード例 #3
0
        public void AddTwoNumber_TwoNode()
        {
            ListNode l1 = new ListNode(1);

            l1.next = new ListNode(2);

            ListNode l2 = new ListNode(2);

            l2.next = new ListNode(3);

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(3, result.val);
            Assert.AreEqual(5, result.next.val);
        }
コード例 #4
0
        public void AddTwoNumber_L1_L2_Length_Different()
        {
            ListNode l1 = new ListNode(5)
            {
            };

            ListNode l2 = new ListNode(5)
            {
                next = new ListNode(1)
            };

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(0, result.val);
            Assert.AreEqual(2, result.next.val);
        }
コード例 #5
0
        public void AddTwoNumber_ThreeNode_Bigger_Than_10()
        {
            ListNode l1 = new ListNode(2)
            {
                next = new ListNode(4)
                {
                    next = new ListNode(3)
                }
            };

            ListNode l2 = new ListNode(5)
            {
                next = new ListNode(6)
                {
                    next = new ListNode(4)
                }
            };

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(7, result.val);
            Assert.AreEqual(0, result.next.val);
            Assert.AreEqual(8, result.next.next.val);
        }
コード例 #6
0
        public void AddTwoNumber_ThreeNode()
        {
            ListNode l1 = new ListNode(1)
            {
                next = new ListNode(2)
                {
                    next = new ListNode(5)
                }
            };

            ListNode l2 = new ListNode(2)
            {
                next = new ListNode(3)
                {
                    next = new ListNode(4)
                }
            };

            var result = AddTwoNumber.AddTwoNumbers(l1, l2);

            Assert.AreEqual(3, result.val);
            Assert.AreEqual(5, result.next.val);
            Assert.AreEqual(9, result.next.next.val);
        }
コード例 #7
0
ファイル: AddTwoNumberTest.cs プロジェクト: Mani0811/Leetcode
 public AddTwoNumberTest()
 {
     _addTwoNumber = new AddTwoNumber();
     PrepareData();
 }