예제 #1
0
        public void ShouldInsertAndFindElement()
        {
            var array = new HighArray(5);

            array.Insert(1);

            var index = array.Find(1);

            Assert.AreEqual(index, 0);

            array.Insert(2);
            index = array.Find(2);
            Assert.AreEqual(index, 1);

            var elem = array.Get(index);

            Assert.AreEqual(elem, 2);
        }
예제 #2
0
        public void ShouldMakeSortedArray()
        {
            var fArray = new HighArray(3);

            fArray.Insert(2);
            fArray.Insert(3);
            fArray.Insert(1);

            var sArray = new HighArray(3);

            for (var i = 0; i < fArray.Length; i++)
            {
                sArray.Insert(fArray.RemoveMax());
            }

            var sArrayFirstElem = sArray.Get(0);

            Assert.AreEqual(sArrayFirstElem, 3);
        }
예제 #3
0
        public void ShouldThrowAnOutOfRangeException([Values(3, -1)] int index)
        {
            var array = new HighArray(3);

            Assert.Catch(typeof(ArgumentOutOfRangeException), () => array.Get(index));
        }