Beispiel #1
0
        public void CopyToTest()
        {
            ICollection<int> heap = new MaxHeap<int>(this.testInts, true);
            int[] copy = new int[this.count];

            heap.CopyTo(copy, 0);

            for (int i = 0; i < this.count; i++)
            {
                Assert.True(copy[i] == ((MaxHeap<int>)heap)[i]);
            }

            Assert.Throws<ArgumentNullException>(() => heap.CopyTo(null, 0));
            Assert.Throws<ArgumentOutOfRangeException>(() => heap.CopyTo(copy, -1));
            Assert.Throws<ArgumentException>(() => heap.CopyTo(copy, 1));
        }