Ejemplo n.º 1
0
        public void Exists_IndexReturned(string txt, string pattern, int expectedPos)
        {
            //Arrange
            SubstringSearchKMP kmp = new SubstringSearchKMP(pattern, new AsciiAlphabet());

            //Act
            int pos = kmp.Search(txt);

            //Assert
            Assert.Equal(expectedPos, pos);
        }
Ejemplo n.º 2
0
        public void DoesntExist_IndicatorReturned()
        {
            //Arrange
            string             pattern = "hello";
            string             txt     = "Hi! This is some test sentence. This sentence doesn't contain the word hell0 in it.";
            SubstringSearchKMP kmp     = new SubstringSearchKMP(pattern, new AsciiAlphabet());

            //Act
            int pos = kmp.Search(txt);

            //Assert
            Assert.Equal(-1, pos);
        }