コード例 #1
0
        public void Excution1Test()
        {
            var func = new MergeTwoLists();

            var result = func.Excution1(CreateLink(new List <int> {
                1, 2, 4
            }), CreateLink(new List <int> {
                1, 3, 4
            }));

            Assert.IsTrue(AreEqual(result, new List <int> {
                1, 1, 2, 3, 4, 4
            }));

            result = func.Excution1(null, CreateLink(new List <int> {
                1, 3, 4
            }));

            Assert.IsTrue(AreEqual(result, new List <int> {
                1, 3, 4
            }));

            result = func.Excution1(CreateLink(new List <int> {
                1, 3, 4
            }), null);

            Assert.IsTrue(AreEqual(result, new List <int> {
                1, 3, 4
            }));

            result = func.Excution1(CreateLink(new List <int> {
                1, 3, 4
            }), CreateLink(new List <int> {
                1
            }));

            Assert.IsTrue(AreEqual(result, new List <int> {
                1, 1, 3, 4
            }));

            result = func.Excution1(CreateLink(new List <int> {
                5
            }), CreateLink(new List <int> {
                1, 3, 4
            }));

            Assert.IsTrue(AreEqual(result, new List <int> {
                1, 3, 4, 5
            }));

            result = func.Excution1(CreateLink(new List <int> {
                -10, -9, -6, -4, 1, 9, 9
            }), CreateLink(new List <int> {
                -5, -3, 0, 7, 8, 8
            }));

            Assert.IsTrue(AreEqual(result, new List <int> {
                -10, -9, -6, -5, -4, -3, 0, 1, 7, 8, 8, 9, 9
            }));
        }
コード例 #2
0
        public void Case1()
        {
            var l1 = new MergeTwoLists.ListNode(1)
            {
                next = new MergeTwoLists.ListNode(2)
                {
                    next = new MergeTwoLists.ListNode(4)
                }
            };

            var l2 = new MergeTwoLists.ListNode(1)
            {
                next = new MergeTwoLists.ListNode(3)
                {
                    next = new MergeTwoLists.ListNode(4)
                }
            };
            var results = new MergeTwoLists().Go(l1, l2);

            var expected = new List <int> {
                1, 1, 2, 3, 4, 4
            };

            CollectionAssert.AreEqual(expected, results.GetFull());
        }
コード例 #3
0
        public void TestingMergeTwoLists(int[] l1, int[] l2, object expected)
        {
            var sut = new MergeTwoLists();

            var result = sut.MergeTwoLists2(l1, l2);

            Assert.AreEqual(expected, result);
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            // Call Even Number
            EvenNumber evenNumber = new EvenNumber();

            evenNumber.PrintEvenNumber();

            MergeTwoLists mergeTwoList = new MergeTwoLists();

            mergeTwoList.Merge();
        }
コード例 #5
0
        public void TestingMergeTwoNodes(int[] l1, int[] l2, object expected)
        {
            var sut = new MergeTwoLists();

            var list1 = sut.CreateNode(l1);
            var list2 = sut.CreateNode(l2);

            var result = sut.MergeTwoNodes(list1, list2);

            Assert.AreEqual(expected, result);
        }
コード例 #6
0
        public void TestingMergeTwoListsAnswer(int[] l1, int[] l2, object expected)
        {
            var sut = new MergeTwoLists();

            var list1 = sut.CreateNode(l1);
            var list2 = sut.CreateNode(l2);

            var tempResult = sut.MergeTwoListsAnswer(list1, list2);

            var result = sut.PrintLinkedList(tempResult);

            Assert.AreEqual(expected, result);
        }
コード例 #7
0
        public void MergesListsTest()
        {
            ListNode l1 = CreateListNode(1, 2, 4);
            ListNode l2 = CreateListNode(1, 3, 4);

            var mergedList = MergeTwoLists.Merge(l1, l2).ToList();

            var expected = new List <int>()
            {
                1, 1, 2, 3, 4, 4
            };

            CollectionAssert.AreEqual(expected, mergedList);
        }