Esempio n. 1
0
        public void UniqueTest()
        {
            string[] data = new string[]
            {
                "hello",
                "world",
                "road",
                "road",
                "cool",
                "job",
                "road"
            };

            int expectedCount = 6;

            int actualCount = 0;

            using (ForwardIterator <string> inputIterator = new ForwardIterator <string>(data))
            {
                Algorithm.Unique(inputIterator);

                actualCount = inputIterator.Count();

                Assert.IsTrue(expectedCount == actualCount);

                bool isCorrectData = (inputIterator[0] == "hello" &&
                                      inputIterator[1] == "world" &&
                                      inputIterator[2] == "world" &&
                                      inputIterator[3] == "cool" &&
                                      inputIterator[4] == "job" &&
                                      inputIterator[5] == "road");
            }
        }
Esempio n. 2
0
        public void FillTest()
        {
            using (ForwardIterator <int> inputIterator = new ForwardIterator <int>(3))
            {
                Algorithm.Fill(inputIterator, 5);

                Assert.IsTrue(inputIterator.Count() == 3);

                bool isCorrectData = (inputIterator[0] == 5 &&
                                      inputIterator[1] == 5 &&
                                      inputIterator[2] == 5);

                Assert.IsTrue(isCorrectData);
            }
        }
Esempio n. 3
0
        public void GenerateNTest()
        {
            using (ForwardIterator <int> inputIterator = new ForwardIterator <int>(3))
            {
                Algorithm.GenerateN(inputIterator, 1, delegate
                {
                    return(2);
                });

                Assert.IsTrue(inputIterator.Count() == 3);

                bool isCorrectData = (inputIterator[0] == 2 &&
                                      inputIterator[1] == 0 &&
                                      inputIterator[2] == 0);

                Assert.IsTrue(isCorrectData);
            }
        }