public void LinkedListSingleLinkPartition3NonStableCompleteTest1NullList()
        {
            LinkedListSingleLinkNode <int> actual = null;

            LinkedListSingleLinkPartition3NonStableComplete.Partition(ref actual, 7);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(null, actual));
        }
        public void LinkedListSingleLinkPartition3NonStableCompleteTest7AllBefore()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 8, 7, 5, 3);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(3, 5, 7, 8, 2, 1);

            LinkedListSingleLinkPartition3NonStableComplete.Partition(ref actual, 9);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
        public void LinkedListSingleLinkPartition3NonStableCompleteTest6SingleBeforeAfter()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(3, 2, 1);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1, 3, 2);

            LinkedListSingleLinkPartition3NonStableComplete.Partition(ref actual, 2);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
예제 #4
0
        public void LinkedListSingleLinkPartition1StableCompleteTest9Default()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 8, 7, 5, 3);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 5, 3, 8, 7);

            LinkedListSingleLinkPartition1StableComplete.Partition(ref actual, 7);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
예제 #5
0
        public void LinkedListSingleLinkPartition1StableCompleteTest4SingleIsPartition()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1);

            LinkedListSingleLinkPartition1StableComplete.Partition(ref actual, 1);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
예제 #6
0
        public void LinkedListSingleLinkPartition2StableUseDummyNodesTest5SingleBefore()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(3, 2);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(3, 2);

            LinkedListSingleLinkPartition2StableUseDummyNodesComplete.Partition(ref actual, 2);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
예제 #7
0
        public void LinkedListSingleLinkPartition2StableUseDummyNodesTest8AllAfter()
        {
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 8, 7, 5, 3);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 8, 7, 5, 3);

            LinkedListSingleLinkPartition2StableUseDummyNodesComplete.Partition(ref actual, 0);
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(expected, actual));
        }
        public void LinkedListSingleLinkSplit2FastSlowCompleteTestEmptyList()
        {
            // Split the list.
            LinkedListSingleLinkSplit2FastSlowComplete.Split(null, out LinkedListSingleLinkNode <int> ResultA, out LinkedListSingleLinkNode <int> ResultB, out LinkedListSingleLinkNode <int> ResultDropped);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultA, null));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultB, null));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultDropped, null));
        }
예제 #9
0
        public void LinkedListSingleRemoveDuplicates2NoAdditionalDSCompleteTest6SingleNode()
        {
            // Create with helper.
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1);

            LinkedListSingleRemoveDuplicates2NoAdditionalDSComplete.RemoveDuplicates(actual);
            LinkedListSingleLinkNode <int> .Compare(expected, actual);
        }
        public void LinkedListSingleRemoveDuplicates1HashSetCompleteTest4SingleDup()
        {
            // Create with helper.
            var actual = LinkedListSingleLinkNode <int> .CreateFromData(1, 1, 1);

            var expected = LinkedListSingleLinkNode <int> .CreateFromData(1);

            LinkedListSingleRemoveDuplicates1HashSetComplete.RemoveDuplicates(actual);
            LinkedListSingleLinkNode <int> .Compare(expected, actual);
        }
        public void LinkedListSingleLinkReverse1TestEmptyListWithDefaults()
        {
            // List to reverse.
            LinkedListSingleLinkNode <int> toReverse = null;

            // Reverse the list.
            LinkedListSingleLinkReverse1Complete.Reverse(ref toReverse);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(toReverse, null));
        }
        public void LinkedListSingleLinkReverse1TestSingleElementWithDefaults()
        {
            // List to reverse.
            var toReverse = LinkedListSingleLinkNode <int> .CreateFromData(3);

            // Expected list.
            var expected = LinkedListSingleLinkNode <int> .CreateFromData(3);

            // Reverse the list.
            LinkedListSingleLinkReverse1Complete.Reverse(ref toReverse);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(toReverse, expected));
        }
        public void LinkedListSingleLinkReverse1TestMultipleElementsWithEndingNode()
        {
            // List to reverse.
            var toReverse = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 3, 4, 5);

            // Expected list.
            var expected = LinkedListSingleLinkNode <int> .CreateFromData(2, 1, 3, 4, 5);

            // Reverse the list.
            LinkedListSingleLinkReverse1Complete.Reverse(ref toReverse, endReverse: toReverse.Next);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(toReverse, expected));
        }
        public void LinkedListSingleLinkSplit2FastSlowCompleteTestSingleElement()
        {
            // First list.
            var toSplit = LinkedListSingleLinkNode <int> .CreateFromData(3);

            // Expected A (1st half of list)
            var expectedDropped = LinkedListSingleLinkNode <int> .CreateFromData(3);

            // Split the list.
            LinkedListSingleLinkSplit2FastSlowComplete.Split(toSplit, out LinkedListSingleLinkNode <int> ResultA, out LinkedListSingleLinkNode <int> ResultB, out LinkedListSingleLinkNode <int> ResultDropped);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultA, null));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultB, null));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultDropped, expectedDropped));
        }
        public void LinkedListSingleLinkSplit2FastSlowCompleteTestSimpleEven()
        {
            // First list.
            var a = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 3, 4);

            // Expected A (1st half of list)
            var expectedA = LinkedListSingleLinkNode <int> .CreateFromData(1, 2);

            // Expected B (2nd half of list)
            var expectedB = LinkedListSingleLinkNode <int> .CreateFromData(3, 4);

            // Split the list.
            LinkedListSingleLinkSplit2FastSlowComplete.Split(a, out LinkedListSingleLinkNode <int> ResultA, out LinkedListSingleLinkNode <int> ResultB, out LinkedListSingleLinkNode <int> ResultDropped);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultA, expectedA));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultB, expectedB));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultDropped, null));
        }
예제 #16
0
        public void LinkedListSingleLinkSplit1BruteForceCompleteTestSimpleOdd()
        {
            // First list.
            var a = LinkedListSingleLinkNode <int> .CreateFromData(1, 2, 3);

            // Expected A (1st half of list)
            var expectedA = LinkedListSingleLinkNode <int> .CreateFromData(1);

            // Expected B (2nd half of list)
            var expectedB = LinkedListSingleLinkNode <int> .CreateFromData(3);

            // Expected dropped.
            var expectedDropped = LinkedListSingleLinkNode <int> .CreateFromData(2);

            // Split the list.
            LinkedListSingleLinkSplit1BruteForceComplete.Split(a, out LinkedListSingleLinkNode <int> ResultA, out LinkedListSingleLinkNode <int> ResultB, out LinkedListSingleLinkNode <int> ResultDropped);

            // Do the compare.
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultA, expectedA));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultB, expectedB));
            Assert.IsTrue(LinkedListSingleLinkNode <int> .Compare(ResultDropped, expectedDropped));
        }