-
Notifications
You must be signed in to change notification settings - Fork 293
/
RabinKarp_Tests.cs
39 lines (26 loc) · 978 Bytes
/
RabinKarp_Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Advanced.Algorithms.String;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.String
{
[TestClass]
public class RabinKarpTests
{
[TestMethod]
public void String_RabinKarp_Test()
{
var algorithm = new RabinKarp();
var index = algorithm.Search("xabcabzabc", "abc");
Assert.AreEqual(1, index);
index = algorithm.Search("abdcdaabxaabxcaabxaabxay", "aabxaabxcaabxaabxay");
Assert.AreEqual(5, index);
index = algorithm.Search("aaaabaaaaaaa", "aaaa");
Assert.AreEqual(0, index);
index = algorithm.Search("abcabababdefgabcd", "fga");
Assert.AreEqual(11, index);
index = algorithm.Search("abxabcabcaby", "abcaby");
Assert.AreEqual(6, index);
index = algorithm.Search("abxabcabcaby", "abx");
Assert.AreEqual(0, index);
}
}
}