Exemplo n.º 1
0
        public void SetLocationAtSizeOfArrayValue()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(SMART_ARRAY_SIZE, 15);

            // assert is handled by ExpectedException
        }
Exemplo n.º 2
0
        public void IncreaseArraySize()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE + 5);

            testSmartArray.SetAtIndex(9, 10);
            int actual   = testSmartArray.GetAtIndex(9);
            int expected = 10;

            Assert.AreEqual(expected, actual, 0.000001, "The search is not Loc 10.");
        }
Exemplo n.º 3
0
        public void SetLocation_0()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(0, 5);
            // assert
            int actual   = testSmartArray.GetAtIndex(0);
            int expected = 5;

            Assert.AreEqual(expected, actual, 0.000001, "Did not set SmartArray loc 0 correctly");
        }
Exemplo n.º 4
0
        public void ReturnTrueTest()
        {
            //Assemble
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(4, 11);
            //Act
            bool resault = testSmartArray.Find(11);

            //Assert
            Assert.IsTrue(resault);
        }
Exemplo n.º 5
0
        public void DecreaseArraySize()
        {
            int             SMART_ARRAY_SIZE = 10;
            SmartArrayClass testSmartArray   = new SmartArrayClass(SMART_ARRAY_SIZE - 5);

            //testSmartArray.SetAtIndex(5, 10); //Error testing, to see if the array is decreased down to 5
            //int actual = testSmartArray.GetAtIndex(5);
            testSmartArray.SetAtIndex(4, 10);
            int actual   = testSmartArray.GetAtIndex(4);
            int expected = 10;

            Assert.AreEqual(expected, actual, 0.000001, "The arrary length is bigger than 5.");
        }
Exemplo n.º 6
0
        public void ReturnFalseTest()
        {
            //Assemble
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(4, 11);
            //Act
            bool resault = testSmartArray.Find(12);

            //bool resault = testSmartArray.Find(11); //To test return false will fail.
            //Assert
            Assert.IsFalse(resault);
        }
Exemplo n.º 7
0
        public void AddValueInLoc()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(0, 1);
            testSmartArray.SetAtIndex(1, 2);
            testSmartArray.SetAtIndex(2, 3);
            testSmartArray.SetAtIndex(3, 4);
            testSmartArray.SetAtIndex(4, 11);
            // assert
            int actual   = testSmartArray.GetAtIndex(4);
            int expected = 11;

            Assert.AreEqual(expected, actual, 0.000001, "Number added in loc 5 is 11.");
        }
Exemplo n.º 8
0
        public void PreValueAfterResize2()
        {
            int             SMART_ARRAY_SIZE = 10;
            SmartArrayClass testSmartArray   = new SmartArrayClass(SMART_ARRAY_SIZE - 5);

            testSmartArray.SetAtIndex(0, 1);
            testSmartArray.SetAtIndex(1, 2);
            testSmartArray.SetAtIndex(2, 3);
            testSmartArray.SetAtIndex(3, 4);
            //testSmartArray.SetAtIndex(9, 0); //Will give an error, to making sure that the array size has decreased to 5.
            int actual   = testSmartArray.GetAtIndex(0);
            int expected = 1;

            Assert.AreEqual(expected, actual, 0.000001, "loc 0 preserved number is 1.");
        }
Exemplo n.º 9
0
        public void ArrayStartWithAll_0s()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);
            //testSmartArray.SetAtIndex(2, 5);  //used to verify test is working
            int actual = 0;

            for (int i = 0; i < SMART_ARRAY_SIZE; i++)
            {
                actual = actual + testSmartArray.GetAtIndex(i);
            }
            // assert
            int expected = 0;

            Assert.AreEqual(expected, actual, 0.000001, "SmartArray not initilized to all zeros");
        }
Exemplo n.º 10
0
        public void NegativeIndexExcep()
        {
            SmartArrayClass testSmartArray = new SmartArrayClass(SMART_ARRAY_SIZE);

            testSmartArray.SetAtIndex(SMART_ARRAY_SIZE, -1);
        }