Exemplo n.º 1
0
        public void Exists_IndexReturned(string txt, string pattern, int expectedPos)
        {
            //Arrange
            SubstringSearchBoyerMoore bm = new SubstringSearchBoyerMoore(pattern, new AsciiAlphabet());

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

            //Assert
            Assert.Equal(expectedPos, pos);
        }
Exemplo 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.";
            SubstringSearchBoyerMoore bm = new SubstringSearchBoyerMoore(pattern, new AsciiAlphabet());

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

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