Пример #1
0
 public void Find_PatternDoesNotExistInText_NoResultExists(string text, string pattern)
 {
     var tree = new SuffixTree(_encoder.GetBytes(text));
       tree.Initialize();
       var results = tree.Find(_encoder.GetBytes(pattern));
       Assert.AreEqual(0, results.OccurrencesCount);
 }
Пример #2
0
 public void Find_an()
 {
     const string text = "banana";
       var tree = new SuffixTree(_encoder.GetBytes(text));
       tree.Initialize();
       var results = tree.Find(_encoder.GetBytes("an"));
       Assert.AreEqual(2, results.OccurrencesCount);
       Assert.AreEqual(3, results.Indices[0]);
       Assert.AreEqual(1, results.Indices[1]);
 }
Пример #3
0
 public void Find_PatternEqualText_OneResultExists(string s)
 {
     var tree = new SuffixTree(_encoder.GetBytes(s));
       tree.Initialize();
       var results = tree.Find(_encoder.GetBytes(s));
       Assert.AreEqual(1, results.OccurrencesCount);
 }
Пример #4
0
        public void Find_TreeIsNotInitialized_ThrowInvalidOperationException()
        {
            const string text = "banana";
              var tree = new SuffixTree(_encoder.GetBytes(text));

              Assert.Throws<InvalidOperationException>(() => tree.Find(_encoder.GetBytes("an")));
        }
Пример #5
0
 public void Find_sba()
 {
     const string text = "sasbasaasba";
       var tree = new SuffixTree(_encoder.GetBytes(text));
       tree.Initialize();
       var results = tree.Find(_encoder.GetBytes("sba"));
       Assert.AreEqual(2, results.OccurrencesCount);
 }
Пример #6
0
 public void Find_PatternEqualText_ReturnIndexZero(string s)
 {
     var tree = new SuffixTree(_encoder.GetBytes(s));
       tree.Initialize();
       var results = tree.Find(_encoder.GetBytes(s));
       Assert.AreEqual(0, results.Indices[0]);
 }