public void CompleteTests()
        {
            var array = new IntList();

            Assert.Equal(0, array.Count);

            array = AddArray(1, 2, 3, 4);
            Assert.Equal(4, array.Count);

            array.Add(5);
            Assert.Equal(5, array.Count);
            Assert.Equal(5, array[4]);

            array[4] = 220;
            Assert.Equal(220, array[4]);

            Assert.True(array.Contains(3));
            Assert.False(array.Contains(10));

            Assert.Equal(-1, array.IndexOf(100));

            array.Insert(5, 100);
            Assert.Equal(5, array.IndexOf(100));
            Assert.Equal(6, array.Count);

            array.Remove(100);
            Assert.Equal(-1, array.IndexOf(100));
            Assert.Equal(5, array.Count);


            array.RemoveAt(4);
            Assert.Equal(4, array[3]);
            Assert.Equal(4, array.Count);
        }
Exemple #2
0
        public void Test_Insert_Should_Correctly_Insert_Element_when_Array_Is_Longer_Then_4()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4, 5, 6, 7, 8);

            //When
            array.Insert(5, 100);
            //Then
            Assert.Equal(5, array.IndexOf(100));
        }
Exemple #3
0
        public void Test_Insert_Should_Correctly_Insert_Element_when_Array_Is_Shorter_Then_4()
        {
            //Given
            IntList array = AddedArray(1, 2, 3);

            //When
            array.Insert(1, 5);
            //Then
            Assert.Equal(1, array.IndexOf(5));
        }
Exemple #4
0
        public void Test_Insert_Should_Correctly_Insert_Element_1_element_array()
        {
            //Given
            IntList array = AddedArray(1);

            //When
            array.Insert(0, 100);
            //Then
            Assert.Equal(0, array.IndexOf(100));
            Assert.Equal(2, array.Count);
        }
Exemple #5
0
        public void Test_Insert_Should_Correctly_Insert_Element_At_Last_Position()
        {
            //Given
            IntList array = AddedArray(1, 2, 3, 4);

            //When
            array.Insert(3, 100);
            //Then
            Assert.Equal(3, array.IndexOf(100));
            Assert.Equal(5, array.Count);
        }
Exemple #6
0
        public void Test_Insert_Should_Correctly_Insert_Element_Array_Has_Exactly_3_elements()
        {
            //Given
            IntList array = AddedArray(1, 2, 3);

            //When
            array.Insert(1, 100);
            //Then
            array.Add(10);
            Assert.Equal(1, array.IndexOf(100));
            Assert.Equal(3, array.IndexOf(3));
            Assert.Equal(5, array.Count);
        }
Exemple #7
0
 static public int Insert(IntPtr l)
 {
     try {
         IntList      self = (IntList)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         self.Insert(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }