public void Test_RabinKarpRollingHash_StringContains() { var searcher = new SubstringSearch(); Assert.AreEqual(2, searcher.RabinKarpRollingHash("asdfxcv", "dfxc")); Assert.AreEqual(0, searcher.RabinKarpRollingHash("asdfxcv", "asdfx")); Assert.AreEqual(5, searcher.RabinKarpRollingHash("01234asdfxcv", "a")); Assert.AreEqual(5, searcher.RabinKarpRollingHash("01234asdf", "asdf")); }
public void ExceptionForEmptyStringSecondArgumentTest() { // Arrange var toMatch = "abc"; var toSearch = string.Empty; // Act SubstringSearch.IsSubstring(toMatch, toSearch); }
public static void Main(string[] args) { string str = "abcxabcdabcdabcy"; string subString = "abcdabcy"; SubstringSearch ss = new SubstringSearch(); bool result = ss.KMP(str.ToCharArray(), subString.ToCharArray()); Console.WriteLine(result); }
public void ExceptionForNullSecondArgumentTest() { // Arrange var toMatch = "abc"; string toSearch = null; // Act SubstringSearch.IsSubstring(toMatch, toSearch); }
public void NoMatchForNonadjacentStringTest() { // Arrange var toMatch = "abc"; var toSearch = "a_b_c"; var expected = false; // Act var actual = SubstringSearch.IsSubstring(toMatch, toSearch); // Assert Assert.AreEqual(expected, actual); }
public void MultipleMatchesTest() { // Arrange var toMatch = "abc"; var toSearch = "abcabc"; var expected = true; // Act var actual = SubstringSearch.IsSubstring(toMatch, toSearch); // Assert Assert.AreEqual(expected, actual); }
public void EndsWithMatchTest() { // Arrange var toMatch = "abc"; var toSearch = "_abc"; var expected = true; // Act var actual = SubstringSearch.IsSubstring(toMatch, toSearch); // Assert Assert.AreEqual(expected, actual); }
public void NoMatchForDifferentCasingTest() { // Arrange var toMatch = "abc"; var toSearch = "ABC"; var expected = false; // Act var actual = SubstringSearch.IsSubstring(toMatch, toSearch); // Assert Assert.AreEqual(expected, actual); }