예제 #1
0
        public void printResults_empty()
        {
            int[]        arr          = { 0 };
            TextMatching s            = new TextMatching();
            string       textMatching = s.PrintResults(arr);

            Assert.AreEqual(null, textMatching);
        }
예제 #2
0
        public void findMatch_empty()
        {
            int          FromIndex = 0;
            string       text = "", subtext = "";
            TextMatching tm = new TextMatching();

            tm.FindMatch(FromIndex, text, subtext);
        }
예제 #3
0
        public void printResults_invalidValues()
        {
            int[]        arr          = new int[] { 1, 2, 3, -1, 5, 6, 7, 8, 9 };
            TextMatching s            = new TextMatching();
            string       textMatching = s.PrintResults(arr);

            Assert.AreEqual("1,2,3", textMatching);
        }
예제 #4
0
        public void findMatch_ValidValues_lastIndex()
        {
            int          FromIndex = 0;
            string       text = "Polly put the kettle on, polly put the kettle on, polly put the kettle on we'll all have tea z", subtext = "z";
            int          expectedValue = 94;
            TextMatching tm            = new TextMatching();
            int          actualValue   = tm.FindMatch(FromIndex, text, subtext);

            Assert.AreEqual(expectedValue, actualValue);
        }
예제 #5
0
        public void calc_validValues()
        {
            string text = "polly put the kettle on, polly put the kettle on, polly put the kettle on we'll all have tea", subtext = "polly";

            int[]        expectedValues = { 1, 26, 51, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            TextMatching tm             = new TextMatching();

            int[] actualValues = tm.Calc(text, subtext);

            for (int i = 0; i < actualValues.Length; i++)
            {
                Assert.AreEqual(expectedValues[i], actualValues[i]);
            }
        }